From e0873dde9816543a34818c1509b1aaa1c195a875 Mon Sep 17 00:00:00 2001 From: JosephKeenan Date: Fri, 28 Jan 2022 11:22:22 +0000 Subject: [TECHDEBT] Align CPS NCMP REST API Specification - Updated ncmp.yml to align implementation with specification - Added new Exception classes to differentiate between server NCMP issues and client based NCMP issues - Added 500 error to specification - To be merged after https://gerrit.onap.org/r/c/cps/+/126848 - Added excpetion handlers for SerNcmpException & DmiRequestException Issue-ID: CPS-823 Signed-off-by: JosephKeenan Change-Id: If1c9c6c29c6ea2daa07753d7f766ef15c1ba4ca0 --- .../rest/exceptions/NetworkCmProxyRestExceptionHandler.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cps-ncmp-rest/src/main/java/org/onap/cps/ncmp') diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java index ce9dd5a02..8c6f9f1d7 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java @@ -21,7 +21,9 @@ package org.onap.cps.ncmp.rest.exceptions; import lombok.extern.slf4j.Slf4j; +import org.onap.cps.ncmp.api.impl.exception.DmiRequestException; import org.onap.cps.ncmp.api.impl.exception.NcmpException; +import org.onap.cps.ncmp.api.impl.exception.ServerNcmpException; import org.onap.cps.ncmp.rest.controller.NetworkCmProxyController; import org.onap.cps.ncmp.rest.model.ErrorMessage; import org.onap.cps.spi.exceptions.CpsException; @@ -56,11 +58,16 @@ public class NetworkCmProxyRestExceptionHandler { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); } - @ExceptionHandler({NcmpException.class}) - public static ResponseEntity handleNcmpExceptions(final NcmpException exception) { + @ExceptionHandler({ServerNcmpException.class}) + public static ResponseEntity handleServerNcmpExceptions(final ServerNcmpException exception) { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); } + @ExceptionHandler({DmiRequestException.class}) + public static ResponseEntity handleDmiRequestExceptions(final DmiRequestException exception) { + return buildErrorResponse(HttpStatus.BAD_REQUEST, exception); + } + private static ResponseEntity buildErrorResponse(final HttpStatus status, final Exception exception) { if (exception.getCause() != null || !(exception instanceof CpsException)) { log.error("Exception occurred", exception); -- cgit 1.2.3-korg