diff options
Diffstat (limited to 'catalog-be/src/main/java')
2 files changed, 24 insertions, 25 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java index 1e2cea5c64..8976753638 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java @@ -436,8 +436,7 @@ public class ResourceImportManager { Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils .findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.NODE_TYPES); if (toscaElement.isLeft() && toscaElement.left().value().size() == 1) { - String toscaResourceName = toscaElement.left().value().keySet().iterator().next(); - return toscaResourceName; + return toscaElement.left().value().keySet().iterator().next(); } return null; } @@ -463,13 +462,16 @@ public class ResourceImportManager { map = Collections.emptyMap(); } if (existingResource.isLeft()) { - final Map<String, InterfaceDefinition> userCreatedInterfaceDefinitions = - existingResource.left().value().getInterfaces().entrySet().stream() - .filter(i -> i.getValue().isUserCreated()) - .filter(i -> !map.containsKey(i.getValue().getType())) - .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); - if (MapUtils.isNotEmpty(userCreatedInterfaceDefinitions)) { - moduleInterfaces.putAll(userCreatedInterfaceDefinitions); + final Map<String, InterfaceDefinition> interfaces = existingResource.left().value().getInterfaces(); + if (MapUtils.isNotEmpty(interfaces)) { + final Map<String, InterfaceDefinition> userCreatedInterfaceDefinitions = + interfaces.entrySet().stream() + .filter(i -> i.getValue().isUserCreated()) + .filter(i -> !map.containsKey(i.getValue().getType())) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + if (MapUtils.isNotEmpty(userCreatedInterfaceDefinitions)) { + moduleInterfaces.putAll(userCreatedInterfaceDefinitions); + } } } @@ -583,16 +585,14 @@ public class ResourceImportManager { for (final Entry<String, PropertyDefinition> entry : propertyDefinitionMap.entrySet()) { addPropertyToList(resource.getName(), propertiesList, entry); } - if (existingResource.isLeft()) { - if ( CollectionUtils.isNotEmpty(existingResource.left().value().getProperties())) { - final List<PropertyDefinition> userCreatedResourceProperties = - existingResource.left().value().getProperties().stream() - .filter(PropertyDataDefinition::isUserCreated) - .filter(propertyDefinition -> !propertyDefinitionMap.containsKey(propertyDefinition.getName())) - .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(userCreatedResourceProperties)) { - propertiesList.addAll(userCreatedResourceProperties); - } + if (existingResource.isLeft() && CollectionUtils.isNotEmpty(existingResource.left().value().getProperties())) { + final List<PropertyDefinition> userCreatedResourceProperties = + existingResource.left().value().getProperties().stream() + .filter(PropertyDataDefinition::isUserCreated) + .filter(propertyDefinition -> !propertyDefinitionMap.containsKey(propertyDefinition.getName())) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(userCreatedResourceProperties)) { + propertiesList.addAll(userCreatedResourceProperties); } } 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 c022304d8b..641e294e42 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 @@ -821,7 +821,7 @@ public class ServiceImportBusinessLogic { ASDCKpiApi.countCreatedResourcesKPI(); return service; - } catch (ComponentException | StorageException | BusinessLogicException e) { + } catch (Exception e) { rollback = true; serviceImportParseLogic.rollback(inTransaction, service, createdArtifacts, nodeTypesNewCreatedArtifacts); throw e; @@ -2390,23 +2390,22 @@ public class ServiceImportBusinessLogic { Map<String, OperationDataDefinition> operations = uploadInterfaceInfo.getOperations(); for (Map.Entry<String, OperationDataDefinition> operation : operations.entrySet()) { - OperationDataDefinition templateOperation = currentInterfaceDef.getOperationsMap().get(operation.getKey()); OperationDataDefinition instanceOperation = operation.getValue(); + OperationDataDefinition templateOperation = currentInterfaceDef.getOperationsMap().getOrDefault(operation.getKey(), new Operation(instanceOperation)); //Inputs ListDataDefinition<OperationInputDefinition> instanceInputs = instanceOperation.getInputs(); - mergeOperationInputDefinitions(templateOperation.getInputs(), instanceInputs); if (null != instanceInputs) { + mergeOperationInputDefinitions(templateOperation.getInputs(), instanceInputs); component.getProperties() .forEach(property -> instanceInputs.getListToscaDataDefinition().stream() .filter(instanceInput -> instanceInput.getToscaFunction() instanceof ToscaGetFunctionDataDefinition && property.getName().equals(instanceInput.getToscaFunction() != null ? - ((ToscaGetFunctionDataDefinition) instanceInput.getToscaFunction()).getPropertyName() : - null)) + ((ToscaGetFunctionDataDefinition) instanceInput.getToscaFunction()).getPropertyName() : null)) .forEach(oldInput -> oldInput.setType(property.getType())) ); + templateOperation.setInputs(instanceInputs); } - templateOperation.setInputs(instanceInputs); //Implementation templateOperation.setImplementation(instanceOperation.getImplementation()); //Description |