From f02c8a02bf45824ef7f8bb76b55462960f561ec3 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Wed, 19 Sep 2018 12:54:50 +0530 Subject: User is unable to modify name of VF User is unable to modify name of VF having operations which was created via Heat Flow Change-Id: I42b666137b26755cccf71028b220560f42b0c0f7 Issue-ID: SDC-1771 Signed-off-by: mojahidi --- .../be/model/jsontitan/utils/InterfaceUtils.java | 84 +++++----------------- 1 file changed, 16 insertions(+), 68 deletions(-) (limited to 'catalog-model/src/main/java') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java index 7a36d92c76..feef31cbc1 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java @@ -15,19 +15,13 @@ */ package org.openecomp.sdc.be.model.jsontitan.utils; +import org.apache.commons.collections.CollectionUtils; +import org.openecomp.sdc.be.model.InterfaceDefinition; + import java.util.Collection; import java.util.Formatter; -import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.commons.collections.CollectionUtils; -import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; -import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition; -import org.openecomp.sdc.be.model.InputDefinition; -import org.openecomp.sdc.be.model.InterfaceDefinition; -import org.openecomp.sdc.be.model.Operation; import org.openecomp.sdc.common.util.ValidationUtils; public class InterfaceUtils { @@ -35,80 +29,34 @@ public class InterfaceUtils { public static final String INTERFACE_TOSCA_RESOURCE_NAME = "org.openecomp.interfaces.node.lifecycle.%s"; public static final Optional getInterfaceDefinitionFromToscaName( - Collection interfaces, - String resourceName) { + Collection interfaces, + String componentName) { if (CollectionUtils.isEmpty(interfaces)) { return Optional.empty(); } - String toscaName = createInterfaceToscaResourceName(resourceName); + String toscaName = createInterfaceToscaResourceName(componentName); return interfaces.stream().filter( - interfaceDefinition -> interfaceDefinition.getToscaResourceName() != null && interfaceDefinition - .getToscaResourceName().equals(toscaName)).findAny(); + interfaceDefinition -> interfaceDefinition.getToscaResourceName() != null && interfaceDefinition + .getToscaResourceName().equals(toscaName)).findAny(); } public static Collection getInterfaceDefinitionListFromToscaName(Collection interfaces, - String resourceName) { - if(CollectionUtils.isEmpty(interfaces)){ + String componentName) { + if (CollectionUtils.isEmpty(interfaces)) { return CollectionUtils.EMPTY_COLLECTION; } - String toscaName = createInterfaceToscaResourceName(resourceName); + String toscaName = createInterfaceToscaResourceName(componentName); return interfaces.stream().filter( - interfaceDefinition -> interfaceDefinition.getToscaResourceName() != null && interfaceDefinition - .getToscaResourceName().equals(toscaName)).collect(Collectors.toList()); + interfaceDefinition -> interfaceDefinition.getToscaResourceName() != null && interfaceDefinition + .getToscaResourceName().equals(toscaName)).collect(Collectors.toList()); } - public static String createInterfaceToscaResourceName(String resourceName) { + public static String createInterfaceToscaResourceName(String componentName) { StringBuilder sb = new StringBuilder(); - try(Formatter formatter = new Formatter(sb)){ - return formatter.format(INTERFACE_TOSCA_RESOURCE_NAME, ValidationUtils.convertToSystemName(resourceName)).toString(); + try (Formatter formatter = new Formatter(sb)) { + return formatter.format(INTERFACE_TOSCA_RESOURCE_NAME, ValidationUtils.convertToSystemName(componentName)).toString(); } } - - public static void createInputOutput(Operation operation, List inputs, List outputs) throws IllegalStateException { - ListDataDefinition inputDefinitionListDataDefinition = operation.getInputs(); - if (inputDefinitionListDataDefinition != null) { - return; - } - List inputListToscaDataDefinition = inputDefinitionListDataDefinition.getListToscaDataDefinition(); - List convertedInputs = inputListToscaDataDefinition.stream() - .map(input -> convertInput(input, inputs)) - .collect(Collectors.toList()); - - ListDataDefinition outputDefinitionListDataDefinition = operation.getOutputs(); - if (outputDefinitionListDataDefinition != null) { - return; - } - List outputListToscaDataDefinition = outputDefinitionListDataDefinition.getListToscaDataDefinition(); - List convertedOutputs = outputListToscaDataDefinition.stream() - .map(output -> convertOutput(output, outputs) ) - .collect(Collectors.toList()); - - inputDefinitionListDataDefinition.getListToscaDataDefinition().clear(); - inputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedInputs); - outputDefinitionListDataDefinition.getListToscaDataDefinition().clear(); - outputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedOutputs); - } - - private static OperationInputDefinition convertInput(OperationInputDefinition input, - List inputs) throws IllegalStateException { - Optional anyInputDefinition = inputs.stream() - .filter(inp -> inp.getUniqueId().equals(input.getUniqueId())).findAny(); - if (anyInputDefinition.isPresent()) { - return new OperationInputDefinition(input.getLabel(),new InputDataDefinition(anyInputDefinition.get())); - } - throw new IllegalStateException("Could not find input :"+ input.getLabel()); - } - - private static OperationOutputDefinition convertOutput(OperationOutputDefinition output, - List outputs) throws IllegalStateException { - Optional anyOutputDefinition = outputs.stream() - .filter(op -> op.getUniqueId().equals(output.getUniqueId())).findAny(); - if (anyOutputDefinition.isPresent()) { - return new OperationOutputDefinition(output.getLabel(),new InputDataDefinition(anyOutputDefinition.get())); - } - throw new IllegalStateException("Could not find output :"+ output.getLabel()); - } - } -- cgit 1.2.3-korg