aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-09-21 13:21:40 +0100
committerKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-09-27 09:45:27 +0100
commit6fa01940a1dec7a323f87f7a141dbef04d8af3d3 (patch)
tree4354c3515911d2c9a7cf5552262e1fbc3a2c2356 /catalog-be/src/main/java
parent467338ad23721809b1f95cb9d2920740b83acb5f (diff)
Service import - Import unknown interface types
Issue-ID: SDC-4186 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: Idfbce90e795136ef2ea1a96f65e458db9206339f
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java30
4 files changed, 47 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
index f92c1d10d2..c401660e27 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
@@ -183,6 +183,13 @@ public abstract class CsarInfo {
public abstract Map<String, Object> getArtifactTypes();
+ /**
+ * Get the interface types defined in the CSAR
+ *
+ * @return map with the interface type name as key and representation of the interface type definition as value
+ */
+ public abstract Map<String, Object> getInterfaceTypes();
+
public Map<String, Object> getPolicyTypes() {
if (policytypeDefinitions == null) {
policytypeDefinitions = new HashMap<>();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
index 9ab767876d..7cb11806e4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
@@ -24,6 +24,7 @@ package org.openecomp.sdc.be.components.csar;
import static org.openecomp.sdc.be.components.impl.ImportUtils.findToscaElement;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DATA_TYPES;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.GROUP_TYPES;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INTERFACE_TYPES;
import fj.data.Either;
import java.util.ArrayList;
@@ -217,6 +218,11 @@ public class OnboardedCsarInfo extends CsarInfo {
}
@Override
+ public Map<String, Object> getInterfaceTypes() {
+ return getTypes(INTERFACE_TYPES);
+ }
+
+ @Override
public Map<String, Object> getCapabilityTypes() {
return getTypes(ToscaTagNamesEnum.CAPABILITY_TYPES);
}
@@ -230,5 +236,4 @@ public class OnboardedCsarInfo extends CsarInfo {
types.putAll(getTypesFromTemplate(mappedToscaMainTemplate, toscaTag));
return types;
}
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
index 54cd29868b..3e0ea35713 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.NodeTypeDefinition;
import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.NodeTypeMetadata;
@@ -174,6 +175,11 @@ public class ServiceCsarInfo extends CsarInfo {
return artifactsTypes;
}
+ @Override
+ public Map<String, Object> getInterfaceTypes() {
+ return getTypes(ToscaTagNamesEnum.INTERFACE_TYPES);
+ }
+
public List<NodeTypeDefinition> getNodeTypesUsed() {
if (nodeTypeDefinitions == null) {
nodeTypeDefinitions = new ArrayList<>();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 151717f9cd..04798ec40a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -144,6 +144,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.ArtifactTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
@@ -203,6 +204,8 @@ public class ServiceImportBusinessLogic {
private final GroupTypeImportManager groupTypeImportManager;
private final GroupTypeOperation groupTypeOperation;
+ private InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
+ private InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager;
private final CapabilityTypeImportManager capabilityTypeImportManager;
private final CapabilityTypeOperation capabilityTypeOperation;
@@ -219,6 +222,8 @@ public class ServiceImportBusinessLogic {
final DataTypeBusinessLogic dataTypeBusinessLogic, final ArtifactTypeOperation artifactTypeOperation,
final ArtifactTypeImportManager artifactTypeImportManager, final GroupTypeImportManager groupTypeImportManager,
final GroupTypeOperation groupTypeOperation,
+ final InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+ final InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager,
final CapabilityTypeImportManager capabilityTypeImportManager,
final CapabilityTypeOperation capabilityTypeOperation) {
this.componentsUtils = componentsUtils;
@@ -242,6 +247,8 @@ public class ServiceImportBusinessLogic {
this.artifactTypeImportManager = artifactTypeImportManager;
this.groupTypeImportManager = groupTypeImportManager;
this.groupTypeOperation = groupTypeOperation;
+ this.interfaceLifecycleTypeOperation = interfaceLifecycleTypeOperation;
+ this.interfaceLifecycleTypeImportManager = interfaceLifecycleTypeImportManager;
this.capabilityTypeImportManager = capabilityTypeImportManager;
this.capabilityTypeOperation = capabilityTypeOperation;
}
@@ -310,6 +317,12 @@ public class ServiceImportBusinessLogic {
groupTypeImportManager.createGroupTypes(toscaTypeImportData, service.getModel(), true);
}
+ final Map<String, Object> interfaceTypesToCreate = getInterfaceTypesToCreate(service.getModel(), csarInfo);
+ if (MapUtils.isNotEmpty(interfaceTypesToCreate)) {
+ interfaceLifecycleTypeImportManager
+ .createLifecycleTypes(new Yaml().dump(interfaceTypesToCreate), service.getModel(), true);
+ }
+
final Map<String, Object> capabilityTypesToCreate = getCapabilityTypesToCreate(service.getModel(), csarInfo);
if (MapUtils.isNotEmpty(capabilityTypesToCreate)) {
@@ -426,8 +439,21 @@ public class ServiceImportBusinessLogic {
return artifactTypesToCreate;
}
- private boolean hasNewProperties(final Either<DataTypeDefinition, JanusGraphOperationStatus> result,
- final Map<String, Map<String, Object>> dataType) {
+ private Map<String, Object> getInterfaceTypesToCreate(final String model, final CsarInfo csarInfo) {
+ final Map<String, Object> interfaceTypesToCreate = new HashMap<>();
+ Map<String, Object> interfacetypeMap = csarInfo.getInterfaceTypes();
+
+ interfacetypeMap.entrySet().forEach(interfacetypeDef -> {
+ Either<InterfaceDefinition, StorageOperationStatus> interfaceDefinition =
+ interfaceLifecycleTypeOperation.getInterface(UniqueIdBuilder.buildInterfaceTypeUid(model, interfacetypeDef.getKey()));
+ if (interfaceDefinition.isRight() && interfaceDefinition.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+ interfaceTypesToCreate.put(interfacetypeDef.getKey(), interfacetypeDef.getValue());
+ }
+ });
+ return interfaceTypesToCreate;
+ }
+
+ private boolean hasNewProperties(final Either<DataTypeDefinition, JanusGraphOperationStatus> result, final Map<String, Map<String, Object>> dataType) {
return result.isLeft() && dataType.containsKey("properties") && result.left().value().getProperties() != null
&& result.left().value().getProperties().size() != dataType.get("properties").size();
}