summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main/java
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-03-15 15:54:12 +0000
committerniamhcore <niamh.core@est.tech>2021-03-31 13:30:09 +0100
commit22bcf714b12e21352c1b90ba72ffc65b0cf5d6e7 (patch)
tree81cb5544bf317f264a7677c6ce614cf88ec16c1d /cps-rest/src/main/java
parent4663fd3a91ddee17393d6e4b1452213208ba5243 (diff)
Internal Server Error when creating the same data node twice
Drop back to honolulu This change adds a generic exception handler class for a already defined object and handles a JsonSyntaxException. Issue-ID: CPS-290 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: Ie645237b5dd5b8e2b1d074c5613e7da560f57484
Diffstat (limited to 'cps-rest/src/main/java')
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java7
1 files changed, 4 insertions, 3 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 d620139b7d..0437e70fe5 100644
--- 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
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Copyright (C) 2021 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@ import org.onap.cps.rest.controller.AdminRestController;
import org.onap.cps.rest.controller.DataRestController;
import org.onap.cps.rest.controller.QueryRestController;
import org.onap.cps.rest.model.ErrorMessage;
+import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.CpsAdminException;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.CpsPathException;
@@ -52,8 +54,7 @@ public class CpsRestExceptionHandler {
* @return response with response code 500.
*/
@ExceptionHandler
- public static ResponseEntity<Object> handleInternalServerErrorExceptions(
- final Exception exception) {
+ public static ResponseEntity<Object> handleInternalServerErrorExceptions(final Exception exception) {
return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception);
}
@@ -68,7 +69,7 @@ public class CpsRestExceptionHandler {
return buildErrorResponse(HttpStatus.NOT_FOUND, exception);
}
- @ExceptionHandler({DataInUseException.class})
+ @ExceptionHandler({DataInUseException.class, AlreadyDefinedException.class})
public static ResponseEntity<Object> handleDataInUseException(final CpsException exception) {
return buildErrorResponse(HttpStatus.CONFLICT, exception);
}