From 0cd5910ca2c949bab95ec73591729c4b7230fdd1 Mon Sep 17 00:00:00 2001 From: niamhcore Date: Mon, 30 Nov 2020 14:39:28 +0000 Subject: Create Common Model objects in SPI Issue-ID: CPS-100 Signed-off-by: niamhcore Change-Id: I8ba54cc5d881d9d5f18b77a54ae28d3dda8412c1 --- .../cps/rest/controller/CpsRestController.java | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'cps-rest/src/main/java/org/onap') diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java index 549760d2f8..0821dca2b6 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java @@ -29,11 +29,12 @@ import java.io.OutputStream; import javax.validation.Valid; import org.modelmapper.ModelMapper; import org.onap.cps.api.CpService; -import org.onap.cps.api.model.AnchorDetails; +import org.onap.cps.api.CpsAdminService; +import org.onap.cps.api.CpsModuleService; import org.onap.cps.exceptions.CpsException; import org.onap.cps.exceptions.CpsValidationException; import org.onap.cps.rest.api.CpsRestApi; -import org.onap.cps.rest.model.Anchor; +import org.onap.cps.spi.model.Anchor; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -52,29 +53,36 @@ public class CpsRestController implements CpsRestApi { @Autowired private CpService cpService; + @Autowired + private CpsModuleService cpsModuleService; + + @Autowired + private CpsAdminService cpsAdminService; + @Autowired private ModelMapper modelMapper; /** * Create a new anchor. * - * @param anchor the anchor details object. + * @param anchor the anchor details object. * @param dataspaceName the dataspace name. * @return a ResponseEntity with the anchor name. */ @Override - public final ResponseEntity createAnchor(@Valid final Anchor anchor, final String dataspaceName) { - final AnchorDetails anchorDetails = modelMapper.map(anchor, AnchorDetails.class); - anchorDetails.setDataspace(dataspaceName); - final String anchorName = cpService.createAnchor(anchorDetails); + public ResponseEntity 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); return new ResponseEntity(anchorName, HttpStatus.CREATED); } @Override public ResponseEntity createModules(@Valid final MultipartFile multipartFile, final String dataspaceName) { final File fileToParse = saveToFile(multipartFile); - final SchemaContext schemaContext = cpService.parseAndValidateModel(fileToParse); - cpService.storeSchemaContext(schemaContext, dataspaceName); + final SchemaContext schemaContext = cpsModuleService.parseAndValidateModel(fileToParse); + cpsModuleService.storeSchemaContext(schemaContext, dataspaceName); return new ResponseEntity<>("Resource successfully created", HttpStatus.CREATED); } @@ -105,7 +113,7 @@ public class CpsRestController implements CpsRestApi { @Override public ResponseEntity getModule(final String dataspaceName, @Valid final String namespaceName, - @Valid final String revision) { + @Valid final String revision) { return null; } -- cgit 1.2.3-korg