diff options
author | niamhcore <niamh.core@est.tech> | 2020-11-30 14:39:28 +0000 |
---|---|---|
committer | Niamh Core <niamh.core@est.tech> | 2020-12-07 14:15:55 +0000 |
commit | 0cd5910ca2c949bab95ec73591729c4b7230fdd1 (patch) | |
tree | 6880654548e97e0e1632d38cd65a008af99142f9 /cps-rest/src/main | |
parent | 4e807e562c7fee9cd07f7dbd27263100c87c07ec (diff) |
Create Common Model objects in SPI
Issue-ID: CPS-100
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I8ba54cc5d881d9d5f18b77a54ae28d3dda8412c1
Diffstat (limited to 'cps-rest/src/main')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java | 28 |
1 files changed, 18 insertions, 10 deletions
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; @@ -53,28 +54,35 @@ public class CpsRestController implements CpsRestApi { 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<String> 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<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); return new ResponseEntity<String>(anchorName, HttpStatus.CREATED); } @Override public ResponseEntity<Object> 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<Object> getModule(final String dataspaceName, @Valid final String namespaceName, - @Valid final String revision) { + @Valid final String revision) { return null; } |