summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-09-30 12:33:48 +0100
committerAndr� Schmid <andre.schmid@est.tech>2022-10-06 12:59:34 +0000
commit899f7858bf981fc12fb5136576a006d83d0ec596 (patch)
tree8a5df77843eeca39181a28294d11f7fe2996c02a /catalog-be/src/main/java/org
parent6ed5592ccb3b2bdb61403f1d1d41d93088cb0709 (diff)
Fix empty interface operation exception
also model not being considered when getting interface type definition during VFC import Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4196 Change-Id: I353d88273acad3047e163ea259e7965c2f3340c0
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java3
5 files changed, 18 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
index 291e973155..aa15d8ae8d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
@@ -159,6 +159,10 @@ public class InterfaceDefinitionHandler {
final OperationDataDefinition operation = new OperationDataDefinition();
operation.setUniqueId(UUID.randomUUID().toString());
operation.setName(operationName);
+
+ if (MapUtils.isEmpty(operationDefinitionMap)) {
+ return operation;
+ }
Object operationDescription = operationDefinitionMap.get(
DESCRIPTION.getElementName()
);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
index b757faf491..b371a8c18d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
@@ -22,12 +22,14 @@ package org.openecomp.sdc.be.components.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.Resource;
@@ -146,8 +148,10 @@ public class InterfaceLifecycleTypeImportManager {
.asList(ToscaTagNamesEnum.DERIVED_FROM.getElementName(), ToscaTagNamesEnum.DESCRIPTION.getElementName(),
ToscaTagNamesEnum.VERSION.getElementName(), ToscaTagNamesEnum.METADATA.getElementName(),
ToscaTagNamesEnum.INPUTS.getElementName(), ToscaTagNamesEnum.NOTIFICATIONS.getElementName());
- operationsMap = toscaJson.entrySet().stream().filter(interfaceEntry -> !entitySchemaEntryList.contains(interfaceEntry.getKey()))
- .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+
+ Stream<Entry<String, Object>> oldFormatOperations = toscaJson.entrySet().stream().filter(interfaceEntry -> !entitySchemaEntryList.contains(interfaceEntry.getKey()));
+ operationsMap = new HashMap<>();
+ oldFormatOperations.forEach(entry -> operationsMap.put(entry.getKey(), entry.getValue()));
}
interfaceDef.setOperationsMap(handleOperations(operationsMap));
return interfaceDef;
@@ -162,6 +166,9 @@ public class InterfaceLifecycleTypeImportManager {
}
private Operation createOperation(final Map<String, Object> toscaOperationMap) {
+ if (toscaOperationMap == null) {
+ return new Operation();
+ }
final Operation operation = new Operation();
operation.setDescription((String) toscaOperationMap.get(ToscaTagNamesEnum.DESCRIPTION.getElementName()));
return operation;
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 92158d0aab..992216db7e 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
@@ -3821,7 +3821,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
while (intItr.hasNext() && eitherResult.isLeft()) {
InterfaceDefinition interfaceDefinition = intItr.next();
String intType = interfaceDefinition.getUniqueId();
- Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(intType);
+ Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType));
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance()
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index b97645cc35..43b88fd63e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -516,7 +516,7 @@ public class ServiceImportParseLogic {
while (intItr.hasNext() && eitherResult.isLeft()) {
InterfaceDefinition interfaceDefinition = intItr.next();
String intType = interfaceDefinition.getUniqueId();
- Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(intType);
+ Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType));
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance()
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
index e373f5d480..ce5038771b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -298,6 +298,9 @@ public class InterfacesOperationsConverter {
final OperationDataDefinition operationDataDefinition,
final ToscaLifecycleOperationDefinition toscaOperation,
final Map<String, DataTypeDefinition> dataTypes) {
+ if (operationDataDefinition.getImplementation() == null) {
+ return;
+ }
final String operationArtifactPath;
final ToscaInterfaceOperationImplementation toscaInterfaceOperationImplementation = new ToscaInterfaceOperationImplementation();
toscaInterfaceOperationImplementation.setPrimary(new ToscaArtifactDefinition());