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;
@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<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);
}
@Override
public ResponseEntity<Object> getModule(final String dataspaceName, @Valid final String namespaceName,
- @Valid final String revision) {
+ @Valid final String revision) {
return null;
}