X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-rest%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Frest%2Fexceptions%2FCpsRestExceptionHandler.java;h=9495b3d9e6fba3663d9b38868d453efdeb789699;hb=e557338803286d8aaa0f877aa25d52d18735f309;hp=52af81cea731bcf561ebf77e75a71628748d19c3;hpb=a5ce86d02493f141848f9d609c65883d2198894a;p=cps.git diff --git a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java index 52af81cea..9495b3d9e 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java @@ -23,6 +23,8 @@ package org.onap.cps.rest.exceptions; import javax.servlet.http.HttpServletRequest; import javax.validation.ValidationException; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.onap.cps.rest.controller.AdminRestController; import org.onap.cps.rest.controller.DataRestController; @@ -46,6 +48,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; @Slf4j @RestControllerAdvice(assignableTypes = {AdminRestController.class, DataRestController.class, QueryRestController.class}) +@NoArgsConstructor(access = AccessLevel.PACKAGE) public class CpsRestExceptionHandler { /** @@ -60,30 +63,25 @@ public class CpsRestExceptionHandler { } @ExceptionHandler({ModelValidationException.class, DataValidationException.class, CpsAdminException.class, - CpsPathException.class}) - public static ResponseEntity handleBadRequestExceptions(final CpsException exception) { + CpsPathException.class, ValidationException.class}) + public static ResponseEntity handleBadRequestExceptions(final Exception exception) { return buildErrorResponse(HttpStatus.BAD_REQUEST, exception); } - @ExceptionHandler({ValidationException.class}) - public static ResponseEntity handleBadRequestExceptions(final ValidationException validationException) { - return buildErrorResponse(HttpStatus.BAD_REQUEST, validationException); - } - @ExceptionHandler({NotFoundInDataspaceException.class, DataNodeNotFoundException.class}) - public static ResponseEntity handleNotFoundExceptions(final CpsException exception, + public static ResponseEntity handleNotFoundExceptions(final Exception exception, final HttpServletRequest request) { return buildErrorResponse(HttpMethod.GET.matches(request.getMethod()) ? HttpStatus.NOT_FOUND : HttpStatus.BAD_REQUEST, exception); } @ExceptionHandler({DataInUseException.class, AlreadyDefinedException.class}) - public static ResponseEntity handleDataInUseException(final CpsException exception) { + public static ResponseEntity handleDataInUseException(final Exception exception) { return buildErrorResponse(HttpStatus.CONFLICT, exception); } @ExceptionHandler({CpsException.class}) - public static ResponseEntity handleAnyOtherCpsExceptions(final CpsException exception) { + public static ResponseEntity handleAnyOtherCpsExceptions(final Exception exception) { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); }