From 899f7858bf981fc12fb5136576a006d83d0ec596 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 30 Sep 2022 12:33:48 +0100 Subject: Fix empty interface operation exception also model not being considered when getting interface type definition during VFC import Signed-off-by: MichaelMorris Issue-ID: SDC-4196 Change-Id: I353d88273acad3047e163ea259e7965c2f3340c0 --- .../sdc/be/components/impl/InterfaceDefinitionHandler.java | 4 ++++ .../components/impl/InterfaceLifecycleTypeImportManager.java | 11 +++++++++-- .../sdc/be/components/impl/ResourceBusinessLogic.java | 2 +- .../sdc/be/components/impl/ServiceImportParseLogic.java | 2 +- .../openecomp/sdc/be/tosca/InterfacesOperationsConverter.java | 3 +++ 5 files changed, 18 insertions(+), 4 deletions(-) (limited to 'catalog-be') 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> 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 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 eitherCapTypeFound = interfaceTypeOperation.getInterface(intType); + Either 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 eitherCapTypeFound = interfaceTypeOperation.getInterface(intType); + Either 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 dataTypes) { + if (operationDataDefinition.getImplementation() == null) { + return; + } final String operationArtifactPath; final ToscaInterfaceOperationImplementation toscaInterfaceOperationImplementation = new ToscaInterfaceOperationImplementation(); toscaInterfaceOperationImplementation.setPrimary(new ToscaArtifactDefinition()); -- cgit 1.2.3-korg