aboutsummaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest/src/main/java')
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java8
1 files changed, 6 insertions, 2 deletions
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 2a89ef2230..c61400d0c5 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
@@ -20,6 +20,7 @@
package org.onap.cps.rest.exceptions;
+import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.rest.controller.AdminRestController;
import org.onap.cps.rest.controller.DataRestController;
@@ -34,6 +35,7 @@ import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.exceptions.DataValidationException;
import org.onap.cps.spi.exceptions.ModelValidationException;
import org.onap.cps.spi.exceptions.NotFoundInDataspaceException;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -65,8 +67,10 @@ public class CpsRestExceptionHandler {
}
@ExceptionHandler({NotFoundInDataspaceException.class, DataNodeNotFoundException.class})
- public static ResponseEntity<Object> handleNotFoundExceptions(final CpsException exception) {
- return buildErrorResponse(HttpStatus.NOT_FOUND, exception);
+ public static ResponseEntity<Object> handleNotFoundExceptions(final CpsException exception,
+ final HttpServletRequest request) {
+ return buildErrorResponse(HttpMethod.GET.matches(request.getMethod())
+ ? HttpStatus.NOT_FOUND : HttpStatus.BAD_REQUEST, exception);
}
@ExceptionHandler({DataInUseException.class, AlreadyDefinedException.class})