summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java9
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java5
2 files changed, 8 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java
index 0651e3504e..80608a82db 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java
@@ -28,6 +28,8 @@ import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -193,12 +195,11 @@ public class ToscaFunctionYamlParsingHandler {
}
private Optional<ToscaFunction> handelCustomFunctionGetInputType(ToscaCustomFunction toscaCustomFunction, Object functionValueObj) {
- if (!(functionValueObj instanceof String)) {
+ if (!(functionValueObj instanceof String) && !(functionValueObj instanceof List)) {
return Optional.empty();
}
- final String parameter = (String) functionValueObj;
Map<String, Object> parameterMap = new HashMap<>();
- parameterMap.put(ToscaFunctionType.GET_INPUT.getName(), parameter);
+ parameterMap.put(ToscaFunctionType.GET_INPUT.getName(), functionValueObj);
buildToscaFunctionBasedOnPropertyValue(parameterMap).ifPresent(toscaFunction -> {
if (toscaFunction instanceof ToscaFunctionParameter) {
toscaCustomFunction.addParameter((ToscaFunctionParameter) toscaFunction);
@@ -210,7 +211,7 @@ public class ToscaFunctionYamlParsingHandler {
private ToscaFunctionType getCustomFunctionType(String name) {
List<Configuration.CustomToscaFunction> customFunctions =
ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultCustomToscaFunctions();
- if (customFunctions.isEmpty()) {
+ if (CollectionUtils.isEmpty(customFunctions)) {
return ToscaFunctionType.CUSTOM;
}
Optional<Configuration.CustomToscaFunction> optionalFunc = customFunctions.stream().filter(func -> func.getName().equals(name)).findFirst();
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
index 0ef417f8e2..9396188fcc 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
@@ -124,8 +124,9 @@ public class ToscaGetFunctionDataDefinition implements ToscaFunction, ToscaFunct
List<Object> propertySourceOneCopy = new ArrayList<>();
propertySourceOneCopy.add(this.propertyPathFromSource.get(0));
if (toscaIndex != null) {
- propertySourceCopy.add(toscaIndex);
- propertySourceOneCopy.add(toscaIndex);
+ Object toscaIndexValue = StringUtils.isNumeric(toscaIndex.toString()) ? Integer.parseInt(toscaIndex.toString()) : toscaIndex;
+ propertySourceCopy.add(toscaIndexValue);
+ propertySourceOneCopy.add(toscaIndexValue);
}
if (this.propertyPathFromSource.size() == 1) {
return Map.of(this.functionType.getFunctionName(), propertySourceOneCopy);