From dce4e316da66ede214977491c712b0a4ab457644 Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Mon, 11 Jan 2021 15:34:10 +0200 Subject: Delete schema set - REST and service layers Issue-ID: CPS-121 Change-Id: I0fe885c79f98c994a8ac25a59b77b99eee4b3076 Signed-off-by: Ruslan Kashapov --- .../java/org/onap/cps/rest/controller/AdminRestController.java | 7 +++++++ .../java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java | 6 ++++++ 2 files changed, 13 insertions(+) (limited to 'cps-rest/src/main/java') 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 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 handleDataInUseException(final CpsException exception) { + return buildErrorResponse(HttpStatus.CONFLICT, exception.getMessage(), extractDetails(exception)); + } + @ExceptionHandler({CpsException.class}) public static ResponseEntity handleAnyOtherCpsExceptions(final CpsException exception) { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception.getMessage(), extractDetails(exception)); -- cgit 1.2.3-korg