X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fimpl%2FServiceImportBusinessLogic.java;h=8671d9e27ac9239ee832a4e3f9c3ece705310072;hb=8d59b022d1b35a4549ff4a1f3aeea0c11214c6fb;hp=7dadbee790bb96664e97e91177c30b0067f78d53;hpb=da6b4a245482f4eebade8f487fc9d63f456469ab;p=sdc.git 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 7dadbee790..8671d9e27a 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 @@ -221,10 +221,10 @@ public class ServiceImportBusinessLogic { private final GroupTypeOperation groupTypeOperation; private final CapabilityTypeImportManager capabilityTypeImportManager; private final CapabilityTypeOperation capabilityTypeOperation; - private ApplicationDataTypeCache applicationDataTypeCache; private final InterfaceLifecycleOperation interfaceLifecycleTypeOperation; private final InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager; private final ModelOperation modelOperation; + private ApplicationDataTypeCache applicationDataTypeCache; public ServiceImportBusinessLogic(final GroupBusinessLogic groupBusinessLogic, final ArtifactsBusinessLogic artifactsBusinessLogic, final ComponentsUtils componentsUtils, final ToscaOperationFacade toscaOperationFacade, @@ -2189,6 +2189,9 @@ public class ServiceImportBusinessLogic { } private List addImplicitAttributeValues(Resource originResource, UploadComponentInstanceInfo uploadComponentInstanceInfo) { + if (uploadComponentInstanceInfo.getAttributes() == null) { + return Collections.emptyList(); + } List origAttributes = originResource.getAttributes().stream().map(AttributeDefinition::getName).collect(toList()); Map uploadAttributes = uploadComponentInstanceInfo.getAttributes(); List newAttributesToAdd = @@ -2207,7 +2210,7 @@ public class ServiceImportBusinessLogic { } }); List attributesToAdd = new ArrayList<>(); - for (PropertyDefinition prop: propsToAddAsAttributes) { + for (PropertyDefinition prop : propsToAddAsAttributes) { attributesToAdd.add(getPropertyAsAttribute(prop)); } return attributesToAdd; @@ -2460,13 +2463,13 @@ public class ServiceImportBusinessLogic { Map instanceInterfacesMap = uploadComponentInstanceInfo.getInterfaces(); Map currInterfacesMap = new HashMap<>(); Map interfacesFromNodeType = originResource.getInterfaces(); - if ((MapUtils.isNotEmpty(instanceInterfacesMap)) && (MapUtils.isEmpty(interfacesFromNodeType))) { + if (interfacesFromNodeType == null) { + interfacesFromNodeType = new HashMap<>(); + } + if (MapUtils.isEmpty(instanceInterfacesMap) && MapUtils.isEmpty(instanceInterfacesMap)) { log.debug("failed to find interfaces "); return componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT); } - if (interfacesFromNodeType == null || interfacesFromNodeType.isEmpty()) { - return componentsUtils.getResponseFormat(ActionStatus.OK); - } for (Map.Entry entryInstances : interfacesFromNodeType.entrySet()) { String interfaceName = entryInstances.getKey().substring(entryInstances.getKey().lastIndexOf(".") + 1); if (!currInterfacesMap.containsKey(interfaceName)) { @@ -2478,11 +2481,16 @@ public class ServiceImportBusinessLogic { if (MapUtils.isNotEmpty(instanceInterfacesMap)) { for (UploadInterfaceInfo uploadInterfaceInfo : instanceInterfacesMap.values()) { String interfaceName = uploadInterfaceInfo.getName(); + InterfaceDefinition currentInterfaceDef; if (!currInterfacesMap.containsKey(interfaceName)) { - log.debug("failed to find interface {} ", interfaceName); - return componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT, interfaceName); + currentInterfaceDef = getInterfaceDef(interfaceName, component.getModel()); + if (currentInterfaceDef == null) { + log.debug("failed to find interface {} ", interfaceName); + return componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT, interfaceName); + } + } else { + currentInterfaceDef = currInterfacesMap.get(interfaceName); } - InterfaceDefinition currentInterfaceDef = currInterfacesMap.get(interfaceName); Map operationsToAdd = new HashMap<>(); Map operations = uploadInterfaceInfo.getOperations(); @@ -2508,6 +2516,7 @@ public class ServiceImportBusinessLogic { templateOperation.setImplementation(instanceOperation.getImplementation()); //Description templateOperation.setDescription(instanceOperation.getDescription()); + templateOperation.setMilestones(instanceOperation.getMilestones()); operationsToAdd.put(operation.getKey(), templateOperation); } InterfaceDefinition interfaceDef = new InterfaceDefinition(); @@ -2529,6 +2538,21 @@ public class ServiceImportBusinessLogic { return componentsUtils.getResponseFormat(ActionStatus.OK); } + private InterfaceDefinition getInterfaceDef(String interfaceName, String model) { + Either, StorageOperationStatus> interfaceLifecycleTypesEither = + interfaceLifecycleTypeOperation.getAllInterfaceLifecycleTypes(model); + if (interfaceLifecycleTypesEither.isRight()) { + return null; + } + Map interfaceLifecycleTypes = interfaceLifecycleTypesEither.left().value(); + Optional interfaceType = + interfaceLifecycleTypes.values().stream().filter(interfaceDef -> interfaceDef.getUniqueId().contains(interfaceName)).findFirst(); + if (interfaceType.isEmpty()) { + return null; + } + return interfaceType.get(); + } + private void mergeOperationInputDefinitions(ListDataDefinition inputsFromNodeType, ListDataDefinition instanceInputs) { if (inputsFromNodeType == null || CollectionUtils.isEmpty(inputsFromNodeType.getListToscaDataDefinition()) || instanceInputs == null