Delete VFC - restrict deletion of system deployed VFCs 85/128785/2
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>
Thu, 21 Apr 2022 17:19:55 +0000 (18:19 +0100)
committerKrupaNagabhushan <krupa.nagabhushan@est.tech>
Fri, 22 Apr 2022 11:53:08 +0000 (12:53 +0100)
Issue-ID: SDC-3981
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: Ib475bb4abbaabc072180a4f1ae85c7427bbbf771

catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java

index af517c5..10cc6f6 100644 (file)
@@ -2633,4 +2633,13 @@ errors:
         code: 409,
         message: "Artifact type '%1' already exist.",
         messageId: "SVC4163"
+    }
+
+    #---------SVC4164-----------------------------
+    # %1 - componentType
+    # %2 - component name
+    CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES: {
+        code: 409,
+        message: "System deployed '%1' cannot be deleted '%2'",
+        messageId: "SVC4164"
     }
\ No newline at end of file
index 86d4e0a..f4952b6 100644 (file)
@@ -4223,6 +4223,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             return componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(resourceStatus.right().value()), "");
         }
         Resource resource = resourceStatus.left().value();
+        if (isComponentSystemDeployed(resource)) {
+            throw new ByActionStatusComponentException(ActionStatus.CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES, ComponentTypeEnum.RESOURCE.getValue(),
+                resource.getName());
+        }
         StorageOperationStatus result = StorageOperationStatus.OK;
         lockComponent(resourceId, resource, "Mark resource to delete");
         try {
@@ -4244,6 +4248,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
         }
     }
 
+    private boolean isComponentSystemDeployed(Resource resource) {
+        return resource.getComponentMetadataDefinition().getMetadataDataDefinition().isNormative();
+    }
+
     public ResponseFormat deleteResourceByNameAndVersion(String resourceName, String version, User user) {
         ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NO_CONTENT);
         validateUserExists(user);
index 1862f85..922853e 100644 (file)
@@ -129,5 +129,7 @@ public enum ActionStatus {
     //ArtifactType
     ARTIFACT_TYPE_ALREADY_EXIST, FAILED_CREATE_ARTIFACTS_TYPES,
     //TOSCA node types
-    INVALID_NODE_TYPES_YAML
+    INVALID_NODE_TYPES_YAML,
+    //system deployed resources
+    CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES
 }