summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-09-19 12:54:50 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-09-27 08:20:25 +0000
commitf02c8a02bf45824ef7f8bb76b55462960f561ec3 (patch)
tree61b445167b03b64ad742116d0f721fd5f770981b /catalog-model/src
parent3527b3e98ec9236072c97a66b3d74955316e094e (diff)
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 <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java84
1 files changed, 16 insertions, 68 deletions
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<InterfaceDefinition> getInterfaceDefinitionFromToscaName(
- Collection<InterfaceDefinition> interfaces,
- String resourceName) {
+ Collection<InterfaceDefinition> 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<InterfaceDefinition> getInterfaceDefinitionListFromToscaName(Collection<InterfaceDefinition> 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<InputDefinition> inputs, List<InputDefinition> outputs) throws IllegalStateException {
- ListDataDefinition<OperationInputDefinition> inputDefinitionListDataDefinition = operation.getInputs();
- if (inputDefinitionListDataDefinition != null) {
- return;
- }
- List<OperationInputDefinition> inputListToscaDataDefinition = inputDefinitionListDataDefinition.getListToscaDataDefinition();
- List<OperationInputDefinition> convertedInputs = inputListToscaDataDefinition.stream()
- .map(input -> convertInput(input, inputs))
- .collect(Collectors.toList());
-
- ListDataDefinition<OperationOutputDefinition> outputDefinitionListDataDefinition = operation.getOutputs();
- if (outputDefinitionListDataDefinition != null) {
- return;
- }
- List<OperationOutputDefinition> outputListToscaDataDefinition = outputDefinitionListDataDefinition.getListToscaDataDefinition();
- List<OperationOutputDefinition> 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<InputDefinition> inputs) throws IllegalStateException {
- Optional<InputDefinition> 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<InputDefinition> outputs) throws IllegalStateException {
- Optional<InputDefinition> 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());
- }
-
}