diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-08-07 19:39:53 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-08-07 19:39:53 +0300 |
commit | 15a6835381bb770ef1e7ea99fe19d9b796c90958 (patch) | |
tree | ad96123eed473170ee4f0d3c1878109f0deb7de5 /vid-app-common/src/main/java/org/onap | |
parent | 12b7509555b1932b90ed7889d62b100557b603eb (diff) |
add default exception handling to VidRestrictedBaseController
Issue-ID: VID-378
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: Ie5bac35975257ad092c75e8e7e7dfd8fefa0363e
Diffstat (limited to 'vid-app-common/src/main/java/org/onap')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java index f1e3a28e6..623804002 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java @@ -24,6 +24,9 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.onap.portalsdk.core.controller.RestrictedBaseController; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.vid.exceptions.AccessDeniedException; +import org.onap.vid.exceptions.NotFoundException; +import org.onap.vid.exceptions.OperationNotAllowedException; import org.onap.vid.model.ExceptionResponse; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -33,7 +36,10 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import static org.onap.vid.utils.Logging.getMethodCallerName; +import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; +import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED; +import static org.springframework.http.HttpStatus.NOT_FOUND; public abstract class VidRestrictedBaseController extends RestrictedBaseController { @@ -59,4 +65,22 @@ public abstract class VidRestrictedBaseController extends RestrictedBaseControll public ExceptionResponse exceptionHandler(Exception e) { return ControllersUtils.handleException(e, LOGGER); } + + @ExceptionHandler(NotFoundException.class) + @ResponseStatus(value=NOT_FOUND) + public ExceptionResponse notFoundExceptionHandler(Exception e) { + return ControllersUtils.handleException(e, LOGGER); + } + + @ExceptionHandler(AccessDeniedException.class) + @ResponseStatus(value=FORBIDDEN) + public ExceptionResponse accessDeniedExceptionHandler(Exception e) { + return ControllersUtils.handleException(e, LOGGER); + } + + @ExceptionHandler(OperationNotAllowedException.class) + @ResponseStatus(value=METHOD_NOT_ALLOWED) + public ExceptionResponse illegalStateExceptionHandler(Exception e) { + return ControllersUtils.handleException(e, LOGGER); + } } |