diff options
author | Rishi Chail <rishi.chail@est.tech> | 2020-12-17 12:55:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-12-17 12:55:49 +0000 |
commit | 1d9845679de45007db30eee42c105edcffd972fb (patch) | |
tree | 51434e7dfb545150d31c832690b1fd4464bc06a6 /cps-rest | |
parent | b9f857d3bf6d7fa8f9d0d5fa1796113d43e6e50d (diff) | |
parent | 8a1e3c9f90d2111835460fc042b4a63f93b80384 (diff) |
Merge "Associate anchor to schema set"
Diffstat (limited to 'cps-rest')
3 files changed, 19 insertions, 34 deletions
diff --git a/cps-rest/docs/api/swagger/openapi.yml b/cps-rest/docs/api/swagger/openapi.yml index ff7cdf8737..587a37606c 100755 --- a/cps-rest/docs/api/swagger/openapi.yml +++ b/cps-rest/docs/api/swagger/openapi.yml @@ -84,14 +84,18 @@ paths: required: true schema: type: string - requestBody: - content: - application/json: - schema: - title: Anchor - description: anchor - $ref: '#/components/schemas/Anchor' - required: true + - name: schema-set-name + in: query + description: schema-set-name + required: true + schema: + type: string + - name: anchor-name + in: query + description: anchor-name + required: true + schema: + type: string responses: 201: description: Created @@ -298,17 +302,3 @@ components: type: string details: type: string - Anchor: - type: object - title: Anchor - required: - - anchorName - - namespace - - revision - properties: - anchorName: - type: string - namespace: - type: string - revision: - type: string 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 d1a773c1e7..2b096240bd 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 @@ -24,13 +24,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; @@ -54,8 +52,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)); } |