From cd6f933375c412c2f79a12e909821322d58a8499 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 29 Jan 2020 17:25:21 +0000 Subject: Configure a new Artifact Type Centralizes artifact configuration in one yaml entry. Allow the configuration of a new artifact type without the need of code changes. The configuration file now is used as a source of artifacts types instead the artifact type enum. The enum will be used as a source of base artifact types and also in hard coded business rules. Change-Id: Id0383d9fca9bce0519a4d52a4ecb3a68c8713f0f Issue-ID: SDC-2754 Signed-off-by: andre.schmid --- .../templates/default/configuration.yaml.erb | 348 -------- .../sdc/asdctool/impl/ArtifactUuidFix.java | 12 +- .../src/main/resources/config/configuration.yaml | 316 -------- .../sdc/asdctool/impl/ArtifactUuidFixTest.java | 2 +- catalog-be/.gitignore | 2 +- catalog-be/pom.xml | 21 +- .../templates/default/BE-configuration.yaml.erb | 893 ++++++++++++--------- .../csar/CsarArtifactsAndGroupsBusinessLogic.java | 10 +- .../distribution/engine/ArtifactInfoImpl.java | 89 +- .../distribution/engine/IArtifactInfo.java | 4 +- .../be/components/impl/ArtifactsBusinessLogic.java | 683 ++++++++-------- .../be/components/impl/ElementBusinessLogic.java | 8 +- .../be/components/impl/ResourceBusinessLogic.java | 29 +- .../be/components/impl/ServiceBusinessLogic.java | 5 +- .../instance/ComponentInstanceArtifactsMerge.java | 2 +- .../sdc/be/info/ArtifactTemplateInfo.java | 55 +- .../openecomp/sdc/be/servlets/ElementServlet.java | 62 +- .../java/org/openecomp/sdc/be/tosca/CsarUtils.java | 227 ++---- .../sdc/be/tosca/utils/OperationArtifactUtil.java | 22 +- .../src/main/resources/config/configuration.yaml | 25 - .../org/openecomp/sdc/ElementOperationMock.java | 8 +- .../distribution/engine/ArtifactInfoImplTest.java | 25 +- .../components/impl/ArtifactBusinessLogicTest.java | 31 +- .../impl/ArtifactsBusinessLogicTest.java | 496 +++++++++--- .../components/impl/ResourceBusinessLogicTest.java | 12 +- .../ComponentInstanceArtifactsMergeTest.java | 2 +- .../be/impl/aaf/RoleAuthorizationHandlerTest.java | 3 +- .../sdc/be/servlets/ElementServletTest.java | 5 +- .../org/openecomp/sdc/be/tosca/CsarUtilsTest.java | 10 +- .../be/tosca/utils/OperationArtifactUtilTest.java | 4 +- .../config/catalog-be/auth/configuration.yaml | 740 +---------------- .../catalog-be/auth/error-configuration.yaml | 8 + .../resources/config/catalog-be/configuration.yaml | 798 +++++++++++------- .../java/org/openecomp/sdc/be/model/Component.java | 2 +- .../org/openecomp/sdc/be/model/GroupInstance.java | 2 +- .../operations/ArtifactsOperations.java | 22 +- .../be/model/operations/api/IElementOperation.java | 21 +- .../be/model/operations/impl/ElementOperation.java | 50 +- .../operations/impl/ElementOperationTest.java | 96 +-- .../config/catalog-model/configuration.yaml | 275 ------- .../src/test/resources/config/configuration.yaml | 267 ------ catalog-ui/src/app/ng2/app.module.ts | 2 + .../artifact-form.component.spec.ts.snap | 1 + .../artifacts-form/artifact-form.component.spec.ts | 100 +-- .../artifacts-form/artifact-form.component.ts | 41 +- .../forms/artifacts-form/artifacts.service.ts | 10 +- .../artifacts-tab/artifact-tab.component.spec.ts | 2 +- .../artifacts-tab/artifacts-tab.component.ts | 2 +- .../deployment-artifacts-page.component.html | 7 +- .../deployment-artifacts-page.component.ts | 45 +- .../information-artifact-page.component.html | 5 + .../information-artifact-page.component.ts | 14 +- .../ng2/services/artifact-config.service.spec.ts | 23 + .../app/ng2/services/artifact-config.service.ts | 50 ++ .../store/actions/instance-artifacts.actions.ts | 4 +- catalog-ui/src/app/utils/constants.ts | 1 + .../sdc/be/config/ArtifactConfigManager.java | 138 ++++ .../sdc/be/config/ArtifactConfiguration.java | 68 ++ .../org/openecomp/sdc/be/config/ComponentType.java | 36 + .../org/openecomp/sdc/be/config/Configuration.java | 66 +- .../openecomp/sdc/common/api/ArtifactTypeEnum.java | 91 ++- .../sdc/common/api/ArtifactTypeEnumTest.java | 47 +- .../src/main/resources/configuration.yaml | 12 - .../src/test/resources/configuration.yaml | 20 - .../config/test-apis-ci/configuration.yaml | 266 ------ 65 files changed, 2594 insertions(+), 4149 deletions(-) create mode 100644 catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml create mode 100644 catalog-ui/src/app/ng2/services/artifact-config.service.spec.ts create mode 100644 catalog-ui/src/app/ng2/services/artifact-config.service.ts create mode 100644 common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfigManager.java create mode 100644 common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfiguration.java create mode 100644 common-app-api/src/main/java/org/openecomp/sdc/be/config/ComponentType.java diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb index f861d0ccc2..e4c4cbd8aa 100644 --- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb +++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb @@ -91,35 +91,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['<%= @DC_NAME %>','<%= @rep_factor %>']} - { name: sdcrepository, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['<%= @DC_NAME %>','<%= @rep_factor %>']} - - - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PLAN - - CONTROLLER_BLUEPRINT_ARCHIVE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -266,325 +237,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -#PLAN - PLAN: - acceptedTypes: - - xml - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: - acceptedTypes: - - zip - - tgz - - csar - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - - PNF - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PM_DICTIONARY: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - YANG_MODULE: - acceptedTypes: - - yang - validForResourceTypes: - - VF - - PNF - ANSIBLE_PLAYBOOK: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - ONBOARDED_PACKAGE: - acceptedTypes: - - csar - - zip - validForResourceTypes: - - VF - - PNF - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - validForResourceTypes: - - VF - - PNF - -#PLAN - PLAN: - acceptedTypes: - - xml - validForResourceTypes: - - VF - - VFC - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -#PLAN - PLAN: - acceptedTypes: - - xml - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - - PNF - unLoggedUrls: - /sdc2/rest/healthCheck diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java index 4ad90b884c..e21594db46 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFix.java @@ -358,7 +358,7 @@ public class ArtifactUuidFix { List vfModules = null; if(isCheckVFModules){ Optional optionalVfModuleArtifact = deploymentArtifacts.values().stream() - .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())).findAny(); + .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())).findAny(); if(!optionalVfModuleArtifact.isPresent()) return true; @@ -436,7 +436,7 @@ public class ArtifactUuidFix { resourceName); return true; } - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType()); + ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifactDefinition.getArtifactType()); if (artifactType != ArtifactTypeEnum.HEAT_ENV) { if (!artifactId.equals(artifactDefinition.getUniqueId())) { log.info( @@ -520,7 +520,7 @@ public class ArtifactUuidFix { servicename); return true; } - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType()); + ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifactDefinition.getArtifactType()); if (artifactType != ArtifactTypeEnum.HEAT_ENV) { if (!artifactId.equals(artifactDefinition.getUniqueId())) { log.info( @@ -856,7 +856,7 @@ public class ArtifactUuidFix { } Optional optionalVfModuleArtifact = artifactsMap.values().stream() - .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())).findAny(); + .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())).findAny(); ArtifactDefinition vfModuleArtifact; if(!optionalVfModuleArtifact.isPresent()){ vfModuleArtifact = createVfModuleArtifact(instance, service); @@ -925,7 +925,7 @@ public class ArtifactUuidFix { group.getName(), artifactId, artifactlabel); if (!artifactlabel.isEmpty() && artifactsMap.containsKey(artifactlabel)) { ArtifactDefinition artifact = artifactsMap.get(artifactlabel); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); + ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifact.getArtifactType()); String correctArtifactId = artifact.getUniqueId(); String correctArtifactUUID = artifact.getArtifactUUID(); if (artifactType != ArtifactTypeEnum.HEAT_ENV) { @@ -1018,7 +1018,7 @@ public class ArtifactUuidFix { String correctArtifactUUID = artifact.getArtifactUUID(); boolean isAddToGroup = true; if (groupArtifacts.size() == 1) { - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); + ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT_ARTIFACT) { isAddToGroup = false; artifact.setArtifactType(ArtifactTypeEnum.OTHER.getType()); diff --git a/asdctool/src/main/resources/config/configuration.yaml b/asdctool/src/main/resources/config/configuration.yaml index 5a88cf040a..78869a7111 100644 --- a/asdctool/src/main/resources/config/configuration.yaml +++ b/asdctool/src/main/resources/config/configuration.yaml @@ -107,31 +107,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-AIO-Ubuntu1', '1']} - { name: sdcrepository, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-AIO-Ubuntu1', '1']} -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - CONTROLLER_BLUEPRINT_ARCHIVE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -294,297 +269,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: - acceptedTypes: - - zip - - tgz - - csar - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - - PNF - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PM_DICTIONARY: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - YANG_MODULE: - acceptedTypes: - - yang - validForResourceTypes: - - VF - - PNF - ANSIBLE_PLAYBOOK: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - ONBOARDED_PACKAGE: - acceptedTypes: - - csar - validForResourceTypes: - - VF - - PNF - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - validForResourceTypes: - - VF - - PNF - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - unLoggedUrls: - /sdc2/rest/healthCheck diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java index 8d599e587a..4e17123bd7 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/ArtifactUuidFixTest.java @@ -174,7 +174,7 @@ public class ArtifactUuidFixTest { Map deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); - artifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType()); artifactDefinition.setEsId("esID"); deploymentArtifacts.put("1",artifactDefinition); List groupInstances = new ArrayList<>(); diff --git a/catalog-be/.gitignore b/catalog-be/.gitignore index 55771d9c92..9ef05f37d7 100644 --- a/catalog-be/.gitignore +++ b/catalog-be/.gitignore @@ -1 +1 @@ -/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/Artifact-Generator.properties +/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default/Artifact-Generator.properties \ No newline at end of file diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml index 27d5d6d861..637dcc4004 100644 --- a/catalog-be/pom.xml +++ b/catalog-be/pom.xml @@ -570,6 +570,20 @@ test + + org.hamcrest + hamcrest + ${hamcrest.version} + test + + + + org.hamcrest + hamcrest-library + ${hamcrest.version} + test + + junit junit @@ -636,13 +650,6 @@ test - - org.hamcrest - java-hamcrest - ${java-hamcrest.version} - test - - org.codehaus.groovy groovy diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb index ac664894a2..8db48dc503 100644 --- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb +++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb @@ -106,32 +106,6 @@ cassandraConfig: - { name: sdcrepository, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['<%= @REP_STRING %>']} -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PLAN - - CONTROLLER_BLUEPRINT_ARCHIVE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -148,6 +122,534 @@ resourceTypes: &allResourceTypes - Abstract - CVFC +artifacts: + - type: CONTROLLER_BLUEPRINT_ARCHIVE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - zip + - type: YANG_XML + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: UCPE_LAYER_2_CONFIGURATION + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #AAI Artifacts + - type: AAI_SERVICE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_INSTANCE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #Plan + - type: PLAN + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - xml + - type: WORKFLOW + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - xml + - type: HEAT + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_VOL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NET + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NESTED + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - zip + - tgz + - csar + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VF_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VENDOR_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: LIFECYCLE_OPERATIONS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - yaml + - yml + - type: VES_EVENTS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - yaml + - yml + - type: PERFORMANCE_COUNTER + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - csv + - type: APPC_CONFIG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - type: DCAE_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - yml + - yaml + - type: DCAE_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - json + - type: DCAE_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - emf + - type: DCAE_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: DCAE_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: AAI_VF_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: OTHER + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + acceptedTypes: + - type: SNMP_POLL + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SNMP_TRAP + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PM_DICTIONARY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: YANG_MODULE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yang + - type: ANSIBLE_PLAYBOOK + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: ONBOARDED_PACKAGE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - csar + - zip + - type: HEAT_ENV + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - env + - type: VF_MODULES_METADATA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - yml + - yaml + - type: DCAE_INVENTORY_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - emf + - type: DCAE_INVENTORY_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_BLUEPRINT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: CHEF + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PUPPET + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SHELL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: YANG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: BPEL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: DG_XML + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: MURANO_PKG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PNF_SW_INFORMATION + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - PNF + acceptedTypes: + - yaml + - yml + - type: GUIDE + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + - CVFC + - PNF + acceptedTypes: + - yaml + - yml deploymentResourceArtifacts: @@ -280,345 +782,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -#PLAN - PLAN: - acceptedTypes: - - xml - WORKFLOW: - acceptedTypes: - - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: - acceptedTypes: - - zip - - tgz - - csar - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VFC - - CP - - VL - - VF - - CR - - VFCMT - - Abstract - - CVFC - - PNF - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PM_DICTIONARY: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - YANG_MODULE: - acceptedTypes: - - yang - validForResourceTypes: - - VF - - PNF - ANSIBLE_PLAYBOOK: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - PNF - ONBOARDED_PACKAGE: - acceptedTypes: - - csar - - zip - validForResourceTypes: - - VF - - PNF - CONTROLLER_BLUEPRINT_ARCHIVE: - acceptedTypes: - - zip - validForResourceTypes: - - VF - - PNF - -#PLAN - PLAN: - acceptedTypes: - - xml - validForResourceTypes: - - VF - - VFC - WORKFLOW: - acceptedTypes: - validForResourceTypes: - - VFC - - CP - - VL - - VF - - CR - - VFCMT - - Abstract - - CVFC - - PNF - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -#PLAN - PLAN: - acceptedTypes: - - xml - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - CR - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - - PNF - unLoggedUrls: - /sdc2/rest/monitoring - /sdc2/rest/healthCheck diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java index 0192516bf0..dadd12f673 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java @@ -736,7 +736,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { artifactUid = newArtifact.getUniqueId(); artifactUUID = newArtifact.getArtifactUUID(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(newArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic @@ -771,7 +771,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { private String checkAndGetHeatEnvId(ArtifactDefinition createdArtifact) { String artifactEnvUid = ""; - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(createdArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(createdArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { artifactEnvUid = createdArtifact.getUniqueId() + ArtifactsBusinessLogic.HEAT_ENV_SUFFIX; @@ -1245,7 +1245,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { if (!artifactsToDelete.isEmpty()) { for (ArtifactDefinition artifact : artifactsToDelete) { String artifactType = artifact.getArtifactType(); - ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.findType(artifactType); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); if (artifactTypeEnum != ArtifactTypeEnum.HEAT_ENV) { Either, ResponseFormat> handleDelete = artifactsBusinessLogic .handleDelete(resourceId, artifact.getUniqueId(), user, AuditingActionEnum.ARTIFACT_DELETE, @@ -1460,7 +1460,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { ArtifactDefinition newArtifact = newArtifactEither.left().value(); artifactUid = newArtifact.getUniqueId(); artifactUUID = newArtifact.getArtifactUUID(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(newArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic @@ -1619,7 +1619,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { ArtifactDefinition createdArtifact = createArtifactEither.left().value(); arifactsUids.add(createdArtifact.getUniqueId()); arifactsUuids.add(createdArtifact.getArtifactUUID()); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(createdArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(createdArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java index f8f6726db8..98a8550b7a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java @@ -20,11 +20,12 @@ package org.openecomp.sdc.be.components.distribution.engine; +import lombok.Getter; +import lombok.Setter; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; import java.util.ArrayList; import java.util.Collection; @@ -32,10 +33,12 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +@Getter +@Setter public class ArtifactInfoImpl implements IArtifactInfo { private String artifactName; - private ArtifactTypeEnum artifactType; + private String artifactType; private String artifactURL; private String artifactChecksum; private String artifactDescription; @@ -50,7 +53,7 @@ public class ArtifactInfoImpl implements IArtifactInfo { private ArtifactInfoImpl(ArtifactDefinition artifactDef, String generatedFromUUID, List relatedArtifacts) { artifactName = artifactDef.getArtifactName(); - artifactType = ArtifactTypeEnum.findType(artifactDef.getArtifactType()); + artifactType = artifactDef.getArtifactType(); artifactChecksum = artifactDef.getArtifactChecksum(); artifactDescription = artifactDef.getDescription(); artifactTimeout = artifactDef.getTimeout(); @@ -108,90 +111,10 @@ public class ArtifactInfoImpl implements IArtifactInfo { return requiredArtifacts; } - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public ArtifactTypeEnum getArtifactType() { - return artifactType; - } - - public void setArtifactType(ArtifactTypeEnum artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactURL() { - return artifactURL; - } - - public void setArtifactURL(String artifactURL) { - this.artifactURL = artifactURL; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public Integer getArtifactTimeout() { - return artifactTimeout; - } - - public void setArtifactTimeout(Integer artifactTimeout) { - this.artifactTimeout = artifactTimeout; - } - - public List getRelatedArtifacts() { - return relatedArtifacts; - } - - public void setRelatedArtifacts(List relatedArtifacts) { - this.relatedArtifacts = relatedArtifacts; - } - @Override public String toString() { return "ArtifactInfoImpl [artifactName=" + artifactName + ", artifactType=" + artifactType + ", artifactURL=" + artifactURL + ", artifactChecksum=" + artifactChecksum + ", artifactDescription=" + artifactDescription + ", artifactTimeout=" + artifactTimeout + ", artifactUUID=" + artifactUUID + ", artifactVersion=" + artifactVersion + ", generatedFromUUID=" + generatedFromUUID + ", relatedArtifacts=" + relatedArtifacts + "]"; } - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getGeneratedFromUUID() { - return generatedFromUUID; - } - - public void setGeneratedFromUUID(String generatedFromUUID) { - this.generatedFromUUID = generatedFromUUID; - } - } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java index 4a917710a9..b4919dfbfe 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java @@ -20,8 +20,6 @@ package org.openecomp.sdc.be.components.distribution.engine; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; - public interface IArtifactInfo { /** Artifact File name */ @@ -32,7 +30,7 @@ public interface IArtifactInfo { * Following are valid values : HEAT , DG_XML.
* List of values will be extended in post-1510 releases. */ - ArtifactTypeEnum getArtifactType(); + String getArtifactType(); /** * Relative artifact's URL. Should be used in REST GET API to download the artifact's payload.
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 103edd6497..b41d076e2a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -22,13 +22,38 @@ package org.openecomp.sdc.be.components.impl; +import static org.openecomp.sdc.be.dao.api.ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE; + import com.google.common.annotations.VisibleForTesting; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import fj.data.Either; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; +import javax.xml.XMLConstants; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -43,7 +68,9 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum; import org.openecomp.sdc.be.components.utils.InterfaceOperationUtils; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; +import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -61,7 +88,6 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.info.ArtifactTemplateInfo; import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactType; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentParametersView; @@ -121,31 +147,6 @@ import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import org.yaml.snakeyaml.Yaml; -import javax.servlet.http.HttpServletRequest; -import javax.xml.XMLConstants; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import static org.openecomp.sdc.be.dao.api.ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE; - @org.springframework.stereotype.Component("artifactBusinessLogic") public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final String RESOURCE_INSTANCE = "resource instance"; @@ -167,19 +168,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(ArtifactsBusinessLogic.class.getName()); private static final String FAILED_UPDATE_GROUPS = "Failed to update groups of the component {}. "; - private static final String FAILED_UPDATE_ARTIFACT = "Failed to delete or update the artifact {}. Parent uniqueId is {}"; private static final String FAILED_SAVE_ARTIFACT = "Failed to save the artifact."; public static final String ARTIFACT_ACTION_LOCK = "Artifact action - lock "; - private static final String UPDATE_ARTIFACT_LOCK = "Update Artifact - lock "; - private static final String FAILED_DOWNLOAD_ARTIFACT = "Download artifact {} failed"; public static final String FAILED_UPLOAD_ARTIFACT_TO_COMPONENT = "Failed to upload artifact to component with type {} and uuid {}. Status is {}. "; - private static final String FAILED_UPLOAD_ARTIFACT_TO_INSTANCE = "Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. "; private static final String FAILED_FETCH_COMPONENT = "Could not fetch component with type {} and uuid {}. Status is {}. "; private static final String NULL_PARAMETER = "One of the function parameteres is null"; public static final String COMPONENT_INSTANCE_NOT_FOUND = "Component instance {} was not found for component {}"; private static final String ROLLBACK = "all changes rollback"; private static final String COMMIT = "all changes committed"; - private static final String ARTIFACT_SAVED = "Artifact saved into ES - {}"; private static final String UPDATE_ARTIFACT = "Update Artifact"; private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -479,9 +475,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { String operationName, AuditingActionEnum auditingAction, User user, Component parent, boolean needUpdateGroup) { Either result; - ArtifactTypeEnum artifactType = validateAndReturnArtifactType(artifactInfo); - if (componentType == ComponentTypeEnum.RESOURCE_INSTANCE - && (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_VOL || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_ENV)) { + validateArtifactType(artifactInfo); + final String artifactType = artifactInfo.getArtifactType(); + if (componentType == ComponentTypeEnum.RESOURCE_INSTANCE && + (ArtifactTypeEnum.HEAT.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_VOL.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_NET.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_ENV.getType().equals(artifactType))) { result = handleUpdateHeatEnvAndHeatMeta(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation); if (needUpdateGroup) { ActionStatus error = updateGroupInstance(artifactInfo, result.left().value(), parent, componentId); @@ -490,7 +490,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } } - else if (componentType == ComponentTypeEnum.RESOURCE && artifactType == ArtifactTypeEnum.HEAT_ENV) { + else if (componentType == ComponentTypeEnum.RESOURCE && ArtifactTypeEnum.HEAT_ENV.getType().equals(artifactType)) { result = handleUpdateHeatWithHeatEnvParams(componentId, artifactInfo, auditingAction, componentType, parent, originData, origMd5, operation, needUpdateGroup); } else { @@ -507,16 +507,70 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return result; } - private ArtifactTypeEnum validateAndReturnArtifactType(ArtifactDefinition artifactInfo) { - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { + private void validateArtifactType(final ArtifactDefinition artifactInfo) { + if (!isArtifactSupported(artifactInfo.getArtifactType())) { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); } - return artifactType; } - public ActionStatus updateGroupForHeatEnv(ArtifactDefinition artifactInfo, ArtifactDefinition artAfterUpdate, Component parent) { - return ActionStatus.OK; + private void validateArtifactType(final ArtifactDefinition artifactInfo, + final ComponentTypeEnum componentType) { + final ArtifactConfiguration artifactConfiguration = + loadArtifactTypeConfig(artifactInfo.getArtifactType()).orElse(null); + if (artifactConfiguration == null) { + BeEcompErrorManager.getInstance() + .logBeMissingArtifactInformationError("Artifact Update / Upload", "artifactLabel"); + log.debug("Missing artifact type for artifact {}", artifactInfo.getArtifactName()); + final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.MISSING_ARTIFACT_TYPE); + throw new ByResponseFormatComponentException(responseFormat); + } + + final ArtifactGroupTypeEnum artifactGroupType = artifactInfo.getArtifactGroupType(); + try { + validateArtifactType(componentType, artifactGroupType, artifactConfiguration); + } catch (final ComponentException e) { + log.debug("Artifact is invalid", e); + BeEcompErrorManager.getInstance() + .logBeInvalidTypeError("Artifact Upload / Delete / Update - Not supported artifact type", artifactInfo + .getArtifactType(), "Artifact " + artifactInfo.getArtifactName()); + log.debug("Not supported artifact type = {}", artifactInfo.getArtifactType()); + final ResponseFormat responseFormat = componentsUtils + .getResponseFormat(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo + .getArtifactType()); + throw new ByResponseFormatComponentException(responseFormat); + } + } + + private void validateArtifactType(final ComponentTypeEnum componentType, final ArtifactGroupTypeEnum groupType, + final ArtifactConfiguration artifactConfiguration) { + final boolean supportComponentType = + CollectionUtils.isNotEmpty(artifactConfiguration.getComponentTypes()) && + artifactConfiguration.getComponentTypes().stream() + .anyMatch(componentType1 -> componentType1.getValue().equalsIgnoreCase(componentType.getValue())); + if (!supportComponentType) { + log.debug("Artifact Type '{}' not supported for Component Type '{}'", + artifactConfiguration.getType(), componentType.getValue()); + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, + artifactConfiguration.getType()); + } + + final boolean supportResourceType = artifactConfiguration.hasSupport(groupType); + if (!supportResourceType) { + log.debug("Artifact Type '{}' not supported for Component Type '{}' and Category '{}'", + artifactConfiguration.getType(), componentType.getValue(), groupType.getType()); + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, + artifactConfiguration.getType()); + } + } + + private boolean isArtifactSupported(final String artifactType) { + final Configuration configuration = ConfigurationManager.getConfigurationManager().getConfiguration(); + final List artifactConfigurationList = configuration.getArtifacts(); + if (CollectionUtils.isEmpty(artifactConfigurationList)) { + return false; + } + return artifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equalsIgnoreCase(artifactType)); } @VisibleForTesting @@ -706,7 +760,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // step 1 // detect auditing type Map resMap = null; -// Either, ResponseFormat> resultOp = null; new Wrapper<>(); // step 2 @@ -745,7 +798,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { throw new ByActionStatusComponentException(ActionStatus.MISSING_INFORMATION); } if (groupType == ArtifactGroupTypeEnum.DEPLOYMENT) { - List list = getDeploymentArtifacts(component, componentType.getNodeType(), componentId); + List list = getDeploymentArtifacts(component, componentId); if (list != null && !list.isEmpty()) { resMap = list.stream().collect(Collectors.toMap(ArtifactDataDefinition::getArtifactLabel, Function.identity())); } @@ -1011,14 +1064,31 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private Either validateInput(String componentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, String artifactId, User user, String interfaceName, String operationName, - ComponentTypeEnum componentType, Component parentComponent) { + private Either validateInput(final String componentId, + final ArtifactDefinition artifactInfo, + final ArtifactOperationInfo operation, + final String artifactId, final User user, + String interfaceName, + String operationName, + final ComponentTypeEnum componentType, + final Component parentComponent) { + + final ArtifactDefinition existingArtifactInfo = + findArtifact(parentComponent, componentType, componentId, operation, artifactId); + final Component component; + if (parentComponent.getUniqueId().equals(componentId)) { + component = parentComponent; + } else { + final ComponentInstance componentInstance = findComponentInstance(componentId, parentComponent); + component = findComponent(componentInstance.getComponentUid()); + component.setComponentType(componentType); + } - ArtifactDefinition currentArtifactInfo = findArtifactOnParentComponent(parentComponent, componentType, componentId, operation, artifactId); - ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, currentArtifactInfo); - validateInformationalArtifact(artifactInfo, parentComponent); - Either validateAndSetArtifactname = validateAndSetArtifactName( - artifactInfo); + ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, existingArtifactInfo); + if (isInformationalArtifact(artifactInfo)) { + validateInformationalArtifact(artifactInfo, component); + } + Either validateAndSetArtifactname = validateAndSetArtifactName(artifactInfo); if (validateAndSetArtifactname.isRight()) { return Either.right(validateAndSetArtifactname.right().value()); } @@ -1036,37 +1106,43 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // This is a patch to block possibility of updating service api fields // through other artifacts flow - ArtifactGroupTypeEnum artifactGroupType = operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL; - if (!ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - checkAndSetUnUpdatableFields(user, artifactInfo, currentArtifactInfo, artifactGroupType); - } - else { + final ArtifactGroupTypeEnum artifactGroupType = + operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL; + final boolean isCreateOrLink = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()); + if (!isCreateOrLink) { + checkAndSetUnUpdatableFields(user, artifactInfo, existingArtifactInfo, artifactGroupType); + } else { checkCreateFields(user, artifactInfo, artifactGroupType); } composeArtifactId(componentId, artifactId, artifactInfo, interfaceName, operationName); - if (currentArtifactInfo != null) { - artifactInfo.setMandatory(currentArtifactInfo.getMandatory()); + if (existingArtifactInfo != null) { + artifactInfo.setMandatory(existingArtifactInfo.getMandatory()); + if (!isCreateOrLink) { + validateArtifactTypeNotChanged(artifactInfo, existingArtifactInfo); + } } // artifactGroupType is not allowed to be updated - if (!ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - Either validateGroupType = validateOrSetArtifactGroupType(artifactInfo, currentArtifactInfo); + if (!isCreateOrLink) { + Either validateGroupType = validateOrSetArtifactGroupType(artifactInfo, existingArtifactInfo); if (validateGroupType.isRight()) { return Either.right(validateGroupType.right().value()); } } - // TODO TEMP !!! - NodeTypeEnum parentType = convertParentType(componentType); - // TODO TEMP !!! - boolean isCreate = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()); - - if (isDeploymentArtifact(artifactInfo)) { - validateDeploymentArtifact(parentComponent, componentId, isCreate, artifactInfo, currentArtifactInfo, parentType); + setArtifactTimeout(artifactInfo, existingArtifactInfo); + if (isHeatArtifact(artifactInfo)) { + validateHeatArtifact(parentComponent, componentId, artifactInfo); } - else { - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + if (isDeploymentArtifact(artifactInfo)) { + if (componentType != ComponentTypeEnum.RESOURCE_INSTANCE) { + final String artifactName = artifactInfo.getArtifactName(); + if (isCreateOrLink || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) { + validateSingleDeploymentArtifactName(artifactName, parentComponent); + } + } + validateDeploymentArtifact(artifactInfo, component); } Either descriptionResult = validateAndCleanDescription(artifactInfo); @@ -1074,11 +1150,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(descriptionResult.right().value()); } - if (currentArtifactInfo != null && currentArtifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.SERVICE_API) { - Either validateServiceApiType = validateArtifactType(user.getUserId(), artifactInfo, parentType); - if (validateServiceApiType.isRight()) { - return Either.right(validateServiceApiType.right().value()); - } + validateArtifactType(artifactInfo, component.getComponentType()); + artifactInfo.setArtifactType(artifactInfo.getArtifactType().toUpperCase()); + if (existingArtifactInfo != null && existingArtifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.SERVICE_API) { // Change of type is not allowed and should be ignored artifactInfo.setArtifactType(ARTIFACT_TYPE_OTHER); @@ -1088,23 +1162,18 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(validateUrl.right().value()); } - Either validateUpdate = validateFirstUpdateHasPayload(artifactInfo, currentArtifactInfo); + Either validateUpdate = validateFirstUpdateHasPayload(artifactInfo, existingArtifactInfo); if (validateUpdate.isRight()) { log.debug("serviceApi first update cnnot be without payload."); return Either.right(validateUpdate.right().value()); } - } - else { - Either validateArtifactType = validateArtifactType(user.getUserId(), artifactInfo, parentType); - if (validateArtifactType.isRight()) { - return Either.right(validateArtifactType.right().value()); - } + } else { if (artifactInfo.getApiUrl() != null) { artifactInfo.setApiUrl(null); log.error("Artifact URL cannot be set through this API - ignoring"); } - if (artifactInfo.getServiceApi() != null && artifactInfo.getServiceApi()) { + if (Boolean.TRUE.equals(artifactInfo.getServiceApi())) { artifactInfo.setServiceApi(false); log.error("Artifact service API flag cannot be changed - ignoring"); } @@ -1113,6 +1182,16 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.left(artifactInfo); } + private Component findComponent(final String componentId) { + Either component = toscaOperationFacade.getToscaFullElement(componentId); + if (component.isRight()) { + log.debug("Component '{}' not found ", componentId); + throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NOT_FOUND, componentId); + } + + return component.left().value(); + } + private void ignoreUnupdateableFieldsInUpdate(ArtifactOperationInfo operation, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifactInfo) { if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) { artifactInfo.setArtifactType(currentArtifactInfo.getArtifactType()); @@ -1121,8 +1200,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private ArtifactDefinition findArtifactOnParentComponent(Component parentComponent, ComponentTypeEnum componentType, String parentId, ArtifactOperationInfo operation, String artifactId) { - + private ArtifactDefinition findArtifact(final Component parentComponent, final ComponentTypeEnum componentType, + final String parentId, final ArtifactOperationInfo operation, + final String artifactId) { ArtifactDefinition foundArtifact = null; if (StringUtils.isNotEmpty(artifactId)) { foundArtifact = findArtifact(parentComponent, componentType, parentId, artifactId); @@ -1132,7 +1212,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_EXIST, foundArtifact.getArtifactLabel()); } if (foundArtifact == null && !ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - log.debug("The artifact {} was not found on parent {}. ", artifactId, parentId); + log.debug("The artifact {} was not found on parent component or instance {}. ", artifactId, parentId); throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_NOT_FOUND, ""); } return foundArtifact; @@ -1150,31 +1230,26 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return foundArtifact; } - private void validateInformationalArtifact(ArtifactDefinition artifactInfo, Component parentComponent) { - ComponentTypeEnum parentComponentType = parentComponent.getComponentType(); - ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); + private void validateInformationalArtifact(final ArtifactDefinition artifactInfo, final Component component) { + final ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); + if (groupType != ArtifactGroupTypeEnum.INFORMATIONAL) { + return; } - else if (parentComponentType == ComponentTypeEnum.RESOURCE && groupType == ArtifactGroupTypeEnum.INFORMATIONAL) { - String artifactTypeName = artifactType.getType(); - ResourceTypeEnum parentResourceType = ((Resource) parentComponent).getResourceType(); - Map resourceInformationalArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInformationalArtifacts(); - Set validArtifactTypes = resourceInformationalArtifacts.keySet(); - if (!validArtifactTypes.contains(artifactTypeName)) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactTypeName); - } - else { - List validResourceType = resourceInformationalArtifacts.get(artifactTypeName) - .getValidForResourceTypes(); - if (!validResourceType.contains(parentResourceType.name())) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactTypeName); - } - } + final ComponentTypeEnum parentComponentType = component.getComponentType(); + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactConfiguration artifactConfiguration = loadArtifactTypeConfig(artifactType).orElse(null); + if (artifactConfiguration == null) { + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactType); } + validateArtifactType(parentComponentType, artifactInfo.getArtifactGroupType(), artifactConfiguration); + + if (component.getComponentType() == ComponentTypeEnum.RESOURCE || + component.getComponentType() == ComponentTypeEnum.RESOURCE_INSTANCE) { + + final ResourceTypeEnum resourceType = ((Resource) component).getResourceType(); + validateResourceType(resourceType, artifactInfo, artifactConfiguration.getResourceTypes()); + } + validateArtifactExtension(artifactConfiguration, artifactInfo); } private NodeTypeEnum convertParentType(ComponentTypeEnum componentType) { @@ -1750,117 +1825,102 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return foundInstance; } - private void validateDeploymentArtifact(Component parentComponent, String parentId, boolean isCreate, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact, NodeTypeEnum parentType) { - - ArtifactTypeEnum artifactType = getValidArtifactType(artifactInfo); - Map resourceDeploymentArtifacts = fillDeploymentArtifactTypeConf(parentType); - validateDeploymentArtifactTypeIsLegalForParent(artifactInfo, artifactType, resourceDeploymentArtifacts); - if (!isCreate) { - validateArtifactTypeNotChanged(artifactInfo, currentArtifact); + private void validateDeploymentArtifact(final ArtifactDefinition artifactInfo, final Component component) { + final ComponentTypeEnum componentType = component.getComponentType(); + if (componentType != ComponentTypeEnum.RESOURCE && + componentType != ComponentTypeEnum.SERVICE && + componentType != ComponentTypeEnum.RESOURCE_INSTANCE) { + log.debug("Invalid component type '{}' for artifact. " + + "Expected Resource, Component or Resource Instance", componentType.getValue()); + throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, + componentType.getValue(), "Service, Resource or ResourceInstance", componentType.getValue()); } - if (parentType == NodeTypeEnum.Resource) { - Resource resource = (Resource) parentComponent; - ResourceTypeEnum resourceType = resource.getResourceType(); - ArtifactTypeConfig config = resourceDeploymentArtifacts.get(artifactType.getType()); - if (config == null) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); - } - List myList = config.getValidForResourceTypes(); - validateResourceType(resourceType, artifactInfo, myList); + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactConfiguration artifactConfiguration = loadArtifactTypeConfig(artifactType).orElse(null); + if (artifactConfiguration == null) { + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactType); } + validateArtifactType(componentType, artifactInfo.getArtifactGroupType(), artifactConfiguration); + if (componentType == ComponentTypeEnum.RESOURCE || componentType == ComponentTypeEnum.RESOURCE_INSTANCE) { + final Resource resource = (Resource) component; + final ResourceTypeEnum resourceType = resource.getResourceType(); - validateFileExtension(() -> getDeploymentArtifactTypeConfig(parentType, artifactType), artifactInfo, parentType, artifactType); + validateResourceType(resourceType, artifactInfo, artifactConfiguration.getResourceTypes()); + } - if (NodeTypeEnum.ResourceInstance != parentType) { - String artifactName = artifactInfo.getArtifactName(); - if (isCreate || !artifactName.equalsIgnoreCase(currentArtifact.getArtifactName())) { - validateSingleDeploymentArtifactName(artifactName, parentComponent, parentType); - } + validateArtifactExtension(artifactConfiguration, artifactInfo); + } + + private void validateHeatArtifact(final Component parentComponent, final String componentId, + final ArtifactDefinition artifactDefinition) { + final String artifactType = artifactDefinition.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + return; } - switch (artifactType) { + switch (artifactTypeEnum) { case HEAT: case HEAT_VOL: case HEAT_NET: - validateHeatTimeoutValue(isCreate, artifactInfo, currentArtifact); + validateHeatTimeoutValue(artifactDefinition); break; case HEAT_ENV: - validateHeatEnvDeploymentArtifact(parentComponent, parentId, artifactInfo, parentType); - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + validateHeatEnvDeploymentArtifact(parentComponent, componentId, artifactDefinition); break; - case DCAE_INVENTORY_TOSCA: - case DCAE_INVENTORY_JSON: - case DCAE_INVENTORY_POLICY: - // Validation is done in handle payload. - case DCAE_INVENTORY_DOC: - case DCAE_INVENTORY_BLUEPRINT: - case DCAE_INVENTORY_EVENT: - // No specific validation default: - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); break; } } - @VisibleForTesting - void validateDeploymentArtifactTypeIsLegalForParent(ArtifactDefinition artifactInfo, ArtifactTypeEnum artifactType, Map resourceDeploymentArtifacts) { - if ((resourceDeploymentArtifacts == null) || !resourceDeploymentArtifacts.containsKey(artifactType.name())) { - log.debug("Artifact Type: {} Not found !", artifactInfo.getArtifactType()); - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); - } - } + private void setArtifactTimeout(final ArtifactDefinition newArtifactInfo, + final ArtifactDefinition existingArtifactInfo) { - private Map fillDeploymentArtifactTypeConf(NodeTypeEnum parentType) { - Map resourceDeploymentArtifacts; - if (parentType == NodeTypeEnum.Resource) { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts(); - } - else if (parentType == NodeTypeEnum.ResourceInstance) { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts(); + final String artifactType = newArtifactInfo.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + newArtifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + return; } - else { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts(); + switch (artifactTypeEnum) { + case HEAT: + case HEAT_VOL: + case HEAT_NET: + if (newArtifactInfo.getTimeout() == null) { + if (existingArtifactInfo == null) { + newArtifactInfo.setTimeout(NodeTemplateOperation.getDefaultHeatTimeout()); + } else { + newArtifactInfo.setTimeout(existingArtifactInfo.getTimeout()); + } + } + break; + default: + newArtifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + break; } - return resourceDeploymentArtifacts; } - public ArtifactTypeEnum getValidArtifactType(ArtifactDefinition artifactInfo) { - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { + @VisibleForTesting + void validateDeploymentArtifactTypeIsLegalForParent(ArtifactDefinition artifactInfo, ArtifactTypeEnum artifactType, Map resourceDeploymentArtifacts) { + if ((resourceDeploymentArtifacts == null) || !resourceDeploymentArtifacts.containsKey(artifactType.name())) { log.debug("Artifact Type: {} Not found !", artifactInfo.getArtifactType()); throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); } - return artifactType; } - private ArtifactTypeConfig getDeploymentArtifactTypeConfig(NodeTypeEnum parentType, ArtifactTypeEnum artifactType) { - ArtifactTypeConfig retConfig = null; - String fileType = artifactType.getType(); - if (parentType == NodeTypeEnum.Resource) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts() - .get(fileType); - } - else if (parentType == NodeTypeEnum.Service) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts() - .get(fileType); + Optional loadArtifactTypeConfig(final String artifactType) { + if (artifactType == null) { + return Optional.empty(); } - else if (parentType == NodeTypeEnum.ResourceInstance) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts() - .get(fileType); + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + if (CollectionUtils.isEmpty(artifactConfigurationList)) { + return Optional.empty(); } - return retConfig; + + return artifactConfigurationList.stream() + .filter(artifactConfiguration -> artifactConfiguration.getType().equalsIgnoreCase(artifactType)) + .findFirst(); } private Either extractHeatParameters(ArtifactDefinition artifactInfo) { @@ -1884,42 +1944,33 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } @VisibleForTesting - public void validateFileExtension(IDeploymentArtifactTypeConfigGetter deploymentConfigGetter, ArtifactDefinition artifactInfo, NodeTypeEnum parentType, ArtifactTypeEnum artifactType) { - if (parentType != NodeTypeEnum.Resource && parentType != NodeTypeEnum.Service && parentType != NodeTypeEnum.ResourceInstance) { - log.debug("parent type of artifact can be either resource or service"); - throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, artifactType.name(), "Service, Resource or ResourceInstance", parentType.getName()); - } - - String fileType = artifactType.getType(); - ArtifactTypeConfig deploymentAcceptedTypes = deploymentConfigGetter.getDeploymentArtifactConfig(); - if (deploymentAcceptedTypes == null) { - log.debug("invalid artifact type {}", fileType); - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, fileType); - } + void validateArtifactExtension(final ArtifactConfiguration artifactConfiguration, + final ArtifactDefinition artifactDefinition) { + final List acceptedTypes = artifactConfiguration.getAcceptedTypes(); /* * No need to check specific types. In case there are no acceptedTypes in configuration, then any type is accepted. */ + if (CollectionUtils.isEmpty(acceptedTypes)) { + return; + } + final String artifactName = artifactDefinition.getArtifactName(); + final String fileExtension = FilenameUtils.getExtension(artifactName); - List acceptedTypes = deploymentAcceptedTypes.getAcceptedTypes(); - String artifactName = artifactInfo.getArtifactName(); - String fileExtension = GeneralUtility.getFilenameExtension(artifactName); - // Pavel - File extension validation is case-insensitive - Ella, - // 21/02/2016 - if (CollectionUtils.isNotEmpty(acceptedTypes) && !acceptedTypes.contains(fileExtension.toLowerCase())) { - log.debug("File extension \"{}\" is not allowed for {} which is of type:{}", fileExtension, artifactName, fileType); - throw new ByActionStatusComponentException(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION, fileType); + if (fileExtension == null || !acceptedTypes.contains(fileExtension.toLowerCase())) { + final String artifactType = artifactDefinition.getArtifactType(); + log.debug("File extension \"{}\" is not allowed for artifact type \"{}\"", fileExtension, artifactType); + throw new ByActionStatusComponentException(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION, artifactType); } } @VisibleForTesting - void validateHeatEnvDeploymentArtifact(Component parentComponent, String parentId, ArtifactDefinition artifactInfo, NodeTypeEnum parentType) { - - Wrapper heatMDWrapper = new Wrapper<>(); - Wrapper payloadWrapper = new Wrapper<>(); + void validateHeatEnvDeploymentArtifact(final Component parentComponent, final String parentId, + final ArtifactDefinition artifactInfo) { + final Wrapper heatMDWrapper = new Wrapper<>(); + final Wrapper payloadWrapper = new Wrapper<>(); validateYaml(artifactInfo); - validateHeatExist(parentComponent.getUniqueId(), parentId, heatMDWrapper, artifactInfo, - parentType, parentComponent.getComponentType()); + validateHeatExist(parentComponent.getUniqueId(), parentId, heatMDWrapper, artifactInfo, parentComponent.getComponentType()); if (!heatMDWrapper.isEmpty()) { fillArtifactPayload(payloadWrapper, heatMDWrapper.getInnerElement()); @@ -2005,42 +2056,38 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private void validateSingleDeploymentArtifactName(String artifactName, Component parentComponent, NodeTypeEnum parentType) { + private void validateSingleDeploymentArtifactName(final String artifactName, final Component parentComponent) { boolean artifactNameFound = false; - Iterator parentDeploymentArtifactsItr = getDeploymentArtifacts(parentComponent, parentType, null) - .iterator(); + final Iterator parentDeploymentArtifactsItr = + getDeploymentArtifacts(parentComponent, null).iterator(); while (!artifactNameFound && parentDeploymentArtifactsItr.hasNext()) { artifactNameFound = artifactName.equalsIgnoreCase(parentDeploymentArtifactsItr.next().getArtifactName()); } if (artifactNameFound) { + final ComponentTypeEnum componentType = parentComponent.getComponentType(); log.debug("Can't upload artifact: {}, because another artifact with this name already exist.", artifactName); - throw new ByActionStatusComponentException(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, parentType.name(), - parentComponent.getName(), artifactName); + throw new ByActionStatusComponentException(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, + componentType.getValue(), parentComponent.getName(), artifactName); } } - private void validateHeatExist(String componentId, String parentRiId, Wrapper heatArtifactMDWrapper, ArtifactDefinition heatEnvArtifact, NodeTypeEnum parentType, + private void validateHeatExist(String componentId, String parentRiId, Wrapper heatArtifactMDWrapper, ArtifactDefinition heatEnvArtifact, ComponentTypeEnum componentType) { - Either res = artifactToscaOperation.getHeatArtifactByHeatEnvId(parentRiId, heatEnvArtifact, parentType, componentId, componentType); + final Either res = artifactToscaOperation + .getHeatArtifactByHeatEnvId(parentRiId, heatEnvArtifact, componentId, componentType); if (res.isRight()) { throw new ByActionStatusComponentException(ActionStatus.MISSING_HEAT); - } else { - heatArtifactMDWrapper.setInnerElement(res.left().value()); } + + heatArtifactMDWrapper.setInnerElement(res.left().value()); } @VisibleForTesting - void validateHeatTimeoutValue(boolean isCreate, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact) { + void validateHeatTimeoutValue(final ArtifactDefinition artifactInfo) { log.trace("Started HEAT pre-payload validation for artifact {}", artifactInfo.getArtifactLabel()); // timeout > 0 for HEAT artifacts - Integer timeout = artifactInfo.getTimeout(); - if (timeout == null) { - Integer defaultTimeout = isCreate ? NodeTemplateOperation.getDefaultHeatTimeout() : currentArtifact.getTimeout(); - artifactInfo.setTimeout(defaultTimeout); - // HEAT artifact but timeout is invalid - } - else if (timeout < 1) { + if (artifactInfo.getTimeout() == null || artifactInfo.getTimeout() < 1) { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_INVALID_TIMEOUT); } // US649856 - Allow several HEAT files on Resource @@ -2048,12 +2095,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } @VisibleForTesting - void validateResourceType(ResourceTypeEnum resourceType, ArtifactDefinition artifactInfo, List typeList) { - if (typeList == null || !typeList.contains(resourceType.name())) { - String listToString = (typeList != null) ? typeList.toString() : ""; - throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, artifactInfo.getArtifactName(), - listToString, resourceType.getValue()); + void validateResourceType(final ResourceTypeEnum resourceType, final ArtifactDefinition artifactInfo, + final List typeList) { + if (CollectionUtils.isEmpty(typeList) || typeList.contains(resourceType.getValue())) { + return; } + final String listToString = typeList.stream().collect(Collectors.joining(", ")); + throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, + artifactInfo.getArtifactGroupType().getType(), listToString, resourceType.getValue()); } @VisibleForTesting @@ -2082,22 +2131,24 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.left(artifactInfo); } - public List getDeploymentArtifacts(Component parentComponent, NodeTypeEnum parentType, String ciId) { - List deploymentArtifacts = new ArrayList<>(); - if (parentComponent.getDeploymentArtifacts() != null) { - if (NodeTypeEnum.ResourceInstance == parentType && ciId != null) { - Either getRI = getRIFromComponent(parentComponent, ciId, null, null, null); - if (getRI.isRight()) { - return deploymentArtifacts; - } - ComponentInstance ri = getRI.left().value(); - if (ri.getDeploymentArtifacts() != null) { - deploymentArtifacts.addAll(ri.getDeploymentArtifacts().values()); - } + public List getDeploymentArtifacts(final Component component, final String ciId) { + final ComponentTypeEnum componentType = component.getComponentType(); + if (component.getDeploymentArtifacts() == null) { + return Collections.emptyList(); + } + final List deploymentArtifacts = new ArrayList<>(); + if (ComponentTypeEnum.RESOURCE == componentType && ciId != null) { + final Either getRI = + getRIFromComponent(component, ciId, null, null, null); + if (getRI.isRight()) { + return Collections.emptyList(); } - else if (parentComponent.getDeploymentArtifacts() != null) { - deploymentArtifacts.addAll(parentComponent.getDeploymentArtifacts().values()); + final ComponentInstance ri = getRI.left().value(); + if (ri.getDeploymentArtifacts() != null) { + deploymentArtifacts.addAll(ri.getDeploymentArtifacts().values()); } + } else { + deploymentArtifacts.addAll(component.getDeploymentArtifacts().values()); } return deploymentArtifacts; } @@ -2184,90 +2235,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return id; } - private Either validateArtifactType(String userId, ArtifactDefinition artifactInfo, NodeTypeEnum parentType) { - if (artifactInfo.getArtifactType() == null || artifactInfo.getArtifactType().isEmpty()) { - BeEcompErrorManager.getInstance() - .logBeMissingArtifactInformationError("Artifact Update / Upload", "artifactLabel"); - log.debug("Missing artifact type for artifact {}", artifactInfo.getArtifactName()); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_ARTIFACT_TYPE)); - } - - boolean artifactTypeExist = false; - Either, ActionStatus> allArtifactTypes = null; - ArtifactGroupTypeEnum artifactGroupType = artifactInfo.getArtifactGroupType(); - - if ((artifactGroupType != null) && artifactGroupType == ArtifactGroupTypeEnum.DEPLOYMENT) { - allArtifactTypes = getDeploymentArtifactTypes(parentType); - } - else { - - allArtifactTypes = elementOperation.getAllArtifactTypes(); - } - if (allArtifactTypes.isRight()) { - BeEcompErrorManager.getInstance() - .logBeInvalidConfigurationError("Artifact Upload / Update", "artifactTypes", allArtifactTypes - .right() - .value() - .name()); - log.debug("Failed to retrieve list of suported artifact types. error: {}", allArtifactTypes.right() - .value()); - return Either.right(componentsUtils.getResponseFormatByUserId(allArtifactTypes.right().value(), userId)); - } - - for (ArtifactType type : allArtifactTypes.left().value()) { - if (type.getName().equalsIgnoreCase(artifactInfo.getArtifactType())) { - artifactInfo.setArtifactType(artifactInfo.getArtifactType().toUpperCase()); - artifactTypeExist = true; - break; - } - } - - if (!artifactTypeExist) { - BeEcompErrorManager.getInstance() - .logBeInvalidTypeError("Artifact Upload / Delete / Update - Not supported artifact type", artifactInfo - .getArtifactType(), "Artifact " + artifactInfo.getArtifactName()); - log.debug("Not supported artifact type = {}", artifactInfo.getArtifactType()); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo - .getArtifactType())); - } - - return Either.left(ActionStatus.OK); - } - - private Either, ActionStatus> getDeploymentArtifactTypes(NodeTypeEnum parentType) { - - Map deploymentArtifacts ; - List artifactTypes = new ArrayList<>(); - - if (parentType == NodeTypeEnum.Service) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts(); - } - else if (parentType == NodeTypeEnum.ResourceInstance) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts(); - } - else { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts(); - } - if (deploymentArtifacts != null) { - for (String artifactType : deploymentArtifacts.keySet()) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return Either.left(artifactTypes); - } - else { - return Either.right(ActionStatus.GENERAL_ERROR); - } - - } - private Either validateFirstUpdateHasPayload(ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact) { if (currentArtifact.getEsId() == null && (artifactInfo.getPayloadData() == null || artifactInfo.getPayloadData().length == 0)) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_DATA, ARTIFACT_PAYLOAD)); @@ -2922,18 +2889,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return resourceListBySystemName.left().value(); } - /*private Either validateResourceNameAndVersion(String resourceName, String resourceVersion) { - - Either resourceListBySystemName = toscaOperationFacade.getComponentByNameAndVersion(ComponentTypeEnum.RESOURCE, resourceName, resourceVersion, JsonParseFlagEnum.ParseMetadata); - if (resourceListBySystemName.isRight()) { - log.debug("Couldn't fetch any resource with name {} and version {}. ", resourceName, resourceVersion); - return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(resourceListBySystemName - .right() - .value()), resourceName)); - } - return Either.left(resourceListBySystemName.left().value()); - }*/ - public byte[] downloadServiceArtifactByNames(String serviceName, String serviceVersion, String artifactName) { // Validation log.trace("Starting download of service interface artifact, serviceName {}, serviceVersion {}, artifact name {}", serviceName, serviceVersion, artifactName); @@ -3242,6 +3197,29 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return ArtifactGroupTypeEnum.DEPLOYMENT == artifactInfo.getArtifactGroupType(); } + private boolean isInformationalArtifact(final ArtifactDefinition artifactInfo) { + return ArtifactGroupTypeEnum.INFORMATIONAL == artifactInfo.getArtifactGroupType(); + } + + private boolean isHeatArtifact(final ArtifactDefinition artifactInfo) { + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + return false; + } + switch (artifactTypeEnum) { + case HEAT: + case HEAT_VOL: + case HEAT_NET: + case HEAT_ENV: + return true; + default: + return false; + } + } + + public ArtifactDefinition createArtifactPlaceHolderInfo(String resourceId, String logicalName, Map artifactInfoMap, String userUserId, ArtifactGroupTypeEnum groupType, boolean inTransaction) { User user = userBusinessLogic.getUser(userUserId, inTransaction); return createArtifactPlaceHolderInfo(resourceId, logicalName, artifactInfoMap, user, groupType); @@ -3670,7 +3648,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (origMd5 != null) { validateMd5(origMd5, originData, artifactInfo.getPayloadData(), operation); if (ArrayUtils.isNotEmpty(artifactInfo.getPayloadData())) { - validateDeploymentArtifact(parent, componentId, false, artifactInfo, artifactInfo, NodeTypeEnum.ResourceInstance); + validateDeploymentArtifact(artifactInfo, parent); handlePayload(artifactInfo, isArtifactMetadataUpdate(auditingAction)); } else { // duplicate throw new ByActionStatusComponentException(ActionStatus.MISSING_DATA, ARTIFACT_PAYLOAD); @@ -4305,7 +4283,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { Either getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true); if (getComponentRes.isRight()) { StorageOperationStatus status = getComponentRes.right().value(); - log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status); + log.debug(FAILED_FETCH_COMPONENT, componentType, componentUuid, status); errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status))); } @@ -4346,7 +4324,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (errorWrapper.isEmpty()) { NodeTypeEnum parentType = convertParentType(componentType); - List existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), parentType,null); + final List existingDeploymentArtifacts = + getDeploymentArtifacts(toscaComponentEither.left().value(),null); for (ArtifactDefinition artifactDefinition: existingDeploymentArtifacts){ if(artifactInfo.getArtifactName().equalsIgnoreCase(artifactDefinition.getArtifactName())){ existingArtifactInfo = artifactDefinition; @@ -4909,5 +4888,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { this.nodeTemplateOperation = nodeTemplateOperation; } + public List getConfiguration() { + return ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + } + } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java index 711e6648ed..9c092da300 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java @@ -948,16 +948,12 @@ public class ElementBusinessLogic extends BaseBusinessLogic { return elementOperation.getAllPropertyScopes(); } - public Either, ActionStatus> getAllArtifactTypes(String userId) { + public Either, ActionStatus> getAllArtifactTypes(final String userId) { ActionStatus status = validateUserExistsActionStatus(userId); if (ActionStatus.OK != status) { return Either.right(status); } - return elementOperation.getAllArtifactTypes(); - } - - public Either, ActionStatus> getAllDeploymentArtifactTypes() { - return elementOperation.getAllDeploymentArtifactTypes(); + return Either.left(elementOperation.getAllArtifactTypes()); } public Either getDefaultHeatTimeout() { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 45f2434482..74f78b2ce1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -2448,8 +2448,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { .stream() // create each artifact .map(e -> createOrUpdateSingleNonMetaArtifact(resource, csarInfo, e.getPath(), - e.getArtifactName(), e.getArtifactType() - .getType(), + e.getArtifactName(), e.getArtifactType(), e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(), CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(), artifactsBusinessLogic.new ArtifactOperationInfo(false, false, @@ -2555,8 +2554,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private boolean isValidArtifactType(ArtifactDefinition artifact) { boolean result = true; if (artifact.getArtifactType() == null - || ArtifactTypeEnum.findType(artifact.getArtifactType()) == ArtifactTypeEnum.VENDOR_LICENSE - || ArtifactTypeEnum.findType(artifact.getArtifactType()) == ArtifactTypeEnum.VF_LICENSE) { + || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VENDOR_LICENSE + || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VF_LICENSE) { result = false; } return result; @@ -2833,10 +2832,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private void setResourceInstanceRelationsOnComponent(Resource resource, List relations) { if (resource.getComponentInstancesRelations() != null) { - /*Map relationsMapByUid = resource.getComponentInstancesRelations().stream().collect(Collectors.toMap(r -> r.getUid(), r -> r)); - Map updatedRelationsByUid = relations.stream().collect(Collectors.toMap(r -> r.getUid(), r -> r)); - relationsMapByUid.putAll(updatedRelationsByUid); - resource.setComponentInstancesRelations(new ArrayList<>(relationsMapByUid.values()));*/ resource.getComponentInstancesRelations().addAll(relations); } else { resource.setComponentInstancesRelations(relations); @@ -5816,8 +5811,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { .findFirst() .orElse(null); if (foundArtifact != null) { - if (ArtifactTypeEnum.findType(foundArtifact.getArtifactType()) == currNewArtifact - .getArtifactType()) { + if (foundArtifact.getArtifactType().equals(currNewArtifact.getArtifactType())) { if (!foundArtifact.getArtifactChecksum() .equals(currNewArtifact.getArtifactChecksum())) { currNewArtifact.setArtifactUniqueId(foundArtifact.getUniqueId()); @@ -5839,8 +5833,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { currNewArtifact.getArtifactName()); ResponseFormat responseFormat = ResponseFormatManager.getInstance() .getResponseFormat(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, - currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType() - .name(), + currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(), foundArtifact.getArtifactType()); AuditingActionEnum auditingAction = artifactsBusinessLogic .detectAuditingType(artifactsBusinessLogic.new ArtifactOperationInfo(false, false, @@ -5858,14 +5851,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { for (ArtifactDefinition currArtifact : existingArtifactsToHandle) { if (currArtifact.getIsFromCsar()) { artifactsToDelete.add(new NonMetaArtifactInfo(currArtifact.getArtifactName(), null, - ArtifactTypeEnum.findType(currArtifact.getArtifactType()), - currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), - currArtifact.getIsFromCsar())); + currArtifact.getArtifactType(), + currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), + currArtifact.getIsFromCsar())); } else { artifactsToUpdate.add(new NonMetaArtifactInfo(currArtifact.getArtifactName(), null, - ArtifactTypeEnum.findType(currArtifact.getArtifactType()), - currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), - currArtifact.getIsFromCsar())); + currArtifact.getArtifactType(), + currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), + currArtifact.getIsFromCsar())); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java index ba04c00cdb..e946f72851 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java @@ -1909,7 +1909,10 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { private ArtifactDefinition getVfModuleInstArtifactForCompInstance(ComponentInstance currVF, Service service, Wrapper payloadWrapper, Wrapper responseWrapper) { ArtifactDefinition vfModuleAertifact = null; if (MapUtils.isNotEmpty(currVF.getDeploymentArtifacts())) { - Optional optionalVfModuleArtifact = currVF.getDeploymentArtifacts().values().stream().filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())).findAny(); + final Optional optionalVfModuleArtifact = + currVF.getDeploymentArtifacts().values().stream() + .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())) + .findAny(); if (optionalVfModuleArtifact.isPresent()) { vfModuleAertifact = optionalVfModuleArtifact.get(); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java index e4f19355dc..6a74428a90 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java @@ -55,7 +55,7 @@ public class ComponentInstanceArtifactsMerge implements ComponentInstanceMergeIn Map deploymentArtifactsCreatedOnTheInstance = componentInstancesDeploymentArtifacts.entrySet() .stream() .filter(i -> !originalComponentDeploymentArtifacts.containsKey(i.getKey())) - .filter(i -> !ArtifactTypeEnum.VF_MODULES_METADATA.name().equals(i.getValue().getArtifactType())) + .filter(i -> !ArtifactTypeEnum.VF_MODULES_METADATA.getType().equals(i.getValue().getArtifactType())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); dataHolder.setOrigComponentDeploymentArtifactsCreatedOnTheInstance(deploymentArtifactsCreatedOnTheInstance); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java index ccb6960c08..21589e0723 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java @@ -23,27 +23,29 @@ package org.openecomp.sdc.be.info; import com.google.gson.Gson; import com.google.gson.JsonObject; import fj.data.Either; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import lombok.Getter; import lombok.NoArgsConstructor; - import lombok.Setter; +import org.apache.commons.collections.CollectionUtils; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.ArtifactType; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - @Getter @Setter @NoArgsConstructor @@ -281,27 +283,36 @@ public class ArtifactTemplateInfo { return Either.left(true); } - private static Either, ActionStatus> getDeploymentArtifactTypes(NodeTypeEnum parentType) { + private static Either, ActionStatus> getDeploymentArtifactTypes(final NodeTypeEnum parentType) { - Map deploymentArtifacts = null; - List artifactTypes = new ArrayList<>(); + final List deploymentArtifacts; + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); - if (parentType.equals(NodeTypeEnum.Service)) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceDeploymentArtifacts(); + if (parentType == NodeTypeEnum.Service) { + deploymentArtifacts = artifactConfigurationList.stream() + .filter(artifactConfiguration -> + artifactConfiguration.hasSupport(ArtifactGroupTypeEnum.DEPLOYMENT) + && artifactConfiguration.hasSupport(ComponentType.SERVICE)) + .collect(Collectors.toList()); } else { - deploymentArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); + deploymentArtifacts = artifactConfigurationList.stream() + .filter(artifactConfiguration -> + artifactConfiguration.hasSupport(ArtifactGroupTypeEnum.DEPLOYMENT) + && artifactConfiguration.hasSupport(ComponentType.RESOURCE)) + .collect(Collectors.toList()); } - if (deploymentArtifacts != null) { - for (String artifactType : deploymentArtifacts.keySet()) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } + final List artifactTypes = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(deploymentArtifacts)) { + deploymentArtifacts.forEach(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + artifactTypes.add(artifactType); + }); return Either.left(artifactTypes); - } else { - return Either.right(ActionStatus.GENERAL_ERROR); } + return Either.right(ActionStatus.GENERAL_ERROR); } public static int compareByGroupName(ArtifactTemplateInfo art1, ArtifactTemplateInfo art2) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java index c350812ce4..befdac48b0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java @@ -31,6 +31,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tags; +import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ElementBusinessLogic; import org.openecomp.sdc.be.components.impl.aaf.AafPermission; import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed; @@ -85,7 +86,7 @@ import java.util.Map; @Path("/v1/") -/**** +/** * * UI oriented servlet - to return elements in specific format UI needs * @@ -101,17 +102,18 @@ public class ElementServlet extends BeGenericServlet { private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}"; private final ComponentsCleanBusinessLogic componentsCleanBusinessLogic; private final ElementBusinessLogic elementBusinessLogic; - private final UserBusinessLogic userBusinessLogic; + private final ArtifactsBusinessLogic artifactsBusinessLogic; @Inject - public ElementServlet(UserBusinessLogic userBusinessLogic, - ComponentsUtils componentsUtils, - ComponentsCleanBusinessLogic componentsCleanBusinessLogic, - ElementBusinessLogic elementBusinessLogic) { + public ElementServlet(final UserBusinessLogic userBusinessLogic, + final ComponentsUtils componentsUtils, + final ComponentsCleanBusinessLogic componentsCleanBusinessLogic, + final ElementBusinessLogic elementBusinessLogic, + final ArtifactsBusinessLogic artifactsBusinessLogic) { super(userBusinessLogic, componentsUtils); this.componentsCleanBusinessLogic = componentsCleanBusinessLogic; this.elementBusinessLogic = elementBusinessLogic; - this.userBusinessLogic = userBusinessLogic; + this.artifactsBusinessLogic = artifactsBusinessLogic; } /* @@ -163,33 +165,6 @@ public class ElementServlet extends BeGenericServlet { } } - //TODO remove after UI alignment and tests after API consolidation ASDC-191 - /* @GET - @Path("/categories") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Retrieve the all resource, service and product categories", httpMethod = "GET", notes = "Retrieve the all resource, service and product categories", response = Response.class) - @ApiResponses(value = {@ApiResponse(code = 200, message = "Returns categories Ok"), @ApiResponse(code = 403, message = "Missing information"), - @ApiResponse(code = 409, message = "Restricted operation"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response getAllCategories(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { - - try { - ElementBusinessLogic elementBL = getElementBL(request.getSession().getServletContext()); - Either either = elementBL.getAllCategories(userId); - if (either.isRight()) { - log.debug("No categories were found"); - return buildErrorResponse(either.right().value()); - } else { - return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), either.left().value()); - } - } catch (Exception e) { - BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get All Categories"); - log.debug("getAllCategories failed with exception", e); - return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)); - } - }*/ - - @POST @Path("/category/{componentType}") @Consumes(MediaType.APPLICATION_JSON) @@ -712,7 +687,7 @@ public class ElementServlet extends BeGenericServlet { try { ServletContext servletContext = request.getSession().getServletContext(); - Map configuration = getConfigurationUi(elementBusinessLogic, userId); + Map configuration = getConfigurationUi(elementBusinessLogic); if (!configuration.isEmpty()) { consolidatedObject.put("configuration", configuration); } else { @@ -743,22 +718,12 @@ public class ElementServlet extends BeGenericServlet { return version; } - private Map getConfigurationUi(ElementBusinessLogic elementBL, String userId) { + private Map getConfigurationUi(final ElementBusinessLogic elementBL) { Either defaultHeatTimeout = elementBL.getDefaultHeatTimeout(); - Either, ActionStatus> deploymentEither = elementBL.getAllDeploymentArtifactTypes(); Either, ActionStatus> resourceTypesMap = elementBL.getResourceTypesMap(); - Either, ActionStatus> otherEither = elementBL.getAllArtifactTypes(userId); Map configuration = new HashMap<>(); - if (otherEither.isRight() || otherEither.left().value() == null) { - log.debug("No other artifact types were found"); - return configuration; - } - if (deploymentEither.isRight() || deploymentEither.left().value() == null) { - log.debug("No deployment artifact types were found"); - return configuration; - } if (defaultHeatTimeout.isRight() || defaultHeatTimeout.left().value() == null) { log.debug("heat default timeout was not found"); return configuration; @@ -767,10 +732,7 @@ public class ElementServlet extends BeGenericServlet { log.debug("No resource types were found"); return configuration; } - Map artifacts = new HashMap<>(); - artifacts.put("other", otherEither.left().value()); - artifacts.put("deployment", deploymentEither.left().value()); - configuration.put("artifacts", artifacts); + configuration.put("artifact", artifactsBusinessLogic.getConfiguration()); configuration.put("heatDeploymentTimeout", defaultHeatTimeout.left().value()); configuration.put("componentTypes", elementBL.getAllComponentTypesParamNames()); configuration.put("roles", elementBL.getAllSupportedRoles()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java index 604715d05d..92a1f8016c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java @@ -41,6 +41,8 @@ import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -50,10 +52,12 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; import org.onap.sdc.tosca.services.YamlUtil; +import org.openecomp.sdc.be.config.ArtifactConfigManager; import org.openecomp.sdc.be.components.impl.ImportUtils; import org.openecomp.sdc.be.components.impl.ImportUtils.Constants; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; @@ -68,7 +72,6 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; @@ -115,7 +118,7 @@ public class CsarUtils { private ToscaExportHandler toscaExportUtils; @Autowired protected ToscaOperationFacade toscaOperationFacade; - + @Autowired(required = false) private List generators; @@ -754,19 +757,23 @@ public class CsarUtils { return artifact; } + @Getter public static final class NonMetaArtifactInfo { + @Setter + private String artifactUniqueId; private final String path; private final String artifactName; private final String displayName; private final String artifactLabel; - private final ArtifactTypeEnum artifactType; + private final String artifactType; private final ArtifactGroupTypeEnum artifactGroupType; - private String payloadData; - private String artifactChecksum; - private String artifactUniqueId; + private final String payloadData; + private final String artifactChecksum; private final boolean isFromCsar; - public NonMetaArtifactInfo(String artifactName, String path, ArtifactTypeEnum artifactType, ArtifactGroupTypeEnum artifactGroupType, byte[] payloadData, String artifactUniqueId, boolean isFromCsar) { + public NonMetaArtifactInfo(final String artifactName, final String path, final String artifactType, + final ArtifactGroupTypeEnum artifactGroupType, final byte[] payloadData, + final String artifactUniqueId, final boolean isFromCsar) { super(); this.path = path; this.isFromCsar = isFromCsar; @@ -780,57 +787,16 @@ public class CsarUtils { displayName = artifactName; } this.artifactLabel = ValidationUtils.normalizeArtifactLabel(artifactName); - if (payloadData != null) { + if (payloadData == null) { + this.payloadData = null; + this.artifactChecksum = null; + } else { this.payloadData = Base64.encodeBase64String(payloadData); this.artifactChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(payloadData); } this.artifactUniqueId = artifactUniqueId; } - public String getPath() { - return path; - } - - public String getArtifactName() { - return artifactName; - } - - public ArtifactTypeEnum getArtifactType() { - return artifactType; - } - - public String getDisplayName() { - return displayName; - } - - public ArtifactGroupTypeEnum getArtifactGroupType() { - return artifactGroupType; - } - - public String getArtifactLabel() { - return artifactLabel; - } - - public boolean isFromCsar(){ - return isFromCsar; - } - - public String getPayloadData() { - return payloadData; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public String getArtifactUniqueId() { - return artifactUniqueId; - } - - public void setArtifactUniqueId(String artifactUniqueId) { - this.artifactUniqueId = artifactUniqueId; - } - } /** @@ -855,7 +821,7 @@ public class CsarUtils { artifactType = detectArtifactTypeVF(groupTypeEnum, artifactType, collectedWarningMessages); String artifactFileNameType = parsedArtifactPath[3]; - ret = Either.left(new NonMetaArtifactInfo(artifactFileNameType, artifactPath, ArtifactTypeEnum.findType(artifactType), groupTypeEnum, payloadData, null, true)); + ret = Either.left(new NonMetaArtifactInfo(artifactFileNameType, artifactPath, artifactType, groupTypeEnum, payloadData, null, true)); } else { ret = Either.right(eitherGroupType.right().value()); @@ -878,37 +844,21 @@ public class CsarUtils { return detectArtifactType(artifactGroupType, receivedTypeName, warningMessage, collectedWarningMessages); } - private static String detectArtifactType(ArtifactGroupTypeEnum artifactGroupType, String receivedTypeName, String warningMessage, Map>> collectedWarningMessages, String... arguments) { - - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(receivedTypeName); - Map resourceValidTypeArtifacts = null; - - if(artifactGroupType != null){ - switch (artifactGroupType) { - case INFORMATIONAL: - resourceValidTypeArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getResourceInformationalArtifacts(); - break; - case DEPLOYMENT: - resourceValidTypeArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getResourceDeploymentArtifacts(); - break; - default: - break; - } - } - - Set validArtifactTypes = null; - if(resourceValidTypeArtifacts != null){ - validArtifactTypes = resourceValidTypeArtifacts.keySet(); - } - - if (validArtifactTypes == null || artifactType == null || !validArtifactTypes.contains(artifactType.getType())) { - List messageArguments = new ArrayList<>(); + private static String detectArtifactType(final ArtifactGroupTypeEnum artifactGroupType, + final String receivedTypeName, final String warningMessage, + final Map>> collectedWarningMessages, + final String... arguments) { + final ArtifactConfiguration artifactConfiguration = + ArtifactConfigManager.getInstance() + .find(receivedTypeName, artifactGroupType, ComponentType.RESOURCE) + .orElse(null); + + if (artifactConfiguration == null) { + final List messageArguments = new ArrayList<>(); messageArguments.add(receivedTypeName); messageArguments.addAll(Arrays.asList(arguments)); if (!collectedWarningMessages.containsKey(warningMessage)) { - Set> messageArgumentLists = new HashSet<>(); + final Set> messageArgumentLists = new HashSet<>(); messageArgumentLists.add(messageArguments); collectedWarningMessages.put(warningMessage, messageArgumentLists); } else { @@ -916,7 +866,7 @@ public class CsarUtils { } } - return artifactType == null ? ArtifactTypeEnum.OTHER.getType() : artifactType.getType(); + return artifactConfiguration == null ? ArtifactTypeEnum.OTHER.getType() : receivedTypeName; } private Either writeAllFilesToCsar(Component mainComponent, CsarDefinition csarDefinition, ZipOutputStream zipstream, boolean isInCertificationRequest) throws IOException{ @@ -929,7 +879,7 @@ public class CsarUtils { } ComponentTypeArtifacts mainTypeAndCIArtifacts = componentArtifacts.getMainTypeAndCIArtifacts(); - writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, mainTypeAndCIArtifacts.getComponentArtifacts(), zipstream, ARTIFACTS_PATH, isInCertificationRequest); + writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, mainTypeAndCIArtifacts.getComponentArtifacts(), zipstream, ARTIFACTS_PATH, isInCertificationRequest); if(writeComponentArtifactsToSpecifiedPath.isRight()){ return Either.right(writeComponentArtifactsToSpecifiedPath.right().value()); @@ -942,7 +892,7 @@ public class CsarUtils { for (String keyAssetName : keySet) { ArtifactsInfo artifactsInfo = componentInstancesArtifacts.get(keyAssetName); String pathWithAssetName = currentPath + keyAssetName + PATH_DELIMITER; - writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, artifactsInfo, zipstream, pathWithAssetName, isInCertificationRequest); + writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, artifactsInfo, zipstream, pathWithAssetName, isInCertificationRequest); if(writeComponentArtifactsToSpecifiedPath.isRight()){ return Either.right(writeComponentArtifactsToSpecifiedPath.right().value()); @@ -1036,7 +986,7 @@ public class CsarUtils { ComponentTypeArtifacts componentInstanceArtifacts = componentTypeArtifacts.get(keyAssetName); ArtifactsInfo componentArtifacts2 = componentInstanceArtifacts.getComponentArtifacts(); String pathWithAssetName = currentPath + keyAssetName + PATH_DELIMITER; - Either writeArtifactsInfoToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, componentArtifacts2, zipstream, pathWithAssetName, isInCertificationRequest); + Either writeArtifactsInfoToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, componentArtifacts2, zipstream, pathWithAssetName, isInCertificationRequest); if(writeArtifactsInfoToSpecifiedPath.isRight()){ return writeArtifactsInfoToSpecifiedPath; @@ -1046,32 +996,34 @@ public class CsarUtils { return Either.left(zipstream); } - private Either writeArtifactsInfoToSpecifiedtPath(Component mainComponent, ArtifactsInfo currArtifactsInfo, ZipOutputStream zip, String path, boolean isInCertificationRequest) throws IOException { - Map>> artifactsInfo = currArtifactsInfo - .getArtifactsInfo(); - Set groupTypeEnumKeySet = artifactsInfo.keySet(); - - for (ArtifactGroupTypeEnum artifactGroupTypeEnum : groupTypeEnumKeySet) { - String groupTypeFolder = path + WordUtils.capitalizeFully(artifactGroupTypeEnum.getType()) + PATH_DELIMITER; + private Either writeArtifactsInfoToSpecifiedPath(final Component mainComponent, + final ArtifactsInfo currArtifactsInfo, + final ZipOutputStream zip, + final String path, + final boolean isInCertificationRequest) throws IOException { + final Map>> artifactsInfo = + currArtifactsInfo.getArtifactsInfo(); + for (final ArtifactGroupTypeEnum artifactGroupTypeEnum : artifactsInfo.keySet()) { + final String groupTypeFolder = path + WordUtils.capitalizeFully(artifactGroupTypeEnum.getType()) + PATH_DELIMITER; - Map> artifactTypesMap = artifactsInfo.get(artifactGroupTypeEnum); - Set artifactTypeEnumKeySet = artifactTypesMap.keySet(); + final Map> artifactTypesMap = artifactsInfo.get(artifactGroupTypeEnum); - for (ArtifactTypeEnum artifactTypeEnum : artifactTypeEnumKeySet) { - List artifactDefinitionList = artifactTypesMap.get(artifactTypeEnum); - String artifactTypeFolder = groupTypeFolder + artifactTypeEnum.toString() + PATH_DELIMITER; + for (final String artifactType : artifactTypesMap.keySet()) { + final List artifactDefinitionList = artifactTypesMap.get(artifactType); + String artifactTypeFolder = groupTypeFolder + artifactType + PATH_DELIMITER; - if(artifactTypeEnum == ArtifactTypeEnum.WORKFLOW && path.contains(ARTIFACTS_PATH + RESOURCES_PATH)){ + if(ArtifactTypeEnum.WORKFLOW.getType().equals(artifactType) && path.contains(ARTIFACTS_PATH + RESOURCES_PATH)){ // Ignore this packaging as BPMN artifacts needs to be packaged in different manner continue; } - if (artifactTypeEnum == ArtifactTypeEnum.WORKFLOW) { + if (ArtifactTypeEnum.WORKFLOW.getType().equals(artifactType)) { artifactTypeFolder += OperationArtifactUtil.BPMN_ARTIFACT_PATH + File.separator; } - Either writeArtifactDefinition = writeArtifactDefinition(mainComponent, zip, artifactDefinitionList, artifactTypeFolder, isInCertificationRequest); + Either writeArtifactDefinition = + writeArtifactDefinition(mainComponent, zip, artifactDefinitionList, artifactTypeFolder, isInCertificationRequest); - if(writeArtifactDefinition.isRight()){ + if (writeArtifactDefinition.isRight()) { return writeArtifactDefinition; } } @@ -1121,29 +1073,22 @@ public class CsarUtils { private class ArtifactsInfo { //Key is the type of artifacts(Informational/Deployment) //Value is a map between an artifact type and a list of all artifacts of this type - private Map>> artifactsInfoField; + private Map>> artifactsInfoField; public ArtifactsInfo() { this.artifactsInfoField = new EnumMap<>(ArtifactGroupTypeEnum.class); } - public Map>> getArtifactsInfo() { + public Map>> getArtifactsInfo() { return artifactsInfoField; } - public List getFlatArtifactsListByType(ArtifactTypeEnum artifactType){ - List artifacts = new ArrayList<>(); - for (List artifactsByType:artifactsInfoField.get(artifactType).values()){ - artifacts.addAll(artifactsByType); - } - return artifacts; - } - - public void addArtifactsToGroup(ArtifactGroupTypeEnum artifactGroup,Map> artifactsDefinition){ + public void addArtifactsToGroup(ArtifactGroupTypeEnum artifactGroup, + Map> artifactsDefinition) { if (artifactsInfoField.get(artifactGroup) == null) { artifactsInfoField.put(artifactGroup, artifactsDefinition); } else { - Map> artifactTypeEnumListMap = + Map> artifactTypeEnumListMap = artifactsInfoField.get(artifactGroup); artifactTypeEnumListMap.putAll(artifactsDefinition); artifactsInfoField.put(artifactGroup, artifactTypeEnumListMap); @@ -1295,8 +1240,8 @@ public class CsarUtils { private String printArtifacts(ComponentTypeArtifacts componentInstanceArtifacts) { StringBuilder result = new StringBuilder(); ArtifactsInfo artifactsInfo = componentInstanceArtifacts.getComponentArtifacts(); - Map>> componetArtifacts = artifactsInfo.getArtifactsInfo(); - printArtifacts(componetArtifacts); + Map>> componentArtifacts = artifactsInfo.getArtifactsInfo(); + printArtifacts(componentArtifacts); result = result.append("Resources\n"); for (Map.Entry resourceInstance:componentInstanceArtifacts.getComponentInstancesArtifacts().entrySet()){ result.append("Folder" + resourceInstance.getKey() + "\n"); @@ -1306,12 +1251,12 @@ public class CsarUtils { return result.toString(); } - private String printArtifacts(Map>> componetArtifacts) { + private String printArtifacts(Map>> componetArtifacts) { StringBuilder result = new StringBuilder(); - for (Map.Entry>> artifactGroup:componetArtifacts.entrySet()){ + for (Map.Entry>> artifactGroup:componetArtifacts.entrySet()){ result.append(" " + artifactGroup.getKey().getType()); - for (Map.Entry> groupArtifacts:artifactGroup.getValue().entrySet()){ - result.append(" " + groupArtifacts.getKey().getType()); + for (Map.Entry> groupArtifacts:artifactGroup.getValue().entrySet()){ + result.append(" " + groupArtifacts.getKey()); for (ArtifactDefinition artifact:groupArtifacts.getValue()){ result.append(" " + artifact.getArtifactDisplayName()); } @@ -1361,10 +1306,10 @@ public class CsarUtils { ComponentTypeArtifacts componentParentArtifacts = collectComponentTypeArtifacts(resourcesTypeArtifacts, componentInstance, fetchedComponent); //3. find the artifacts specific to the instance - Map> componentInstanceSpecificInformationalArtifacts = + Map> componentInstanceSpecificInformationalArtifacts = getComponentInstanceSpecificArtifacts(componentInstance.getArtifacts(), componentParentArtifacts.getComponentArtifacts().getArtifactsInfo(), ArtifactGroupTypeEnum.INFORMATIONAL); - Map> componentInstanceSpecificDeploymentArtifacts = + Map> componentInstanceSpecificDeploymentArtifacts = getComponentInstanceSpecificArtifacts(componentInstance.getDeploymentArtifacts(), componentParentArtifacts.getComponentArtifacts().getArtifactsInfo(), ArtifactGroupTypeEnum.DEPLOYMENT); @@ -1402,24 +1347,23 @@ public class CsarUtils { public void setVersionFirstThreeOctets(String versionFirstThreeOctetes) { this.versionFirstThreeOctets = versionFirstThreeOctetes; } - private Map> getComponentInstanceSpecificArtifacts(Map componentArtifacts, - Map>> componentTypeArtifacts, ArtifactGroupTypeEnum artifactGroupTypeEnum) { - Map> parentArtifacts = componentTypeArtifacts.get(artifactGroupTypeEnum); //the artfiacts of the component itself and not the instance + private Map> getComponentInstanceSpecificArtifacts(Map componentArtifacts, + Map>> componentTypeArtifacts, ArtifactGroupTypeEnum artifactGroupTypeEnum) { + Map> parentArtifacts = componentTypeArtifacts.get(artifactGroupTypeEnum); //the artfiacts of the component itself and not the instance - Map> artifactsByTypeOfComponentInstance = new EnumMap<>(ArtifactTypeEnum.class); + Map> artifactsByTypeOfComponentInstance = new HashMap<>(); if (componentArtifacts!=null){ for (ArtifactDefinition artifact:componentArtifacts.values()){ - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); List parentArtifactsByType = null; if (parentArtifacts!=null){ - parentArtifactsByType = parentArtifacts.get(artifactType); + parentArtifactsByType = parentArtifacts.get(artifact.getArtifactType()); } //the artifact is of instance if (parentArtifactsByType == null || !parentArtifactsByType.contains(artifact)){ - List typeArtifacts = artifactsByTypeOfComponentInstance.get(artifactType); + List typeArtifacts = artifactsByTypeOfComponentInstance.get(artifact.getArtifactType()); if (typeArtifacts == null){ typeArtifacts = new ArrayList<>(); - artifactsByTypeOfComponentInstance.put(artifactType, typeArtifacts); + artifactsByTypeOfComponentInstance.put(artifact.getArtifactType(), typeArtifacts); } typeArtifacts.add(artifact); } @@ -1431,12 +1375,12 @@ public class CsarUtils { private ArtifactsInfo collectComponentArtifacts(Component component) { Map informationalArtifacts = component.getArtifacts(); - Map> informationalArtifactsByType = collectGroupArtifacts(informationalArtifacts); + Map> informationalArtifactsByType = collectGroupArtifacts(informationalArtifacts); Map deploymentArtifacts = component.getDeploymentArtifacts(); - Map> deploymentArtifactsByType = collectGroupArtifacts(deploymentArtifacts); + Map> deploymentArtifactsByType = collectGroupArtifacts(deploymentArtifacts); Map interfaceOperationArtifacts = OperationArtifactUtil.getDistinctInterfaceOperationArtifactsByName(component); - Map> interfaceOperationArtifactsByType = collectGroupArtifacts( + Map> interfaceOperationArtifactsByType = collectGroupArtifacts( interfaceOperationArtifacts); ArtifactsInfo artifactsInfo = new ArtifactsInfo(); if (!informationalArtifactsByType.isEmpty()){ @@ -1453,16 +1397,13 @@ public class CsarUtils { return artifactsInfo; } - private Map> collectGroupArtifacts(Map componentArtifacts) { - Map> artifactsByType = new EnumMap<>(ArtifactTypeEnum.class); - for (ArtifactDefinition artifact:componentArtifacts.values()){ - if (artifact.getArtifactUUID()!=null){ - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); - List typeArtifacts = artifactsByType.get(artifactType); - if (typeArtifacts==null){ - typeArtifacts = new ArrayList<>(); - artifactsByType.put(artifactType, typeArtifacts); - } + private Map> collectGroupArtifacts( + final Map componentArtifacts) { + final Map> artifactsByType = new HashMap<>(); + for (final ArtifactDefinition artifact : componentArtifacts.values()) { + if (artifact.getArtifactUUID() != null) { + artifactsByType.putIfAbsent(artifact.getArtifactType(), new ArrayList<>()); + final List typeArtifacts = artifactsByType.get(artifact.getArtifactType()); typeArtifacts.add(artifact); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java index bab82ada1b..08e4406d6a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java @@ -16,6 +16,13 @@ package org.openecomp.sdc.be.tosca.utils; +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.WordUtils; import org.openecomp.sdc.be.components.impl.ImportUtils.Constants; @@ -33,15 +40,6 @@ import org.openecomp.sdc.be.tosca.CsarUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - public class OperationArtifactUtil { public static final String BPMN_ARTIFACT_PATH = "BPMN"; @@ -86,11 +84,11 @@ public class OperationArtifactUtil { return implementationArtifactName.substring(1, implementationArtifactName.length()-1); } else { return CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) - + File.separator + ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + + File.separator + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + operation.getImplementation().getArtifactName(); } } - + private static boolean artifactNameIsALiteralValue(final String artifactName) { return artifactName.startsWith(Constants.ESCAPED_DOUBLE_QUOTE) && artifactName.endsWith(Constants.ESCAPED_DOUBLE_QUOTE); } @@ -99,7 +97,7 @@ public class OperationArtifactUtil { OperationDataDefinition operation) { return CsarUtils.ARTIFACTS + File.separator + toscaComponentName + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + operation.getImplementation().getArtifactName(); } diff --git a/catalog-be/src/main/resources/config/configuration.yaml b/catalog-be/src/main/resources/config/configuration.yaml index f6d12fcfa0..b56c243093 100644 --- a/catalog-be/src/main/resources/config/configuration.yaml +++ b/catalog-be/src/main/resources/config/configuration.yaml @@ -121,31 +121,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-sdc-iltlv650', '1']} - { name: sdcrepository, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-sdc-iltlv650', '1']} -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - CONTROLLER_BLUEPRINT_ARCHIVE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index b1c0330d4f..48a317bcf0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -110,13 +110,7 @@ public class ElementOperationMock implements IElementOperation { } @Override - public Either, ActionStatus> getAllArtifactTypes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Either, ActionStatus> getAllDeploymentArtifactTypes() { + public List getAllArtifactTypes() { // TODO Auto-generated method stub return null; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java index 0b9542c269..bbe453e755 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.be.components.distribution.engine; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + import mockit.Deencapsulation; import org.junit.Assert; import org.junit.Test; @@ -130,23 +133,11 @@ public class ArtifactInfoImplTest extends BeConfDependentTest { } @Test - public void testGetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactType(); - } - - @Test - public void testSetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum artifactType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL); + public void testSetArtifactType() { + final ArtifactInfoImpl testSubject = createTestSubject(); + final String expectedType = ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(); + testSubject.setArtifactType(expectedType); + assertThat("Artifact type should be the same", testSubject.getArtifactType(), is(expectedType)); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java index e401df3920..3fb25dfc77 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,11 +38,12 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.components.ArtifactsResolver; +import org.openecomp.sdc.be.config.ArtifactConfigManager; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -432,15 +434,22 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map componentDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); - Map componentInstanceDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index edf561b717..cd7d9d556a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -22,6 +22,28 @@ package org.openecomp.sdc.be.components.impl; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,6 +52,15 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; import mockit.Deencapsulation; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; @@ -48,11 +79,15 @@ import org.openecomp.sdc.be.MockGenerator; import org.openecomp.sdc.be.components.ArtifactsResolver; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo; +import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; import org.openecomp.sdc.be.components.validation.UserValidations; +import org.openecomp.sdc.be.config.ArtifactConfigManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -107,42 +142,13 @@ import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; - @RunWith(MockitoJUnitRunner.Silent.class) -public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ +public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { private static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis()); private static final String RESOURCE_INSTANCE_NAME = "Service-111"; private static final String INSTANCE_ID = "S-123-444-ghghghg"; - private static final String ARTIFACT_NAME = "service-Myservice-template.yml"; private static final String ARTIFACT_LABEL = "assettoscatemplate"; private static final String ES_ARTIFACT_ID = "123123dfgdfgd0"; @@ -150,7 +156,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private static final String RESOURCE_NAME = "My-Resource_Name with space"; private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; private static final String RESOURCE_SUBCATEGORY = "Router"; - public static final String RESOURCE_CATEGORY = "Network Layer 2-3/Router"; private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension"; public static final Resource resource = Mockito.mock(Resource.class); @@ -158,7 +163,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private ArtifactsBusinessLogic artifactBL; private static User user = null; private static Resource resourceResponse = null; - private static ResponseFormatManager responseManager = null; final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class); @Mock public ComponentsUtils componentsUtils; @@ -196,15 +200,13 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private Gson gson = new GsonBuilder().setPrettyPrinting().create(); private static List getAllTypes() { - List artifactTypes = new ArrayList(); - List artifactTypesList = ConfigurationManager.getConfigurationManager().getConfiguration() - .getArtifactTypes(); - for (String artifactType : artifactTypesList) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return artifactTypes; + final List artifactConfigurationList = ConfigurationManager.getConfigurationManager() + .getConfiguration().getArtifacts(); + return artifactConfigurationList.stream().map(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + return artifactType; + }).collect(Collectors.toList()); } @Before @@ -227,8 +229,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ when(userOperation.getUserData("jh0003", false)).thenReturn(Either.left(USER)); - Either, ActionStatus> getType = Either.left(getAllTypes()); - when(elementOperation.getAllArtifactTypes()).thenReturn(getType); + when(elementOperation.getAllArtifactTypes()).thenReturn(getAllTypes()); when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC); @@ -665,15 +666,22 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map componentDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration().getResourceDeploymentArtifacts(); - Map componentInstanceDeploymentArtifacts = ConfigurationManager - .getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test @@ -1051,7 +1059,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testFindArtifactOnParentComponent() throws Exception { + public void testFindArtifactOnParentComponent() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE; @@ -1063,7 +1071,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "findArtifactOnParentComponent", new Object[]{component, + result = Deencapsulation.invoke(testSubject, "findArtifact", new Object[]{component, componentType, parentId, operation, artifactId}); } @@ -1154,9 +1162,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentId, instanceId, componentType}); } - @Test - public void testFindComponentInstance() throws Exception { + public void testFindComponentInstance() { ArtifactsBusinessLogic testSubject; String componentInstanceId = ""; Component component = createResourceObject(true); @@ -1168,9 +1175,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentInstanceId, component}); } - - @Test(expected= ComponentException.class) - public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() throws Exception { + @Test(expected = ComponentException.class) + public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() { ArtifactsBusinessLogic testSubject; ArtifactDefinition artifactInfo = buildArtifactPayload(); ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; @@ -1180,56 +1186,83 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateDeploymentArtifactTypeIsLegalForParent(artifactInfo, artifactType, resourceDeploymentArtifacts); } - @Test - public void testFillDeploymentArtifactTypeConf() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - Map result; + public void testLoadArtifactTypeConfig() { + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //null artifactType + Optional artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(null); + assertThat(artifactConfiguration.isPresent()).isFalse(); + //not configured artifactType + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig("NotConfiguredArtifactType"); + assertThat(artifactConfiguration.isPresent()).isFalse(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "fillDeploymentArtifactTypeConf", - new Object[]{parentType}); + //valid artifactType + final String artifactType = ArtifactTypeEnum.YANG.getType(); + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(artifactType); + assertThat(artifactConfiguration.isPresent()).isTrue(); + final ArtifactConfiguration artifactConfiguration1 = artifactConfiguration.get(); + assertThat(artifactConfiguration1.getType()).isEqualTo(artifactType); + assertThat(artifactConfiguration1.getCategories()).hasSize(1); + assertThat(artifactConfiguration1.getCategories()).contains(ArtifactGroupTypeEnum.INFORMATIONAL); + assertThat(artifactConfiguration1.getComponentTypes()).hasSize(1); + assertThat(artifactConfiguration1.getComponentTypes()).contains(ComponentType.RESOURCE); + assertThat(artifactConfiguration1.getResourceTypes()).hasSize(7); + assertThat(artifactConfiguration1.getResourceTypes()) + .contains(ResourceTypeEnum.VFC.getValue(), ResourceTypeEnum.CP.getValue(), ResourceTypeEnum.VL.getValue(), + ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.VFCMT.getValue(), "Abstract", + ResourceTypeEnum.CVFC.getValue()); } - @Test - public void testValidateArtifactTypeExists() throws Exception { - ArtifactsBusinessLogic testSubject; - Wrapper responseWrapper = null; - ArtifactDefinition artifactInfo = buildArtifactPayload(); + public void testValidateArtifactExtension_acceptedExtension() { + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + artifactInfo.setArtifactName("artifact.yml"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //empty accepted types + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(new ArtifactConfiguration(), artifactInfo)) + .doesNotThrowAnyException(); - // default test - testSubject = createTestSubject(); - testSubject.getValidArtifactType(artifactInfo); + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo)) + .doesNotThrowAnyException(); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_notAcceptedExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //not accepted extension + artifactInfo.setArtifactName("artifact.xml"); - @Test - public void testGetDeploymentArtifactTypeConfig() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; - ArtifactTypeConfig result; + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "getDeploymentArtifactTypeConfig", - new Object[]{parentType, artifactType}); + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_noExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //no extension in the artifact name + artifactInfo.setArtifactName("artifact"); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - @Test(expected= ComponentException.class) - public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() throws Exception { + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); + } + + @Test(expected = ComponentException.class) + public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); String parentId = ""; ArtifactDefinition artifactInfo = buildArtifactPayload(); - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; // default test testSubject = createTestSubject(); - testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo, parentType); + testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo); } @Test @@ -1257,47 +1290,46 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ result = Deencapsulation.invoke(testSubject, "isValidXml", new Object[]{xmlToParse}); } - @Test - public void testHeatTimeoutValue() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + @Test(expected = ByActionStatusComponentException.class) + public void testHeatTimeoutValue() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setTimeout(1); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); + artifactInfo.setTimeout(0); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); } @Test - public void testValidateHeatDeploymentArtifact() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + public void testValidateResourceType_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List typeList = Arrays + .asList(ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.PNF.getValue(), ResourceTypeEnum.VFC.getValue()); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); + }).doesNotThrowAnyException(); } - - @Test(expected= ComponentException.class) - public void testValidateResourceType_shouldThrowException() throws Exception { - ArtifactsBusinessLogic testSubject; - ResourceTypeEnum resourceType = ResourceTypeEnum.VF; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - List typeList = new ArrayList<>(); - Either result; - - // test 1 - testSubject = createTestSubject(); - testSubject.validateResourceType(resourceType, artifactInfo, typeList); - result = Deencapsulation.invoke(testSubject, "validateResourceType", new Object[]{resourceType, artifactInfo, typeList}); + @Test(expected=ComponentException.class) + public void testValidateResourceType_invalidResourceType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List typeList = Collections.singletonList(ResourceTypeEnum.PNF.getValue()); + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); } + @Test + public void testValidateResourceType_emptyResourceTypeConfig_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, null); + }).doesNotThrowAnyException(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, new ArrayList<>()); + }).doesNotThrowAnyException(); + } @Test public void testValidateAndConvertHeatParameters() throws Exception { @@ -1321,7 +1353,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = testSubject.getDeploymentArtifacts(component, parentType, ciId); + result = testSubject.getDeploymentArtifacts(component, ciId); } @@ -1349,6 +1381,36 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateAndSetArtifactName(artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactType_notConfiguredArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType("notConfiguredType"); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_componentTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_groupTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.SERVICE); + } + @Test public void testValidateArtifactTypeNotChanged() throws Exception { ArtifactsBusinessLogic testSubject; @@ -1883,6 +1945,172 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ assertEquals(Deencapsulation.getField(testSubject, "nodeTemplateOperation"), nodeTemplateOperation); } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_invalidComponentType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.PRODUCT); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_notConfiguredArtifactType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.RESOURCE); + artifactDefinition.setArtifactType("NotConfiguredType"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_unsupportedResourceType() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.ServiceProxy); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + } + + @Test + public void validateDeploymentArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.VF); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + }).doesNotThrowAnyException(); + + } + + @Test + public void validateHeatArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); + artifactDefinition.setTimeout(1); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateHeatArtifact", new Resource(), "componentId", artifactDefinition); + }).doesNotThrowAnyException(); + } + + @Test + public void validateInputForResourceInstance() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + artifactDefinition.setDescription("artifact description"); + artifactDefinition.setServiceApi(true); + artifactDefinition.setApiUrl("dumbUrl"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + + result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + } + + @Test + public void validateInputForResourceInstanceDeploymentArtifact() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + artifactDefinition.setDescription("artifact description"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + final Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + } + + @Test public void testHandleArtifactRequest() { @@ -1894,7 +2122,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setPayload("Test".getBytes()); artifactDefinition.setArtifactLabel("other"); artifactDefinition.setDescription("Test artifact"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.getType()); artifactDefinition.setArtifactUUID("artifactUId"); artifactDefinition.setArtifactLabel("test"); artifactDefinition.setArtifactDisplayName("Test"); @@ -1979,7 +2207,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setUniqueId("artifactId"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.getType()); User user = new User(); boolean inCertificationRequest = false; boolean fetchTemplatesFromDB = false; @@ -2013,7 +2241,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition csarArtifact = new ArtifactDefinition(); csarArtifact.setArtifactName("csarArtifact"); - csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.name()); + csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.getType()); csarArtifact.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean())) @@ -2039,7 +2267,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setArtifactName("test.csar"); artifactDefinition.setArtifactType(ComponentTypeEnum.RESOURCE.name()); - artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); artifactDefinition.setUniqueId(artifactId); artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); @@ -2143,7 +2371,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ resource.setComponentInstances(componentInstanceList); componentInstance.setDeploymentArtifacts(deploymentArtifacts); - List result = artifactBL.getDeploymentArtifacts(resource, parentType, ciId); + List result = artifactBL.getDeploymentArtifacts(resource, ciId); assertThat(result.size() == 1).isTrue(); Assert.assertEquals(artifactDefinition.getArtifactName(), result.get(0).getArtifactName()); } @@ -2249,8 +2477,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } private ArtifactsBusinessLogic getTestSubject() { - return new ArtifactsBusinessLogic(artifactCassandraDao, toscaExportHandler, csarUtils, lifecycleBusinessLogic, - userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + final ArtifactsBusinessLogic artifactsBusinessLogic = new ArtifactsBusinessLogic(artifactCassandraDao, + toscaExportHandler, csarUtils, lifecycleBusinessLogic, + userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, + groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + artifactsBusinessLogic.setComponentsUtils(componentsUtils); + return artifactsBusinessLogic; } } \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 9e563fc34c..c19d997d73 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1842,27 +1842,27 @@ public class ResourceBusinessLogicTest { List artifactPathAndNameList = new ArrayList<>(); NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo( deploymentArtifactToUpdate.getArtifactName(), null, - ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()), + deploymentArtifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToCreateFileName, false); NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactInfoToCreateFileName, false); artifactPathAndNameList.add(deploymentArtifactInfoToUpdate); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java index 06b06b08ad..160f595e95 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java @@ -154,7 +154,7 @@ public class ComponentInstanceArtifactsMergeTest { artifactCreatedOnTheInstance.setTimeout(30); ArtifactDefinition artifactGeneratedBySubmitForTesting = new ArtifactDefinition(); artifactGeneratedBySubmitForTesting.setArtifactLabel("artifactThree"); - artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.name()); + artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType()); artifactGeneratedBySubmitForTesting.setTimeout(30); Map componentInstanceArtifacts = new HashMap<>(); componentInstanceArtifacts.put(artifactFromTheOriginalResource.getArtifactLabel(), artifactFromTheOriginalResource); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java index 71513c36bd..c488a9a6ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java @@ -53,7 +53,7 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class RoleAuthorizationHandlerTest { - private RoleAuthorizationHandler roleAuthorizationHandler = new RoleAuthorizationHandler(); + private RoleAuthorizationHandler roleAuthorizationHandler; @Mock JoinPoint joinPoint; @Mock @@ -72,6 +72,7 @@ public class RoleAuthorizationHandlerTest { when(beGenericServlet.getServletRequest()).thenReturn(httpServletRequest); ThreadLocalsHolder.setApiType(FilterDecisionEnum.EXTERNAL); new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be/auth")); + roleAuthorizationHandler = new RoleAuthorizationHandler(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java index f90ef19293..974f286098 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java @@ -305,7 +305,6 @@ public class ElementServletTest extends JerseyTest { Either getAllCategoriesEither = Either.left(new UiCategories()); Either, ActionStatus> otherEither = Either.left(new ArrayList<>()); when(elementBusinessLogic.getDefaultHeatTimeout()).thenReturn(Either.left(configurationManager.getConfiguration().getHeatArtifactDeploymentTimeout())); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()).thenReturn(Either.left(new HashMap())); when(elementBusinessLogic.getResourceTypesMap()).thenReturn(Either.left(new HashMap())); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); @@ -961,15 +960,12 @@ public class ElementServletTest extends JerseyTest { Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout(); heatDeploymentArtifactTimeout.setDefaultMinutes(1); Either defaultHeatTimeoutEither = Either.left(heatDeploymentArtifactTimeout); - Either, ActionStatus> deploymentEither = Either.left(new HashMap<>()); Either, ActionStatus> resourceTypesMapEither = Either.left(new HashMap<>()); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); when(elementBusinessLogic.getDefaultHeatTimeout()) .thenReturn(defaultHeatTimeoutEither); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()) - .thenReturn(deploymentEither); when(elementBusinessLogic.getResourceTypesMap()) .thenReturn(resourceTypesMapEither); @@ -1065,6 +1061,7 @@ public class ElementServletTest extends JerseyTest { bind(componentUtils).to(ComponentsUtils.class); bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class); bind(elementBusinessLogic).to(ElementBusinessLogic.class); + bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class); } }) .property("contextConfig", context); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java index cdea369fe8..c7dced79c5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.tosca; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -115,7 +117,7 @@ public class CsarUtilsTest extends BeConfDependentTest { private final List nodesFromPackage = Arrays.asList("tosca.nodes.Root", "tosca.nodes.Container.Application"); private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() { - return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL, + return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true); } @@ -706,9 +708,9 @@ public class CsarUtilsTest extends BeConfDependentTest { @Test public void testNonMetaArtifactInfoGetArtifactType() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactType(); + final NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); + assertThat("The artifact type should be as expected", + testSubject.getArtifactType(), is(ArtifactTypeEnum.AAI_SERVICE_MODEL.getType())); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java index 23288582ca..c9f21e41b7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java @@ -62,7 +62,7 @@ public class OperationArtifactUtilTest { final String actualArtifactPath = OperationArtifactUtil.createOperationArtifactPath(component, null, op, false); String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; @@ -84,7 +84,7 @@ public class OperationArtifactUtilTest { String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + "org.openecomp.resource.vf.TestResource_v1.0" + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml index 0e68b3294b..f13e74bdcc 100644 --- a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml @@ -1,739 +1 @@ -identificationHeaderFields: - - HTTP_IV_USER - - HTTP_CSP_FIRSTNAME - - HTTP_CSP_LASTNAME - - HTTP_IV_REMOTE_ADDRESS - - HTTP_CSP_WSTYPE - -# catalog backend hostname -beFqdn: localhost -# sdccatalog.com - -# catalog backend http port -beHttpPort: 8080 - -# catalog backend http context -beContext: /sdc/rest/config/get - -# catalog backend protocol -beProtocol: http - -# catalog backend ssl port -beSslPort: 8443 - -version: 1.1.0 -released: 2012-11-30 -toscaConformanceLevel: 8.0 -minToscaConformanceLevel: 3.0 - -janusGraphCfgFile: /home/vagrant/catalog-be/config/catalog-be/janusGraph.properties -janusGraphInMemoryGraph: false -janusGraphLockTimeout: 1800 - -# The interval to try and reconnect to janusGraph DB when it is down during ASDC startup: -janusGraphReconnectIntervalInSeconds: 3 - -# The read timeout towards Titan DB when health check is invoked: -janusGraphHealthCheckReadTimeout: 1 - -uebHealthCheckReconnectIntervalInSeconds: 15 -uebHealthCheckReadTimeout: 4 - -# Protocols -protocols: - - http - - https - -# Default imports -defaultImports: - - nodes: - file: nodes.yml - - datatypes: - file: data.yml - - capabilities: - file: capabilities.yml - - relationships: - file: relationships.yml - - groups: - file: groups.yml - - policies: - file: policies.yml - -# Users -users: - tom: passwd - bob: passwd - -neo4j: - host: neo4jhost - port: 7474 - user: neo4j - password: "12345" - -cassandraConfig: - cassandraHosts: ['localhost'] - localDataCenter: datacenter1 - reconnectTimeout : 30000 - authenticate: false - username: koko - password: bobo - ssl: false - truststorePath : /path/path - truststorePassword : 123123 - keySpaces: - - { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - -licenseTypes: - - User - - Installation - - CPU - -#Deployment artifacts placeHolder -resourceTypes: &allResourceTypes - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - -# validForResourceTypes usage -# validForResourceTypes: -# - VF -# - VL -deploymentResourceArtifacts: -# heat: -# displayName: "Base HEAT Template" -# type: HEAT -# validForResourceTypes: *allResourceTypes -# heatVol: -# displayName: "Volume HEAT Template" -# type: HEAT_VOL -# validForResourceTypes: *allResourceTypes -# heatNet: -# displayName: "Network HEAT Template" -# type: HEAT_NET -# validForResourceTypes: *allResourceTypes - -deploymentResourceInstanceArtifacts: - heatEnv: - displayName: "HEAT ENV" - type: HEAT_ENV - description: "Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - VfHeatEnv: - displayName: "VF HEAT ENV" - type: HEAT_ENV - description: "VF Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - -#tosca artifacts placeholders -toscaArtifacts: - assetToscaTemplate: - artifactName: -template.yml - displayName: Tosca Template - type: TOSCA_TEMPLATE - description: TOSCA representation of the asset - assetToscaCsar: - artifactName: -csar.csar - displayName: Tosca Model - type: TOSCA_CSAR - description: TOSCA definition package of the asset - - -#Informational artifacts placeHolder -excludeResourceCategory: - - Generic -excludeResourceType: - - PNF -informationalResourceArtifacts: - features: - displayName: Features - type: OTHER - capacity: - displayName: Capacity - type: OTHER - vendorTestResult: - displayName: Vendor Test Result - type: OTHER - testScripts: - displayName: Test Scripts - type: OTHER - CloudQuestionnaire: - displayName: Cloud Questionnaire (completed) - type: OTHER - HEATTemplateFromVendor: - displayName: HEAT Template from Vendor - type: HEAT - resourceSecurityTemplate: - displayName: Resource Security Template - type: OTHER - -excludeServiceCategory: - -informationalServiceArtifacts: - serviceArtifactPlan: - displayName: Service Artifact Plan - type: OTHER - summaryOfImpactsToECOMPElements: - displayName: Summary of impacts to ECOMP elements,OSSs, BSSs - type: OTHER - controlLoopFunctions: - displayName: Control Loop Functions - type: OTHER - dimensioningInfo: - displayName: Dimensioning Info - type: OTHER - affinityRules: - displayName: Affinity Rules - type: OTHER - operationalPolicies: - displayName: Operational Policies - type: OTHER - serviceSpecificPolicies: - displayName: Service-specific Policies - type: OTHER - engineeringRules: - displayName: Engineering Rules (ERD) - type: OTHER - distributionInstructions: - displayName: Distribution Instructions - type: OTHER - certificationTestResults: - displayName: TD Certification Test Results - type: OTHER - deploymentVotingRecord: - displayName: Deployment Voting Record - type: OTHER - serviceQuestionnaire: - displayName: Service Questionnaire - type: OTHER - serviceSecurityTemplate: - displayName: Service Security Template - type: OTHER - -serviceApiArtifacts: - configuration: - displayName: Configuration - type: OTHER - instantiation: - displayName: Instantiation - type: OTHER - monitoring: - displayName: Monitoring - type: OTHER - reporting: - displayName: Reporting - type: OTHER - logging: - displayName: Logging - type: OTHER - testing: - displayName: Testing - type: OTHER - -additionalInformationMaxNumberOfKeys: 50 - -systemMonitoring: - enabled: false - isProxy: false - probeIntervalInSeconds: 15 - -heatArtifactDeploymentTimeout: - defaultMinutes: 30 - minMinutes: 1 - maxMinutes: 120 - -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - -unLoggedUrls: - - /sdc2/rest/healthCheck - -cleanComponentsConfiguration: - cleanIntervalInMinutes: 1440 - componentsToClean: - - Resource - - Service - -artifactsIndex: resources - -heatEnvArtifactHeader: "" -heatEnvArtifactFooter: "" - -onboarding: - protocol: http - host: localhost - port: 8080 - downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages" - healthCheckUri: "/onboarding-api/v1.0/healthcheck" - -dcae: - protocol: http - host: 127.0.0.1 - port: 8080 - healthCheckUri: "/dcae/healthCheck" - -switchoverDetector: - gBeFqdn: AIO-BE.ecomp.idns.cip.com - gFeFqdn: AIO-FE.ecomp.idns.cip.com - beVip: 0.0.0.0 - feVip: 0.0.0.0 - beResolveAttempts: 3 - feResolveAttempts: 3 - enabled: false - interval: 60 - changePriorityUser: ecompasdc - changePriorityPassword: ecompasdc123 - publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" - publishNetworkBody: '{"note":"publish network"}' - groups: - beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", - changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} - feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", - changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} - -applicationL1Cache: - datatypes: - enabled: true - firstRunDelay: 10 - pollIntervalInSec: 60 - -applicationL2Cache: - enabled: true - catalogL1Cache: - enabled: true - resourcesSizeInCache: 300 - servicesSizeInCache: 200 - productsSizeInCache: 100 - queue: - syncIntervalInSecondes: 43200 - waitOnShutDownInMinutes: 10 - numberOfCacheWorkers: 4 - -toscaValidators: - stringMaxLength: 2500 - -disableAudit: false - -vfModuleProperties: - min_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: 0 - max_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: - initial_count: - forBaseModule: 1 - forNonBaseModule: 0 - vf_module_type: - forBaseModule: Base - forNonBaseModule: Expansion - -genericAssetNodeTypes: - VFC: org.openecomp.resource.abstract.nodes.VFC - CVFC: org.openecomp.resource.abstract.nodes.VFC - VF : org.openecomp.resource.abstract.nodes.VF - PNF: org.openecomp.resource.abstract.nodes.PNF - Service: org.openecomp.resource.abstract.nodes.service - -workloadContext: Production -environmentContext: - defaultValue: General_Revenue-Bearing - validValues: - - Critical_Revenue-Bearing - - Vital_Revenue-Bearing - - Essential_Revenue-Bearing - - Important_Revenue-Bearing - - Needed_Revenue-Bearing - - Useful_Revenue-Bearing - - General_Revenue-Bearing - - Critical_Non-Revenue - - Vital_Non-Revenue - - Essential_Non-Revenue - - Important_Non-Revenue - - Needed_Non-Revenue - - Useful_Non-Revenue - - General_Non-Revenue - -dmaapConsumerConfiguration: - active: true - hosts: olsd004.wnsnet.com:3905 - consumerGroup: asdc - consumerId: invalidMamaUser #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.sdc.23911-SDCforTestDev-v001 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: https - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 0 - credential: - username: m09875@sdc.com - password: hmXYcznAljMSisdy8zgcag== - aftDme2SslEnable: true - aftDme2ClientIgnoreSslConfig: false - aftDme2ClientKeystore: /opt/app/jetty/base/be/config/.truststore - aftDme2ClientKeystorePassword: hmXYcznAljMSisdy8zgcag== - aftDme2ClientSslCertAlias: certman - -dmaapProducerConfiguration: - active: true - hosts: olsd004.wnsnet.attws.com:3904 - consumerGroup: asdc - consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.att.sdc.23911-msfacadesdc-v1 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: http - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 120000 - credential: - username: m09875@sdc.att.com - password: hmXYcznAljMSisdy8zgcag== -# isActive: false -# transportType: HTTPAAF -# hosts: olsd004.wnsnet.attws.com:3904 -# consumerGroup: asdc -# consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama -# limit: 1000 -# timeout: 15000 -# topic: com.att.sdc.23911-msfacadesdc-v1 -# protocol: http -# contenttype: application/json -# authKey: d8fWpPuZ3JJEs8Gf:XyQeXFoxIJZGAUaJUfx+oV6JO -# authDate: 2018-05-18T13:57:37-0800 -# dme2preferredRouterFilePath: DME2preferredRouter.txt #stub , used only cause exception is thrown without it -# credential: -# username: m09875@sdc.att.com -# password: hmXYcznAljMSisdy8zgcag== -dmeConfiguration: - lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT" - -excludedGroupTypesMapping: - CR: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - VF: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - Service: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root -healthStatusExclude: - - DE - - ES - - DMAAP - -aafNamespace: com.att.sdc - -aafAuthNeeded: true - -cadiFilterParams: - AFT_LATITUDE: "32.780140" - AFT_LONGITUDE: "-96.800451" - hostname: 192.168.33.10 - aaf_id: m09875@sdc.att.com - aaf_env: TEST - aaf_url: https://aaftest.test.att.com/locate/com.att.aaf.service:2.0 - csp_domain: PROD - cadi_keyfile: /opt/app/jetty/base/be/etc/keyfile - aaf_password: enc:uI_J4jBL4YUcIZZa5uZKj3QMUC63hbS8TmDn5PSp5nO - cadi_loglevel: DEBUG - AFT_ENVIRONMENT: AFTUAT - cadiX509Issuers: CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US - cadi_truststore: /opt/app/jetty/base/be/etc/cadi_truststore.jks - cadi_truststore_password: changeit - - +aafAuthNeeded: true \ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml new file mode 100644 index 0000000000..d1b2df7b42 --- /dev/null +++ b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml @@ -0,0 +1,8 @@ +# Errors +errors: + #---------POL5003------------------------------ + AUTH_FAILED: { + code: 403 , + message: "Error: Not authorized to use the API.", + messageId: "POL5003" + } \ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml index 64b730b046..ca7c636ff6 100644 --- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml @@ -87,31 +87,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -274,248 +249,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - PNF_SW_INFORMATION: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - PNF - unLoggedUrls: - /sdc2/rest/healthCheck @@ -746,4 +479,533 @@ cadiFilterParams: # This configuration entry lists all node type names prefix that shall be allowed on SDC. definedResourceNamespace: - - org.openecomp.resource. \ No newline at end of file + - org.openecomp.resource. + +artifacts: + - type: CONTROLLER_BLUEPRINT_ARCHIVE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - zip + - type: YANG_XML + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: UCPE_LAYER_2_CONFIGURATION + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #AAI Artifacts + - type: AAI_SERVICE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_INSTANCE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #Plan + - type: PLAN + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - xml + - type: WORKFLOW + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - xml + - type: HEAT + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_VOL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NET + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NESTED + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - zip + - tgz + - csar + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VF_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VENDOR_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: LIFECYCLE_OPERATIONS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - yaml + - yml + - type: VES_EVENTS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - yaml + - yml + - type: PERFORMANCE_COUNTER + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - csv + - type: APPC_CONFIG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - type: DCAE_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - yml + - yaml + - type: DCAE_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - json + - type: DCAE_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - emf + - type: DCAE_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: DCAE_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: AAI_VF_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: OTHER + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + acceptedTypes: + - type: SNMP_POLL + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SNMP_TRAP + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PM_DICTIONARY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: YANG_MODULE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yang + - type: ANSIBLE_PLAYBOOK + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: ONBOARDED_PACKAGE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - csar + - zip + - type: HEAT_ENV + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - env + - type: VF_MODULES_METADATA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - yml + - yaml + - type: DCAE_INVENTORY_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - emf + - type: DCAE_INVENTORY_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_BLUEPRINT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: CHEF + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PUPPET + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SHELL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: YANG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: BPEL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: DG_XML + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: MURANO_PKG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PNF_SW_INFORMATION + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - PNF + acceptedTypes: + - yaml + - yml + - type: GUIDE + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + - CVFC + - PNF + acceptedTypes: + - yaml + - yml diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index 38f2f36ae2..7d4dfa72f4 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -321,7 +321,7 @@ public abstract class Component implements PropertiesOwner { return safeGetComponentInstanceDeploymentArtifacts(componentInstanceId) .values() .stream() - .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.name().equals(artifact.getArtifactType())) + .filter(artifact -> ArtifactTypeEnum.HEAT_ENV.getType().equals(artifact.getArtifactType())) .collect(Collectors.toList()); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java index caebf4a275..ca154f3076 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/GroupInstance.java @@ -116,7 +116,7 @@ public class GroupInstance extends GroupInstanceDataDefinition { String label = artifactId.substring(artifactId.lastIndexOf('.') + 1); ArtifactDefinition artifact = deploymentArtifacts.get(label); log.debug("current artifact id: {}, current artifact definition: {}", artifactId, artifact); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); + ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(artifact.getArtifactType()); if (artifactType != ArtifactTypeEnum.HEAT_ENV){ addArtifactsIdToCollection(artifactUuids, artifact); }else{ diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java index 50c165f535..3c8e0ee5cf 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java @@ -312,7 +312,11 @@ public class ArtifactsOperations extends BaseOperation { String currentChecksum = updateArtifactData.getArtifactChecksum(); if (isUpdate) { - ArtifactTypeEnum type = ArtifactTypeEnum.findType(updateArtifactData.getArtifactType()); + final ArtifactTypeEnum type = ArtifactTypeEnum.parse(updateArtifactData.getArtifactType()); + if(type == null) { + generateUUIDForNonHeatArtifactType(updateArtifactData, oldChecksum, oldVesrion, currentChecksum); + return; + } switch (type) { case HEAT_ENV: if (edgeLabel == EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS) { @@ -384,17 +388,11 @@ public class ArtifactsOperations extends BaseOperation { return addArtifactToComponent(artifactHeatEnv, component, parentType, failIfExist, instanceId); } - public Either getHeatArtifactByHeatEnvId(String parentId, ArtifactDefinition heatEnv, NodeTypeEnum parentType, String containerId, ComponentTypeEnum componentType) { - String id = heatEnv.getGeneratedFromId(); - ComponentTypeEnum compType; - switch (parentType) { - case ResourceInstance: - compType = ComponentTypeEnum.RESOURCE_INSTANCE; - break; - default: - compType = componentType; - } - return getArtifactById(parentId, id, compType, containerId); + public Either getHeatArtifactByHeatEnvId(final String parentId, + final ArtifactDefinition heatEnv, + final String containerId, + final ComponentTypeEnum componentType) { + return getArtifactById(parentId, heatEnv.getGeneratedFromId(), componentType, containerId); } public Either updateHeatEnvArtifact(Component component, ArtifactDefinition artifactEnvInfo, String artifactId, String newArtifactId, NodeTypeEnum type, String instanceId) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java index 6ecfc1048b..33877add47 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java @@ -21,6 +21,8 @@ package org.openecomp.sdc.be.model.operations.api; import fj.data.Either; +import java.util.List; +import java.util.Map; import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; @@ -33,9 +35,6 @@ import org.openecomp.sdc.be.model.category.GroupingDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.resources.data.CategoryData; -import java.util.List; -import java.util.Map; - public interface IElementOperation { Either, ActionStatus> getAllResourceCategories(); @@ -44,21 +43,19 @@ public interface IElementOperation { Either, ActionStatus> getAllProductCategories(); - public Either, ActionStatus> getAllTags(); - - public Either, ActionStatus> getAllPropertyScopes(); + Either, ActionStatus> getAllTags(); - public Either, ActionStatus> getAllArtifactTypes(); + Either, ActionStatus> getAllPropertyScopes(); - public Either, ActionStatus> getAllDeploymentArtifactTypes(); + List getAllArtifactTypes(); - public Either getDefaultHeatTimeout(); + Either getDefaultHeatTimeout(); - public Either getCategoryData(String name, NodeTypeEnum type, Class clazz); + Either getCategoryData(String name, NodeTypeEnum type, Class clazz); - public Either getNewCategoryData(String name, NodeTypeEnum type, Class clazz); + Either getNewCategoryData(String name, NodeTypeEnum type, Class clazz); - public Either, ActionStatus> getResourceTypesMap(); + Either, ActionStatus> getResourceTypesMap(); Either createCategory(CategoryDefinition category, NodeTypeEnum nodeType); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java index 402129b8ba..9d0c7b1075 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java @@ -20,22 +20,29 @@ package org.openecomp.sdc.be.model.operations.impl; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; +import org.openecomp.sdc.be.config.ArtifactConfigManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.config.Configuration; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition; import org.openecomp.sdc.be.datatypes.category.GroupingDataDefinition; import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition; @@ -58,8 +65,6 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import java.util.*; - @Component("element-operation") public class ElementOperation implements IElementOperation { @@ -781,32 +786,13 @@ public class ElementOperation implements IElementOperation { } @Override - public Either, ActionStatus> getAllArtifactTypes() { - List artifactTypes = new ArrayList<>(); - - List artifactTypesList = ConfigurationManager.getConfigurationManager().getConfiguration().getArtifactTypes(); - for (String artifactType : artifactTypesList) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return Either.left(artifactTypes); - } - - @Override - public Either, ActionStatus> getAllDeploymentArtifactTypes() { - - Map artifactTypes = new HashMap<>(); - Map artifactResourceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); - Map artifactServiceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceDeploymentArtifacts(); - Map artifactResourceInstanceTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - - artifactTypes.put("resourceDeploymentArtifacts", artifactResourceTypes); - artifactTypes.put("serviceDeploymentArtifacts", artifactServiceTypes); - artifactTypes.put("resourceInstanceDeploymentArtifacts", artifactResourceInstanceTypes); - - return Either.left(artifactTypes); - + public List getAllArtifactTypes() { + final List artifactTypesList = ArtifactConfigManager.getInstance().getConfiguration(); + return artifactTypesList.stream().map(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + return artifactType; + }).collect(Collectors.toList()); } @Override diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java index 17e2430d82..3597d02834 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java @@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.structure.T; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; @@ -47,6 +48,7 @@ import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @@ -64,52 +66,44 @@ public class ElementOperationTest extends ModelTestBase { @BeforeClass public static void setupBeforeClass() { - // ExternalConfiguration.setAppName("catalog-model"); - // String appConfigDir = "src/test/resources/config/catalog-model"; - // ConfigurationSource configurationSource = new - // FSConfigurationSource(ExternalConfiguration.getChangeListener(), - // appConfigDir); - ModelTestBase.init(); - } @Test public void testGetArtifactsTypes() { - - List artifactTypesCfg = new ArrayList<>(); - artifactTypesCfg.add("type1"); - artifactTypesCfg.add("type2"); - artifactTypesCfg.add("type3"); - artifactTypesCfg.add("type4"); - configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg); - Either, ActionStatus> allArtifactTypes = elementOperation.getAllArtifactTypes(); - assertTrue(allArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allArtifactTypes.left().value().size()); - - artifactTypesCfg.remove(0); - allArtifactTypes = elementOperation.getAllArtifactTypes(); - assertTrue(allArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allArtifactTypes.left().value().size()); - - artifactTypesCfg.add("type5"); + final List expectedArtifactConfigurationList = new ArrayList<>(); + final ArtifactConfiguration artifactConfiguration1 = new ArtifactConfiguration(); + artifactConfiguration1.setType("type1"); + expectedArtifactConfigurationList.add(artifactConfiguration1); + final ArtifactConfiguration artifactConfiguration2 = new ArtifactConfiguration(); + artifactConfiguration2.setType("type2"); + expectedArtifactConfigurationList.add(artifactConfiguration2); + final ArtifactConfiguration artifactConfiguration3 = new ArtifactConfiguration(); + artifactConfiguration3.setType("type3"); + expectedArtifactConfigurationList.add(artifactConfiguration3); + configurationManager.getConfiguration().setArtifacts(expectedArtifactConfigurationList); + + List actualArtifactTypes = elementOperation.getAllArtifactTypes(); + assertNotNull(actualArtifactTypes); + assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size()); + boolean allMatch = actualArtifactTypes.stream().allMatch(artifactType -> + expectedArtifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName())) + ); + assertTrue(allMatch); + + expectedArtifactConfigurationList.remove(0); + actualArtifactTypes = elementOperation.getAllArtifactTypes(); + assertNotNull(actualArtifactTypes); + assertEquals(expectedArtifactConfigurationList.size(), actualArtifactTypes.size()); + + allMatch = actualArtifactTypes.stream().allMatch(artifactType -> + expectedArtifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equals(artifactType.getName())) + ); + assertTrue(allMatch); } - @Test - public void testAllDeploymentArtifactTypes() { - - List artifactTypesCfg = new ArrayList(); - artifactTypesCfg.add("type1"); - artifactTypesCfg.add("type2"); - artifactTypesCfg.add("type3"); - configurationManager.getConfiguration().setArtifactTypes(artifactTypesCfg); - Either, ActionStatus> allDeploymentArtifactTypes = elementOperation - .getAllDeploymentArtifactTypes(); - assertTrue(allDeploymentArtifactTypes.isLeft()); - assertEquals(artifactTypesCfg.size(), allDeploymentArtifactTypes.left().value().size()); - - } - // @Test public void testGetResourceAndServiceCategoty() { String id = OperationTestsUtil.deleteAndCreateResourceCategory(CATEGORY, SUBCATEGORY, janusGraphDao); @@ -431,29 +425,6 @@ public class ElementOperationTest extends ModelTestBase { testSubject = createTestSubject(); result = testSubject.getAllPropertyScopes(); } - - - @Test - public void testGetAllArtifactTypes() throws Exception { - ElementOperation testSubject; - Either, ActionStatus> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAllArtifactTypes(); - } - - - @Test - public void testGetAllDeploymentArtifactTypes() throws Exception { - ElementOperation testSubject; - Either, ActionStatus> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAllDeploymentArtifactTypes(); - } - @Test public void testGetResourceTypesMap() throws Exception { @@ -465,7 +436,6 @@ public class ElementOperationTest extends ModelTestBase { result = testSubject.getResourceTypesMap(); } - @Test public void testGetNewCategoryData() throws Exception { ElementOperation testSubject; diff --git a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml index 052add6a28..8f7f0f8cf8 100644 --- a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml +++ b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml @@ -86,31 +86,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -273,256 +248,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - unLoggedUrls: - /sdc2/rest/healthCheck diff --git a/catalog-model/src/test/resources/config/configuration.yaml b/catalog-model/src/test/resources/config/configuration.yaml index adf065ca41..8f7f0f8cf8 100644 --- a/catalog-model/src/test/resources/config/configuration.yaml +++ b/catalog-model/src/test/resources/config/configuration.yaml @@ -86,31 +86,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -273,248 +248,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - unLoggedUrls: - /sdc2/rest/healthCheck diff --git a/catalog-ui/src/app/ng2/app.module.ts b/catalog-ui/src/app/ng2/app.module.ts index 3f43feb7b2..b3c12a5f11 100644 --- a/catalog-ui/src/app/ng2/app.module.ts +++ b/catalog-ui/src/app/ng2/app.module.ts @@ -72,6 +72,7 @@ import { AutomatedUpgradeModule } from './pages/automated-upgrade/automated-upgr import {WorkspaceModule} from './pages/workspace/workspace.module'; import { ModalsModule } from './components/modals/modals.module'; import { SharingService, CacheService, HomeService } from 'app/services-ng2'; +import { ArtifactConfigService } from "./services/artifact-config.service"; import { IUserProperties } from 'app/models'; import { PluginsModule } from './pages/plugins/plugins-module'; import {WorkspaceNg1BridgeService} from './pages/workspace/workspace-ng1-bridge-service'; @@ -173,6 +174,7 @@ export function configServiceFactory(config: ConfigService, authService: Authent SharingService, CacheService, HomeService, + ArtifactConfigService, ComponentFactoryProvider, CookieServiceProvider, StateServiceFactory, diff --git a/catalog-ui/src/app/ng2/components/forms/artifacts-form/__snapshots__/artifact-form.component.spec.ts.snap b/catalog-ui/src/app/ng2/components/forms/artifacts-form/__snapshots__/artifact-form.component.spec.ts.snap index 8cd085e248..440dc74d72 100644 --- a/catalog-ui/src/app/ng2/components/forms/artifacts-form/__snapshots__/artifact-form.component.spec.ts.snap +++ b/catalog-ui/src/app/ng2/components/forms/artifacts-form/__snapshots__/artifact-form.component.spec.ts.snap @@ -2,6 +2,7 @@ exports[`artifact form component should match current snapshot of artifact form component 1`] = ` { let fixture: ComponentFixture; let cacheServiceMock: Partial; + let artifactConfigService: Partial; let onValidationChangeMock: Partial>; let artifactModel = new ArtifactModel(); + artifactConfigService = { + findAllTypeBy: jest.fn() + }; beforeEach( async(() => { onValidationChangeMock = { next: jest.fn() - } + }; cacheServiceMock = { contains: jest.fn(), remove: jest.fn(), set: jest.fn(), get: jest.fn() - } + }; const configure: ConfigureFn = testBed => { testBed.configureTestingModule({ @@ -41,6 +46,7 @@ describe('artifact form component', () => { schemas: [NO_ERRORS_SCHEMA], providers: [ {provide: CacheService, useValue: cacheServiceMock}, + {provide: ArtifactConfigService, useValue: artifactConfigService}, {provide: TranslateService, useValue: {}} ], }); @@ -55,91 +61,73 @@ describe('artifact form component', () => { it('should verify initArtifactTypes for DEPLOYMENT and ArtifactType = HEAT_ENV', () =>{ - cacheServiceMock.get.mockImplementation(() =>{ - return { - artifacts: { - deployment:{ - resourceInstanceDeploymentArtifacts: [{name: "Dummy Value Returned from ui api"}], - } - } + artifactConfigService.findAllTypeBy.mockImplementation((artifactType, componentType, resourceType) => { + if (artifactType == 'DEPLOYMENT' && componentType == ComponentType.RESOURCE_INSTANCE && resourceType == 'VF') { + return ['Val1', 'Val2', 'Val3', ArtifactType.HEAT_ENV]; } }); fixture.componentInstance.artifactType = 'DEPLOYMENT'; + fixture.componentInstance.resourceType = 'VF'; fixture.componentInstance.artifact = artifactModel; - fixture.componentInstance.artifact.artifactType = 'HEAT_ENV'; + fixture.componentInstance.artifact.artifactType = ArtifactType.HEAT_ENV; fixture.componentInstance.initArtifactTypes(); - expect(fixture.componentInstance.selectedFileType).toEqual(undefined); + expect(fixture.componentInstance.selectedFileType).toEqual({"label": ArtifactType.HEAT_ENV, "value": ArtifactType.HEAT_ENV}); }); - it('should verify initArtifactTypes for DEPLOYMENT and ComponentType = RESOURCE', () =>{ + it('should verify initArtifactTypes for DEPLOYMENT and ComponentType = RESOURCE', () => { - cacheServiceMock.get.mockImplementation(() =>{ - return { - artifacts: { - deployment:{ - resourceDeploymentArtifacts: [{name: "Dummy Value Returned from ui api"}], - } - } + const expectedSelectedValue = 'Val3'; + const artifactType = 'DEPLOYMENT'; + const resourceType = 'VF'; + artifactConfigService.findAllTypeBy.mockImplementation((artifactType1, componentType1, resourceType1) => { + if (artifactType1 == artifactType && componentType1 == ComponentType.RESOURCE && resourceType1 == resourceType) { + return ['Val1', 'Val2', expectedSelectedValue, 'Val4']; } - }); - - fixture.componentInstance.artifactType = 'DEPLOYMENT'; - fixture.componentInstance.artifact = artifactModel; - fixture.componentInstance.componentType = 'RESOURCE'; - - fixture.componentInstance.initArtifactTypes(); - - expect(fixture.componentInstance.selectedFileType).toEqual(undefined); - - }); - - it('should verify initArtifactTypes for DEPLOYMENT and NOT ComponentType = RESOURCE OR NOT ArtifactType = HEAT_ENV', () =>{ - cacheServiceMock.get.mockImplementation(() =>{ - return { - artifacts: { - deployment:{ - serviceDeploymentArtifacts: [{name: "Dummy Value Returned from ui api"}], - } - } - } + return []; }); - fixture.componentInstance.artifactType = 'DEPLOYMENT'; + fixture.componentInstance.artifactType = artifactType; fixture.componentInstance.artifact = artifactModel; - // fixture.componentInstance.componentType = 'RESOURCE'; + fixture.componentInstance.resourceType = resourceType; + fixture.componentInstance.componentType = ComponentType.RESOURCE; + fixture.componentInstance.artifact.artifactType = expectedSelectedValue; fixture.componentInstance.initArtifactTypes(); - expect(fixture.componentInstance.selectedFileType).toEqual(undefined); + expect(fixture.componentInstance.selectedFileType).toEqual({'label': expectedSelectedValue, 'value': expectedSelectedValue}); }); - it('should verify initArtifactTypes for INFORMATION', () =>{ + it('should verify initArtifactTypes for INFORMATIONAL', () => { - cacheServiceMock.get.mockImplementation(() =>{ - return { - artifacts: { - other: [{name: "Val1"}, {name: "ExpectedValToBeSelected"}, {name: "Val3"}] - } + const expectedSelectedValue = 'Val3'; + const artifactType = 'INFORMATIONAL'; + const resourceType = null; + artifactConfigService.findAllTypeBy.mockImplementation((artifactType1, componentType1, resourceType1) => { + if (artifactType1 == artifactType && componentType1 == ComponentType.SERVICE && resourceType1 == resourceType) { + return ['Val1', 'Val2', expectedSelectedValue, 'Val4']; } + + return []; }); - fixture.componentInstance.artifactType = 'INFORMATIONAL'; + fixture.componentInstance.artifactType = artifactType; fixture.componentInstance.artifact = artifactModel; - fixture.componentInstance.artifact.artifactType = 'ExpectedValToBeSelected'; + fixture.componentInstance.resourceType = resourceType; + fixture.componentInstance.componentType = ComponentType.SERVICE; + fixture.componentInstance.artifact.artifactType = expectedSelectedValue; fixture.componentInstance.initArtifactTypes(); - expect(fixture.componentInstance.selectedFileType).toEqual({"label": "ExpectedValToBeSelected", "value": "ExpectedValToBeSelected"}); + expect(fixture.componentInstance.selectedFileType).toEqual({'label': expectedSelectedValue, 'value': expectedSelectedValue}); }); - it('should match current snapshot of artifact form component', () => { expect(fixture).toMatchSnapshot(); }); @@ -147,7 +135,7 @@ describe('artifact form component', () => { it('should verify onUploadFile -> file gets file name', () => { let file = { filename:'dummyFileName' - } + }; fixture.componentInstance.verifyTypeAndFileWereFilled = jest.fn(); fixture.componentInstance.artifact = artifactModel; diff --git a/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifact-form.component.ts b/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifact-form.component.ts index 905d1a25ad..f7dbf09e3f 100644 --- a/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifact-form.component.ts +++ b/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifact-form.component.ts @@ -9,6 +9,7 @@ import { ArtifactModel } from '../../../../models'; import { ArtifactType, ComponentType } from '../../../../utils'; import { Dictionary } from '../../../../utils/dictionary/dictionary'; import { CacheService } from '../../../services/cache.service'; +import { ArtifactConfigService } from '../../../services/artifact-config.service'; @Component({ selector: 'artifact-form', @@ -20,6 +21,7 @@ export class ArtifactFormComponent { @Input() artifact: ArtifactModel; @Input() artifactType: ArtifactType; @Input() componentType: string; + @Input() resourceType: string; @Input() instanceId: string; @Input() isViewOnly: boolean; @@ -31,7 +33,8 @@ export class ArtifactFormComponent { private descriptionIsValid: boolean; private labelIsValid: boolean; - constructor(private cacheService: CacheService) { + constructor(private cacheService: CacheService, + private artifactConfigService: ArtifactConfigService) { } ngOnInit(): void { @@ -44,7 +47,7 @@ export class ArtifactFormComponent { public onTypeChange = (selectedFileType: IDropDownOption) => { this.artifact.artifactType = selectedFileType.value; this.verifyTypeAndFileWereFilled(); - } + }; public onUploadFile = (file) => { if (file) { @@ -55,34 +58,24 @@ export class ArtifactFormComponent { this.artifact.artifactName = null; } this.verifyTypeAndFileWereFilled(); - } + }; private initArtifactTypes = (): void => { - const artifactTypes: any = this.cacheService.get('UIConfiguration'); - let validExtensions: string[]; let artifactTypesList: string[]; - switch (this.artifactType) { case ArtifactType.DEPLOYMENT: if (this.artifact.artifactType === ArtifactType.HEAT_ENV || this.instanceId) { - validExtensions = artifactTypes.artifacts.deployment.resourceInstanceDeploymentArtifacts; - } else if (this.componentType === ComponentType.RESOURCE) { - validExtensions = artifactTypes.artifacts.deployment.resourceDeploymentArtifacts; + artifactTypesList = this.artifactConfigService.findAllTypeBy(this.artifactType, ComponentType.RESOURCE_INSTANCE, this.resourceType); } else { - validExtensions = artifactTypes.artifacts.deployment.serviceDeploymentArtifacts; - } - if (validExtensions) { - artifactTypesList = Object.keys(validExtensions); + artifactTypesList = this.artifactConfigService.findAllTypeBy(this.artifactType, this.componentType, this.resourceType); } break; case ArtifactType.INFORMATION: - artifactTypesList = artifactTypes.artifacts.other.map((element: any) => { - return element.name; - }); - _.remove(artifactTypesList, (item: string) => { - return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, item) || - _.has(ArtifactType.TOSCA, item); - }); + if (this.instanceId) { + artifactTypesList = this.artifactConfigService.findAllTypeBy(this.artifactType, ComponentType.RESOURCE_INSTANCE, this.resourceType); + } else { + artifactTypesList = this.artifactConfigService.findAllTypeBy(this.artifactType, this.componentType, this.resourceType); + } break; } @@ -94,7 +87,7 @@ export class ArtifactFormComponent { return artifactType.value === this.artifact.artifactType; }); - } + }; // Verify that the Type and the Name (file) are filled in the Modal // For Description and Label - I used this.descriptionIsValid:boolean & this.labelIsValid:boolean as part of the sdc-validation Element @@ -116,17 +109,17 @@ export class ArtifactFormComponent { this.onValidationChange.next(false); } } - } + }; // sdc-validation for Description private onDescriptionChange = (isValid: boolean): void => { this.descriptionIsValid = isValid; this.onValidationChange.next(isValid) && this.verifyTypeAndFileWereFilled(); - } + }; // sdc-validation for Label private onLabelChange = (isValid: boolean): void => { this.labelIsValid = isValid; this.onValidationChange.next(isValid) && this.verifyTypeAndFileWereFilled(); - } + }; } diff --git a/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifacts.service.ts b/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifacts.service.ts index f9400e9d18..ead85a6afa 100644 --- a/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifacts.service.ts +++ b/catalog-ui/src/app/ng2/components/forms/artifacts-form/artifacts.service.ts @@ -25,12 +25,13 @@ export class ArtifactsService { private store: Store) { } - public dispatchArtifactAction = (componentId: string, componentType: string, artifact: ArtifactModel, artifactType: ArtifactGroupType, instanceId: string) => { + public dispatchArtifactAction = (componentId: string, componentType: string, artifact: ArtifactModel, artifactType: ArtifactGroupType, instanceId: string, resourceType?: string) => { const artifactObj = { componentType, componentId, instanceId, - artifact + artifact, + resourceType }; // Create or update instance artifact @@ -48,14 +49,14 @@ export class ArtifactsService { } } - public openArtifactModal = (componentId: string, componentType: string, artifact: ArtifactModel, artifactType: ArtifactGroupType, isViewOnly?: boolean, instanceId?: string) => { + public openArtifactModal = (componentId: string, componentType: string, artifact: ArtifactModel, artifactType: ArtifactGroupType, isViewOnly?: boolean, instanceId?: string, resourceType?: string) => { let modalInstance; const onOkPressed = () => { const updatedArtifact = modalInstance.innerModalContent.instance.artifact; this.serviceLoader.activate(); - this.dispatchArtifactAction(componentId, componentType, updatedArtifact, artifactType, instanceId) + this.dispatchArtifactAction(componentId, componentType, updatedArtifact, artifactType, instanceId, resourceType) .subscribe().add(() => this.serviceLoader.deactivate()); }; @@ -82,6 +83,7 @@ export class ArtifactsService { artifactType, instanceId, componentType, + resourceType: resourceType, isViewOnly }); diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifact-tab.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifact-tab.component.spec.ts index 258f2295ab..9df3e38eb2 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifact-tab.component.spec.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifact-tab.component.spec.ts @@ -220,7 +220,7 @@ describe('artifact-tab component', () => { fixture.componentInstance.addOrUpdate(artifact); - expect(artifactsServiceMockService.openArtifactModal).toHaveBeenCalledWith(topologyTemplateId, topologyTemplateType, artifact, type, isViewOnly, component.uniqueId); + expect(artifactsServiceMockService.openArtifactModal).toHaveBeenCalledWith(topologyTemplateId, topologyTemplateType, artifact, type, isViewOnly, component.uniqueId, undefined); }); it ('on addOrUpdate -> openArtifactModal is being called from artifactService when isComponentInstanceSelected = false', () => { diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifacts-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifacts-tab.component.ts index 53a6c267e2..91664ce8e8 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifacts-tab.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/artifacts-tab/artifacts-tab.component.ts @@ -64,7 +64,7 @@ export class ArtifactsTabComponent { public addOrUpdate = (artifact: ArtifactModel): void => { if (this.isComponentInstanceSelected) { - this.artifactService.openArtifactModal(this.topologyTemplateId, this.topologyTemplateType, artifact, this.type, this.isViewOnly, this.component.uniqueId); + this.artifactService.openArtifactModal(this.topologyTemplateId, this.topologyTemplateType, artifact, this.type, this.isViewOnly, this.component.uniqueId, this.resourceType); } else { this.artifactService.openArtifactModal(this.topologyTemplateId, this.topologyTemplateType, artifact, this.type, this.isViewOnly); } diff --git a/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.html b/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.html index 1df318e4a5..3ed2173b15 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.html +++ b/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.html @@ -16,11 +16,16 @@
{{row.artifactDisplayName}} - + + + + {{row.artifactName}} + + {{row.artifactType}} diff --git a/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.ts b/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.ts index 53b21b34b6..ec30cd15aa 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.ts +++ b/catalog-ui/src/app/ng2/pages/workspace/deployment-artifacts/deployment-artifacts-page.component.ts @@ -1,23 +1,22 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; -import { Select, Store } from '@ngxs/store'; -import { ArtifactModel } from 'app/models'; +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Select, Store} from '@ngxs/store'; +import {ArtifactModel} from 'app/models'; import * as _ from 'lodash'; -import { SdcUiCommon, SdcUiComponents, SdcUiServices } from 'onap-ui-angular'; -import { Observable } from 'rxjs/index'; -import { map } from 'rxjs/operators'; -import { GabConfig } from '../../../../models/gab-config'; -import { PathsAndNamesDefinition } from '../../../../models/paths-and-names'; -import { GenericArtifactBrowserComponent } from '../../../../ng2/components/logic/generic-artifact-browser/generic-artifact-browser.component'; -import { ArtifactGroupType, ArtifactType } from '../../../../utils/constants'; -import { ArtifactsService } from '../../../components/forms/artifacts-form/artifacts.service'; -import { PopoverContentComponent } from '../../../components/ui/popover/popover-content.component'; -import { CacheService } from '../../../services/cache.service'; -import { TranslateService } from '../../../shared/translator/translate.service'; -import { GetArtifactsByTypeAction } from '../../../store/actions/artifacts.action'; -import { ArtifactsState } from '../../../store/states/artifacts.state'; -import { WorkspaceState, WorkspaceStateModel } from '../../../store/states/workspace.state'; -import { WorkspaceService } from '../workspace.service'; -import { ModalService } from 'app/ng2/services/modal.service'; +import {SdcUiCommon, SdcUiServices} from 'onap-ui-angular'; +import {Observable} from 'rxjs'; +import {map} from 'rxjs/operators'; +import {GabConfig} from '../../../../models/gab-config'; +import {PathsAndNamesDefinition} from '../../../../models/paths-and-names'; +import {GenericArtifactBrowserComponent} from '../../../components/logic/generic-artifact-browser/generic-artifact-browser.component'; +import {ArtifactGroupType, ArtifactType} from '../../../../utils/constants'; +import {ArtifactsService} from '../../../components/forms/artifacts-form/artifacts.service'; +import {PopoverContentComponent} from '../../../components/ui/popover/popover-content.component'; +import {CacheService} from '../../../services/cache.service'; +import {TranslateService} from '../../../shared/translator/translate.service'; +import {GetArtifactsByTypeAction} from '../../../store/actions/artifacts.action'; +import {ArtifactsState} from '../../../store/states/artifacts.state'; +import {WorkspaceState, WorkspaceStateModel} from '../../../store/states/workspace.state'; +import {WorkspaceService} from '../workspace.service'; export interface IPoint { x: number; @@ -33,6 +32,7 @@ export class DeploymentArtifactsPageComponent implements OnInit { public componentId: string; public componentType: string; + public resourceType: string; public deploymentArtifacts$: Observable; public isComponentInstanceSelected: boolean; @@ -68,11 +68,12 @@ export class DeploymentArtifactsPageComponent implements OnInit { } }); return sortedArtifacts; - }) + }); ngOnInit(): void { this.componentId = this.workspaceService.metadata.uniqueId; this.componentType = this.workspaceService.metadata.componentType; + this.resourceType = this.workspaceService.metadata.resourceType; this.store.dispatch(new GetArtifactsByTypeAction({ componentType: this.componentType, @@ -91,8 +92,8 @@ export class DeploymentArtifactsPageComponent implements OnInit { } public addOrUpdateArtifact = (artifact: ArtifactModel, isViewOnly: boolean) => { - this.artifactsService.openArtifactModal(this.componentId, this.componentType, artifact, ArtifactGroupType.DEPLOYMENT, isViewOnly); - } + this.artifactsService.openArtifactModal(this.componentId, this.componentType, artifact, ArtifactGroupType.DEPLOYMENT, isViewOnly, null, this.resourceType); + }; public deleteArtifact = (artifactToDelete) => { this.artifactsService.deleteArtifact(this.componentType, this.componentId, artifactToDelete); diff --git a/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.html b/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.html index cff33258ae..b1f610a653 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.html +++ b/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.html @@ -28,6 +28,11 @@ + + + {{row.artifactName}} + + {{row.artifactType}} diff --git a/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.ts b/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.ts index a6804a43c6..981e00bf40 100644 --- a/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.ts +++ b/catalog-ui/src/app/ng2/pages/workspace/information-artifact/information-artifact-page.component.ts @@ -1,13 +1,11 @@ import {Component, OnInit, ViewChild} from "@angular/core"; import {WorkspaceService} from "../workspace.service"; -import {SdcUiCommon, SdcUiComponents, SdcUiServices} from "onap-ui-angular"; -import {TopologyTemplateService} from "../../../services/component-services/topology-template.service"; import * as _ from "lodash"; import {ArtifactGroupType, ArtifactType} from "../../../../utils/constants"; import {ArtifactsService} from "../../../components/forms/artifacts-form/artifacts.service"; -import {DeleteArtifactAction, GetArtifactsByTypeAction} from "../../../store/actions/artifacts.action"; +import {GetArtifactsByTypeAction} from "../../../store/actions/artifacts.action"; import {Select, Store} from "@ngxs/store"; -import {Observable} from "rxjs/index"; +import {Observable} from "rxjs"; import {ArtifactsState} from "../../../store/states/artifacts.state"; import {map} from "rxjs/operators"; import {WorkspaceState} from "../../../store/states/workspace.state"; @@ -22,6 +20,7 @@ export class InformationArtifactPageComponent implements OnInit { public componentId: string; public componentType: string; + public resourceType: string; public informationArtifacts$: Observable; public informationArtifactsAsButtons$: Observable; @Select(WorkspaceState.isViewOnly) isViewOnly$: boolean; @@ -35,6 +34,7 @@ export class InformationArtifactPageComponent implements OnInit { ngOnInit(): void { this.componentId = this.workspaceService.metadata.uniqueId; this.componentType = this.workspaceService.metadata.componentType; + this.resourceType = this.workspaceService.metadata.resourceType; this.store.dispatch(new GetArtifactsByTypeAction({ componentType: this.componentType, @@ -59,11 +59,11 @@ export class InformationArtifactPageComponent implements OnInit { } public addOrUpdateArtifact = (artifact: ArtifactModel, isViewOnly?: boolean) => { - this.artifactsService.openArtifactModal(this.componentId, this.componentType, artifact, ArtifactGroupType.INFORMATION, isViewOnly); - } + this.artifactsService.openArtifactModal(this.componentId, this.componentType, artifact, ArtifactGroupType.INFORMATION, isViewOnly, null, this.resourceType); + }; public deleteArtifact = (artifactToDelete) => { this.artifactsService.deleteArtifact(this.componentType, this.componentId, artifactToDelete) - } + }; } \ No newline at end of file diff --git a/catalog-ui/src/app/ng2/services/artifact-config.service.spec.ts b/catalog-ui/src/app/ng2/services/artifact-config.service.spec.ts new file mode 100644 index 0000000000..bbbd387b4e --- /dev/null +++ b/catalog-ui/src/app/ng2/services/artifact-config.service.spec.ts @@ -0,0 +1,23 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { ArtifactConfigService } from './artifact-config.service'; +import {CacheService} from "./cache.service"; + +describe('ArtifactConfigService', () => { + beforeEach(() => { + const cacheServiceMock = { + get: jest.fn(() => { + return { + artifact: null + } + }) + }; + TestBed.configureTestingModule({ + providers: [ArtifactConfigService, {provide: CacheService, useValue: cacheServiceMock}] + }); + }); + + it('should be created', inject([ArtifactConfigService], (service: ArtifactConfigService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/catalog-ui/src/app/ng2/services/artifact-config.service.ts b/catalog-ui/src/app/ng2/services/artifact-config.service.ts new file mode 100644 index 0000000000..e3f914fa29 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/artifact-config.service.ts @@ -0,0 +1,50 @@ +import {Injectable} from '@angular/core'; +import {CacheService} from './cache.service'; +import {ArtifactType} from "../../utils/constants"; + +@Injectable() +export class ArtifactConfigService { + + artifactConfigList:Array; + + constructor(private cacheService: CacheService) { + const uiConfiguration = cacheService.get('UIConfiguration'); + this.artifactConfigList = uiConfiguration.artifact; + } + + public getConfig() { + return this.artifactConfigList; + } + + public findAllBy(artifactType?:ArtifactType, componentType?:string, resourceType?:string):Array { + return this.artifactConfigList.filter((artifactConfig:any) => { + let hasCategory = true; + if (artifactType) { + hasCategory = artifactConfig.categories && artifactConfig.categories.some(value => value == artifactType); + } + let hasComponentType = true; + if (componentType) { + hasComponentType = artifactConfig.componentTypes && artifactConfig.componentTypes.some(value => value == componentType); + } + let hasResourceType = true; + //resourceTypes are not restrictive, if it was not configured all resources are accepted. + if (resourceType && artifactConfig.resourceTypes) { + hasResourceType = artifactConfig.resourceTypes.some(value => value == resourceType); + } + return hasCategory && hasComponentType && hasResourceType; + }); + } + + + public findAllTypeBy(artifactType?:ArtifactType, componentType?:string, resourceType?:string):Array { + const artifactConfigList = this.findAllBy(artifactType, componentType, resourceType); + if (artifactConfigList) { + return artifactConfigList.map((element: any) => { + return element.type; + }); + } + + return []; + } + +} diff --git a/catalog-ui/src/app/ng2/store/actions/instance-artifacts.actions.ts b/catalog-ui/src/app/ng2/store/actions/instance-artifacts.actions.ts index 0f1df78352..d762b171ce 100644 --- a/catalog-ui/src/app/ng2/store/actions/instance-artifacts.actions.ts +++ b/catalog-ui/src/app/ng2/store/actions/instance-artifacts.actions.ts @@ -13,14 +13,14 @@ export class GetInstanceArtifactsByTypeAction { export class CreateInstanceArtifactAction { static readonly type = '[INSTANCE_ARTIFACTS] CreateInstanceArtifactAction'; - constructor(public payload: { componentType: string, componentId: string, instanceId: string, artifact: ArtifactModel }) { + constructor(public payload: { componentType: string, componentId: string, instanceId: string, artifact: ArtifactModel, resourceType: string }) { } } export class UpdateInstanceArtifactAction { static readonly type = '[INSTANCE_ARTIFACTS] UpdateInstanceArtifactAction'; - constructor(public payload: { componentType: string, componentId: string, instanceId: string, artifact: ArtifactModel }) { + constructor(public payload: { componentType: string, componentId: string, instanceId: string, artifact: ArtifactModel, resourceType: string }) { } } diff --git a/catalog-ui/src/app/utils/constants.ts b/catalog-ui/src/app/utils/constants.ts index 738b4d1366..f2efc42e44 100644 --- a/catalog-ui/src/app/utils/constants.ts +++ b/catalog-ui/src/app/utils/constants.ts @@ -37,6 +37,7 @@ export class GeneralStatus { export class ComponentType { static SERVICE = 'SERVICE'; static RESOURCE = 'RESOURCE'; + static RESOURCE_INSTANCE = 'RESOURCE_INSTANCE'; static SERVICE_PROXY = 'ServiceProxy' } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfigManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfigManager.java new file mode 100644 index 0000000000..e3327cc696 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfigManager.java @@ -0,0 +1,138 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.config; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; + +/** + * Singleton that manages the artifact type configuration + */ +public class ArtifactConfigManager { + + public static final ArtifactConfigManager INSTANCE = new ArtifactConfigManager(); + + private ArtifactConfigManager() { + + } + + public static ArtifactConfigManager getInstance() { + return INSTANCE; + } + + /** + * Find an artifact configuration by artifact type. + * + * @param type the artifact type + * @return the artifact configuration if the type exists + */ + public Optional find(final String type) { + final List artifactConfigurationList = getConfiguration(); + return artifactConfigurationList.stream() + .filter(artifactConfiguration -> artifactConfiguration.getType().equals(type)) + .findFirst(); + } + + /** + * Find an artifact configuration by artifact type, that supports the artifact category/group and component type. + * + * @param type the artifact type + * @param artifactGroup the artifact category/group + * @param componentType the component type + * @return the artifact configuration if it matches the provided filter + */ + public Optional find(final String type, final ArtifactGroupTypeEnum artifactGroup, + final ComponentType componentType) { + final ArtifactConfiguration artifactConfiguration = find(type).orElse(null); + if (artifactConfiguration == null) { + return Optional.empty(); + } + + final boolean hasCategory = artifactConfiguration.hasSupport(artifactGroup); + if (!hasCategory) { + return Optional.empty(); + } + final boolean hasComponentType = artifactConfiguration.hasSupport(componentType); + if (!hasComponentType) { + return Optional.empty(); + } + + return Optional.of(artifactConfiguration); + } + + /** + * Find all artifact configuration that supports an artifact category/group and a component type. + * + * @param artifactGroup the artifact group/category + * @param componentType the component type + * @return the artifact configurations that matches the filter + */ + public List findAll(final ArtifactGroupTypeEnum artifactGroup, + final ComponentType componentType) { + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + + return artifactConfigurationList.stream() + .filter(artifactConfiguration1 -> + artifactConfiguration1.hasSupport(artifactGroup) && artifactConfiguration1.hasSupport(componentType)) + .collect(Collectors.toList()); + } + + /** + * Find all artifact configuration that supports an artifact category/group. + * + * @param artifactGroup the artifact category/group + * @return the artifact configurations that matches the filter + */ + public List findAll(final ArtifactGroupTypeEnum artifactGroup) { + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + + return artifactConfigurationList.stream() + .filter(artifactConfiguration1 -> artifactConfiguration1.hasSupport(artifactGroup)) + .collect(Collectors.toList()); + } + + /** + * Find all artifact configuration that supports a component type. + * + * @param componentType the component type + * @return the artifact configurations that matches the filter + */ + public List findAll(final ComponentType componentType) { + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + + return artifactConfigurationList.stream() + .filter(artifactConfiguration1 -> artifactConfiguration1.hasSupport(componentType)) + .collect(Collectors.toList()); + } + + /** + * Gets the artifact configuration list. + * + * @return the artifact configuration list. + */ + public List getConfiguration() { + return ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfiguration.java new file mode 100644 index 0000000000..1656b4abb1 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ArtifactConfiguration.java @@ -0,0 +1,68 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.config; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.apache.commons.collections.CollectionUtils; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; + +/** + * Represents an artifact type configuration + */ +@Getter +@Setter +@ToString +public class ArtifactConfiguration { + + private String type; + private List categories; + private List componentTypes; + private List acceptedTypes; + private List resourceTypes; + + /** + * Checks if the configuration supports a component type. + * + * @param componentType the component type + * @return {@code true} if the component type is supported, {@code false} otherwise + */ + public boolean hasSupport(final ComponentType componentType) { + if (CollectionUtils.isEmpty(componentTypes)) { + return false; + } + return componentTypes.contains(componentType); + } + + /** + * Checks if the configuration supports an artifact group/category. + * + * @param groupType the artifact category/group type + * @return {@code true} if the artifact group/category is supported, {@code false} otherwise + */ + public boolean hasSupport(final ArtifactGroupTypeEnum groupType) { + if (CollectionUtils.isEmpty(categories)) { + return false; + } + return categories.contains(groupType); + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ComponentType.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ComponentType.java new file mode 100644 index 0000000000..2f28687620 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ComponentType.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.config; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ComponentType { + + RESOURCE("Resource"), + SERVICE("Service"), + RESOURCE_INSTANCE("Resource Instance"), + SERVICE_INSTANCE("Service Instance"); + + private final String value; + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java index 0bc0707822..f9f4bc14ae 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java @@ -20,16 +20,15 @@ package org.openecomp.sdc.be.config; -import org.apache.commons.collections.map.CaseInsensitiveMap; -import org.openecomp.sdc.common.api.BasicConfiguration; +import static java.lang.String.format; +import static java.util.Collections.emptyMap; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; - -import static java.lang.String.format; -import static java.util.Collections.emptyMap; +import org.apache.commons.collections.map.CaseInsensitiveMap; +import org.openecomp.sdc.common.api.BasicConfiguration; public class Configuration extends BasicConfiguration { @@ -91,14 +90,9 @@ public class Configuration extends BasicConfiguration { private Map toscaArtifacts; private Map informationalResourceArtifacts; private Map informationalServiceArtifacts; - private Map resourceDeploymentArtifacts; - private Map serviceDeploymentArtifacts; - private Map resourceInstanceDeploymentArtifacts; - private Map resourceInformationalArtifacts; private Map serviceApiArtifacts; private List excludeServiceCategory; - private List artifactTypes; private List licenseTypes; private List definedResourceNamespace; @@ -161,6 +155,15 @@ public class Configuration extends BasicConfiguration { private EnvironmentContext environmentContext; private List gabConfig; private EcompPortalConfig ecompPortal; + private List artifacts; + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } public String getAutoHealingOwner() { return autoHealingOwner; @@ -437,14 +440,6 @@ public class Configuration extends BasicConfiguration { this.janusGraphReconnectIntervalInSeconds = janusGraphReconnectIntervalInSeconds; } - public List getArtifactTypes() { - return artifactTypes; - } - - public void setArtifactTypes(List artifactTypes) { - this.artifactTypes = artifactTypes; - } - public List getExcludeResourceCategory() { return excludeResourceCategory; } @@ -509,31 +504,6 @@ public class Configuration extends BasicConfiguration { this.serviceApiArtifacts = serviceApiArtifacts; } - public Map getServiceDeploymentArtifacts() { - return serviceDeploymentArtifacts; - } - - public void setServiceDeploymentArtifacts(Map serviceDeploymentArtifacts) { - this.serviceDeploymentArtifacts = serviceDeploymentArtifacts; - } - - public Map getResourceDeploymentArtifacts() { - return resourceDeploymentArtifacts; - } - - public void setResourceDeploymentArtifacts(Map resourceDeploymentArtifacts) { - this.resourceDeploymentArtifacts = resourceDeploymentArtifacts; - } - - public void setResourceInstanceDeploymentArtifacts( - Map resourceInstanceDeploymentArtifacts) { - this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts; - } - - public Map getResourceInstanceDeploymentArtifacts() { - return resourceInstanceDeploymentArtifacts; - } - public List getExcludeServiceCategory() { return excludeServiceCategory; } @@ -1529,7 +1499,7 @@ public class Configuration extends BasicConfiguration { .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts)) .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts)) .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts)) - .append(format("Supported artifacts types: %s%n", artifactTypes)) + .append(format("Supported artifacts types: %s%n", artifacts)) .append(format("Supported license types: %s%n", licenseTypes)) .append(format("Additional information Maximum number of preoperties: %s%n", additionalInformationMaxNumberOfKeys)) @@ -1653,14 +1623,6 @@ public class Configuration extends BasicConfiguration { this.disableAudit = enableAudit; } - public Map getResourceInformationalArtifacts() { - return resourceInformationalArtifacts; - } - - public void setResourceInformationalArtifacts(Map resourceInformationalArtifacts) { - this.resourceInformationalArtifacts = resourceInformationalArtifacts; - } - public Map getVfModuleProperties() { return vfModuleProperties; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java index 9d0ff1c083..affa2d32e0 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,50 +20,69 @@ package org.openecomp.sdc.common.api; -import java.util.ArrayList; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; /** - * Enum That Represents possible Artifacts Types. - * + * Represents an artifact type that is used for hard-coded type representation. All artifacts must be configured in the + * SDC configuration file. */ @Getter @AllArgsConstructor public enum ArtifactTypeEnum { - CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), SHELL("SHELL"), ICON("ICON"), UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), HEAT_ENV("HEAT_ENV"), YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), - HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"), NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), BPEL("BPEL"), - VENDOR_LICENSE("VENDOR_LICENSE"), MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), HEAT_ARTIFACT("HEAT_ARTIFACT"), CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"), - VF_MODULES_METADATA("VF_MODULES_METADATA"), LIFECYCLE_OPERATIONS("LIFECYCLE_OPERATIONS"), VES_EVENTS("VES_EVENTS"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"),UCPE_LAYER_2_CONFIGURATION("UCPE_LAYER_2_CONFIGURATION"), - CONTROLLER_BLUEPRINT_ARCHIVE("CONTROLLER_BLUEPRINT_ARCHIVE"), - // DCAE Artifacts - DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), - DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), - // AAI Artifacts - AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), - // MIB artifacts - SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE"), - PLAN("PLAN"), PM_DICTIONARY("PM_DICTIONARY"), YANG_MODULE("YANG_MODULE"), - ANSIBLE_PLAYBOOK("ANSIBLE_PLAYBOOK"), ONBOARDED_PACKAGE("ONBOARDED_PACKAGE"), PNF_SW_INFORMATION("PNF_SW_INFORMATION"); + AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), + ANSIBLE_PLAYBOOK("ANSIBLE_PLAYBOOK"), + CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"), + DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), + DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), + GUIDE("GUIDE"), + HEAT("HEAT"), + HEAT_ARTIFACT("HEAT_ARTIFACT"), + HEAT_ENV("HEAT_ENV"), + HEAT_NESTED("HEAT_NESTED"), + HEAT_NET("HEAT_NET"), + HEAT_VOL("HEAT_VOL"), + LIFECYCLE_OPERATIONS("LIFECYCLE_OPERATIONS"), + MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), + MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), + OTHER("OTHER"), + PM_DICTIONARY("PM_DICTIONARY"), + PUPPET("PUPPET"), + SNMP_POLL("SNMP_POLL"), + SNMP_TRAP("SNMP_TRAP"), + TOSCA_CSAR("TOSCA_CSAR"), + TOSCA_TEMPLATE("TOSCA_TEMPLATE"), + UCPE_LAYER_2_CONFIGURATION("UCPE_LAYER_2_CONFIGURATION"), + VENDOR_LICENSE("VENDOR_LICENSE"), + VES_EVENTS("VES_EVENTS"), + VF_LICENSE("VF_LICENSE"), + VF_MODULES_METADATA("VF_MODULES_METADATA"), + VNF_CATALOG("VNF_CATALOG"), + WORKFLOW("WORKFLOW"), + YANG_XML("YANG_XML"), + CHEF("CHEF"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), SHELL("SHELL"), ICON("ICON"), UNKNOWN("UNKNOWN"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), + NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), BPEL("BPEL"), APPC_CONFIG("APPC_CONFIG"), PERFORMANCE_COUNTER("PERFORMANCE_COUNTER"), CONTROLLER_BLUEPRINT_ARCHIVE("CONTROLLER_BLUEPRINT_ARCHIVE"), + DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), + DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), + AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), + PLAN("PLAN"), YANG_MODULE("YANG_MODULE"), ONBOARDED_PACKAGE("ONBOARDED_PACKAGE"), PNF_SW_INFORMATION("PNF_SW_INFORMATION"); - private final String type; + private final String type; - public static ArtifactTypeEnum findType(final String type) { - for (final ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { - if (ate.getType().equalsIgnoreCase(type)) { - return ate; - } - } - return null; - } + /** + * Parse a string to a {@link ArtifactTypeEnum}, ignoring the case. + * + * @param type the artifact type + * @return The artifact type if its represented in the present enum, otherwise {@code null}. + */ + public static ArtifactTypeEnum parse(final String type) { + for (final ArtifactTypeEnum artifactType : ArtifactTypeEnum.values()) { + if (artifactType.getType().equalsIgnoreCase(type)) { + return artifactType; + } + } + return null; + } - public static List getAllTypes() { - final List types = new ArrayList<>(); - for (final ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { - types.add(ate.getType()); - } - return types; - } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java index 86cdeaafa8..86f1f86bb0 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/api/ArtifactTypeEnumTest.java @@ -20,43 +20,36 @@ package org.openecomp.sdc.common.api; -import java.util.List; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; import org.junit.Test; public class ArtifactTypeEnumTest { - - private ArtifactTypeEnum createTestSubject() { - return ArtifactTypeEnum.AAI_SERVICE_MODEL; - } - @Test - public void testGetType() throws Exception { - ArtifactTypeEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); + public void testGetType() { + assertThat("The artifact type should match", ArtifactTypeEnum.WORKFLOW.getType(), is("WORKFLOW")); + assertThat("The artifact type should match", ArtifactTypeEnum.OTHER.getType(), is("OTHER")); + assertThat("The artifact type should match", ArtifactTypeEnum.HEAT.getType(), is("HEAT")); } @Test - public void testFindType() throws Exception { - String type = ""; - ArtifactTypeEnum result; - - // default test - result = ArtifactTypeEnum.findType(type); + public void testParse() { + ArtifactTypeEnum actual = ArtifactTypeEnum.parse("HEAT"); + assertThat("The artifact type should not be null", actual, notNullValue()); + assertThat("The artifact type should match", actual, is(ArtifactTypeEnum.HEAT)); + actual = ArtifactTypeEnum.parse("OTHER"); + assertThat("The artifact type should not be null", actual, notNullValue()); + assertThat("The artifact type should match", actual, is(ArtifactTypeEnum.OTHER)); + actual = ArtifactTypeEnum.parse("WORKFLOW"); + assertThat("The artifact type should not be null", actual, notNullValue()); + assertThat("The artifact type should match", actual, is(ArtifactTypeEnum.WORKFLOW)); + actual = ArtifactTypeEnum.parse("anyNotKnownType"); + assertThat("The artifact type should be null", actual, nullValue()); } - - @Test - public void testGetAllTypes() throws Exception { - List result; - - // default test - result = ArtifactTypeEnum.getAllTypes(); - } } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml index 81a548dd16..628ca43261 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml @@ -83,18 +83,6 @@ elasticSearch: - indexPrefix: monitoring_events creationPeriod: month -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - OTHER - licenseTypes: - User - Installation diff --git a/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml index 44b2759940..22aac102b6 100644 --- a/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml +++ b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml @@ -84,18 +84,6 @@ elasticSearch: - indexPrefix: monitoring_events creationPeriod: month -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - OTHER - licenseTypes: - User - Installation @@ -213,14 +201,6 @@ systemMonitoring: defaultHeatArtifactTimeoutMinutes: 60 -serviceDeploymentArtifacts: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - unLoggedUrls: - /sdc2/rest/healthCheck diff --git a/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml index de9f2137f5..6943e9b024 100644 --- a/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml +++ b/test-apis-ci/src/test/resources/config/test-apis-ci/configuration.yaml @@ -111,30 +111,6 @@ elasticSearch: - indexPrefix: monitoring_events creationPeriod: month -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -294,248 +270,6 @@ systemMonitoring: defaultHeatArtifactTimeoutMinutes: 60 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - PNF_SW_INFORMATION: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - requirementsToFulfillBeforeCert: capabilitiesToConsumeBeforeCert: -- cgit 1.2.3-korg