diff options
author | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2020-11-24 11:13:43 +0200 |
---|---|---|
committer | Ruslan Kashapov <ruslan.kashapov@pantheon.tech> | 2020-12-17 14:40:53 +0200 |
commit | 8a1e3c9f90d2111835460fc042b4a63f93b80384 (patch) | |
tree | c26fa83be590816686d239580e161cc04e298197 /cps-rest/src/main/java/org | |
parent | 84ac94d2f3f9ebd6a3a7befa244beef851eac126 (diff) |
Associate anchor to schema set
- db schema updated
- db layer tests provided for ancor create and reading by dataspace
- anchor model is removed from rest api as extra
- api/spi updated to use string references instead of object
Issue-ID: CPS-99
Change-Id: Ideeb83fa9e91ec1816308d8327a6589b999c64c5
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-rest/src/main/java/org')
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java | 14 | ||||
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java | 5 |
2 files changed, 7 insertions, 12 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 e2ce367b08..336762cb49 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 @@ -43,16 +43,15 @@ public class AdminRestController implements CpsAdminApi { /** * Create a new anchor. * - * @param anchor the anchor details object. - * @param dataspaceName the dataspace name. + * @param dataspaceName dataspace name + * @param schemaSetName schema set name + * @param anchorName anchorName * @return a ResponseEntity with the anchor name. */ @Override - public ResponseEntity<String> createAnchor(final org.onap.cps.rest.model.@Valid Anchor anchor, - final String dataspaceName) { - final Anchor anchorDetails = modelMapper.map(anchor, Anchor.class); - anchorDetails.setDataspaceName(dataspaceName); - final String anchorName = cpsAdminService.createAnchor(anchorDetails); + public ResponseEntity<String> createAnchor(final String dataspaceName, final String schemaSetName, + final String anchorName) { + cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName); return new ResponseEntity<>(anchorName, HttpStatus.CREATED); } @@ -72,7 +71,6 @@ public class AdminRestController implements CpsAdminApi { } @Override - public ResponseEntity<Object> getAnchors(final String dataspaceName) { final Collection<Anchor> anchorDetails = cpsAdminService.getAnchors(dataspaceName); return new ResponseEntity<>(anchorDetails, HttpStatus.OK); 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 9d7f38ae84..d4faebc329 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 @@ -23,13 +23,11 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.onap.cps.rest.controller.AdminRestController; import org.onap.cps.rest.controller.DataRestController; import org.onap.cps.rest.model.ErrorMessage; -import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException; import org.onap.cps.spi.exceptions.CpsAdminException; import org.onap.cps.spi.exceptions.CpsException; import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.exceptions.ModelValidationException; import org.onap.cps.spi.exceptions.NotFoundInDataspaceException; -import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -52,8 +50,7 @@ public class CpsRestExceptionHandler { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); } - @ExceptionHandler({ModelValidationException.class, DataValidationException.class, - SchemaSetAlreadyDefinedException.class, AnchorAlreadyDefinedException.class, CpsAdminException.class}) + @ExceptionHandler({ModelValidationException.class, DataValidationException.class, CpsAdminException.class}) public static ResponseEntity<Object> handleBadRequestExceptions(final CpsException exception) { return buildErrorResponse(HttpStatus.BAD_REQUEST, exception.getMessage(), extractDetails(exception)); } |