Delete anchor part 2: cps rest
[cps.git] / cps-rest / src / main / java / org / onap / cps / rest / controller / AdminRestController.java
old mode 100644 (file)
new mode 100755 (executable)
index 08020ec..ead365a
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Nordix Foundation
  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 2021 Pantheon.tech
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -33,10 +34,12 @@ import org.onap.cps.spi.model.SchemaSet;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 @RestController
+@RequestMapping("${rest.api.cps-base-path}")
 public class AdminRestController implements CpsAdminApi {
 
     @Autowired
@@ -54,6 +57,11 @@ public class AdminRestController implements CpsAdminApi {
         return new ResponseEntity<>(dataspaceName, HttpStatus.CREATED);
     }
 
+    @Override
+    public ResponseEntity<Object> deleteDataspace(final String dataspaceName) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
     @Override
     public ResponseEntity<String> createSchemaSet(final MultipartFile multipartFile,
         final String schemaSetName, final String dataspaceName) {
@@ -89,18 +97,15 @@ public class AdminRestController implements CpsAdminApi {
     }
 
     @Override
-    public ResponseEntity<Object> deleteAnchor(final String dataspaceName, final String anchorName) {
-        return null;
-    }
-
-    @Override
-    public ResponseEntity<Object> deleteDataspace(final String dataspaceName) {
-        return null;
+    public ResponseEntity<Void> deleteAnchor(final String dataspaceName, final String anchorName) {
+        cpsAdminService.deleteAnchor(dataspaceName, anchorName);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
     }
 
     @Override
     public ResponseEntity<Object> getAnchor(final String dataspaceName, final String anchorName) {
-        return null;
+        final Anchor anchor = cpsAdminService.getAnchor(dataspaceName, anchorName);
+        return new ResponseEntity<>(anchor, HttpStatus.OK);
     }
 
     @Override