Disabling archive functionality for normatives 56/134556/5
authorJvD_Ericsson <jeff.van.dam@est.tech>
Fri, 12 May 2023 11:37:02 +0000 (12:37 +0100)
committerMichael Morris <michael.morris@est.tech>
Wed, 17 May 2023 10:03:18 +0000 (10:03 +0000)
Issue-ID: SDC-4497
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: If7ce7205543682697a2b787aebfd4c8a3da25db7

asdctool/src/main/resources/config/error-configuration.yaml
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/ArchiveBusinessLogic.java
catalog-be/src/main/resources/config/error-configuration.yaml
catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArchiveOperation.java

index 4742241..e8f100d 100644 (file)
@@ -2868,4 +2868,13 @@ errors:
     code: 409,
     message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
     messageId: "SVC4017"
+  }
+
+  #---------SVC4018-----------------------------
+  # %1 - componentType
+  # %2 - component id
+  CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES: {
+      code: 409,
+      message: "System deployed %1 cannot be archived. Component: '%2'",
+      messageId: "SVC4018"
   }
\ No newline at end of file
index 0592615..0cdcd01 100644 (file)
@@ -2886,3 +2886,12 @@ errors:
         message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
         messageId: "SVC4017"
     }
+
+    #---------SVC4018-----------------------------
+    # %1 - componentType
+    # %2 - component id
+    CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES: {
+        code: 409,
+        message: "System deployed %1 cannot be archived. Component: '%2'",
+        messageId: "SVC4018"
+    }
\ No newline at end of file
index 19afff0..3806eed 100644 (file)
@@ -77,7 +77,11 @@ public class ArchiveBusinessLogic {
         User user = accessValidations.userIsAdminOrDesigner(userId, containerComponentType + "_ARCHIVE");
         Either<List<String>, ActionStatus> result = this.archiveOperation.archiveComponent(componentId);
         if (result.isRight()) {
-            throw new ByActionStatusComponentException(result.right().value(), componentId);
+            ActionStatus status = result.right().value();
+            if (ActionStatus.CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES.equals(status)) {
+                throw new ByActionStatusComponentException(status, containerComponentType, componentId);
+            }
+            throw new ByActionStatusComponentException(status, componentId);
         }
         this.auditAction(ArchiveOperation.Action.ARCHIVE, result.left().value(), user, containerComponentType);
         // Send Archive Notification To Facade
index a4b56d5..7589511 100644 (file)
@@ -2877,4 +2877,13 @@ errors:
         code: 409,
         message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
         messageId: "SVC4017"
+    }
+
+    #---------SVC4018-----------------------------
+    # %1 - componentType
+    # %2 - component id
+    CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES: {
+        code: 409,
+        message: "System deployed %1 cannot be archived. Component: '%2'",
+        messageId: "SVC4018"
     }
\ No newline at end of file
index e8c5d9a..6911570 100644 (file)
@@ -2863,4 +2863,13 @@ errors:
         code: 409,
         message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
         messageId: "SVC4017"
+    }
+
+    #---------SVC4018-----------------------------
+    # %1 - componentType
+    # %2 - component id
+    CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES: {
+        code: 409,
+        message: "System deployed %1 cannot be archived. Component: '%2'",
+        messageId: "SVC4018"
     }
\ No newline at end of file
index e9d7bae..7daf693 100644 (file)
@@ -132,6 +132,7 @@ public enum ActionStatus {
     INVALID_NODE_TYPES_YAML,
     //system deployed resources
     CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES,
+    CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES,
     TOSCA_GET_FUNCTION_INPUTS_ONLY_SELF_ERROR,
     TOSCA_GET_FUNCTION_INPUTS_NOT_FOUND,
     TOSCA_GET_FUNCTION_TYPE_DIVERGE,
index b8ef2ae..a8367b3 100644 (file)
@@ -29,6 +29,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import org.apache.commons.collections.MapUtils;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -38,6 +39,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -66,6 +68,11 @@ public class ArchiveOperation extends BaseOperation {
     public Either<List<String>, ActionStatus> archiveComponent(String componentId) {
         final Either<GraphVertex, JanusGraphOperationStatus> vertexResult = this.janusGraphDao.getVertexById(componentId);
         if (vertexResult.isLeft()) {
+            Map<String, Object> metadataJson = vertexResult.left().value().getMetadataJson();
+            String normative = JsonPresentationFields.NORMATIVE.getPresentation();
+            if (MapUtils.isNotEmpty(metadataJson) && metadataJson.containsKey(normative) && (boolean) metadataJson.get(normative)) {
+                return Either.right(ActionStatus.CANNOT_ARCHIVE_SYSTEM_DEPLOYED_RESOURCES);
+            }
             return doAction(ARCHIVE, vertexResult.left().value());
         } else {
             return Either.right(onError(ARCHIVE.name(), componentId, vertexResult.right().value()));