diff options
author | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2021-01-11 15:34:10 +0200 |
---|---|---|
committer | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2021-01-19 14:08:37 +0200 |
commit | dce4e316da66ede214977491c712b0a4ab457644 (patch) | |
tree | 992a172ed47557717468afff2628691b71f1eb5c /cps-rest/src/main/java/org/onap | |
parent | 6f25d3a2ae84aff3f22b50d10592c5321a7c98ce (diff) |
Delete schema set - REST and service layers
Issue-ID: CPS-121
Change-Id: I0fe885c79f98c994a8ac25a59b77b99eee4b3076
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-rest/src/main/java/org/onap')
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java | 7 | ||||
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java index 4237846ee7..08020eca2a 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java @@ -21,6 +21,7 @@ package org.onap.cps.rest.controller; import static org.onap.cps.rest.utils.MultipartFileUtil.extractYangResourcesMap; +import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED; import java.util.Collection; import org.modelmapper.ModelMapper; @@ -66,6 +67,12 @@ public class AdminRestController implements CpsAdminApi { return new ResponseEntity<>(schemaSet, HttpStatus.OK); } + @Override + public ResponseEntity<Void> deleteSchemaSet(final String dataspaceName, final String schemaSetName) { + cpsModuleService.deleteSchemaSet(dataspaceName, schemaSetName, CASCADE_DELETE_PROHIBITED); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + /** * Create a new anchor. * 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 2b096240bd..2f636630c4 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 @@ -26,6 +26,7 @@ import org.onap.cps.rest.controller.DataRestController; import org.onap.cps.rest.model.ErrorMessage; import org.onap.cps.spi.exceptions.CpsAdminException; import org.onap.cps.spi.exceptions.CpsException; +import org.onap.cps.spi.exceptions.DataInUseException; import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.exceptions.ModelValidationException; import org.onap.cps.spi.exceptions.NotFoundInDataspaceException; @@ -62,6 +63,11 @@ public class CpsRestExceptionHandler { return buildErrorResponse(HttpStatus.NOT_FOUND, exception.getMessage(), extractDetails(exception)); } + @ExceptionHandler({DataInUseException.class}) + public static ResponseEntity<Object> handleDataInUseException(final CpsException exception) { + return buildErrorResponse(HttpStatus.CONFLICT, exception.getMessage(), extractDetails(exception)); + } + @ExceptionHandler({CpsException.class}) public static ResponseEntity<Object> handleAnyOtherCpsExceptions(final CpsException exception) { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception.getMessage(), extractDetails(exception)); |