summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java28
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java4
3 files changed, 28 insertions, 8 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 2a7af62a0c..0b9432b3a1 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
@@ -23,8 +23,11 @@ package org.openecomp.sdc.be.components.csar;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.datatypes.elements.CustomYamlFunction;
import org.openecomp.sdc.be.datatypes.elements.ToscaConcatFunction;
import org.openecomp.sdc.be.datatypes.elements.ToscaCustomFunction;
@@ -51,7 +54,9 @@ public class ToscaFunctionYamlParsingHandler {
}
final List<String> functionParameters;
try {
- functionParameters = (List<String>) functionValueObj;
+ functionParameters = ((List<Object>) functionValueObj).stream()
+ .map(object -> Objects.toString(object, null))
+ .collect(Collectors.toList());
} catch (final ClassCastException ignored) {
return Optional.empty();
}
@@ -66,7 +71,14 @@ public class ToscaFunctionYamlParsingHandler {
toscaGetFunction.setPropertySource(PropertySource.INSTANCE);
toscaGetFunction.setSourceName(propertySourceType);
}
- toscaGetFunction.setPropertyPathFromSource(functionParameters.subList(1, functionParameters.size()));
+ List<String> propertySourceIndex = functionParameters.subList(1, functionParameters.size());
+ String toscaIndexValue = propertySourceIndex.get((propertySourceIndex.size() - 1));
+ if (propertySourceIndex.size() > 1 && (toscaIndexValue.equalsIgnoreCase("INDEX") || StringUtils.isNumeric(toscaIndexValue))) {
+ toscaGetFunction.setPropertyPathFromSource(propertySourceIndex.subList(0,(propertySourceIndex.size() - 1)));
+ toscaGetFunction.setToscaIndex(toscaIndexValue);
+ } else {
+ toscaGetFunction.setPropertyPathFromSource(propertySourceIndex);
+ }
final String propertyName = toscaGetFunction.getPropertyPathFromSource().get(toscaGetFunction.getPropertyPathFromSource().size() - 1);
toscaGetFunction.setPropertyName(propertyName);
return Optional.of(toscaGetFunction);
@@ -85,11 +97,19 @@ public class ToscaFunctionYamlParsingHandler {
} else {
final List<String> functionParameters;
try {
- functionParameters = (List<String>) functionValueObj;
+ functionParameters = ((List<Object>) functionValueObj).stream()
+ .map(object -> Objects.toString(object, null))
+ .collect(Collectors.toList());
} catch (final ClassCastException ignored) {
return Optional.empty();
}
- toscaGetFunction.setPropertyPathFromSource(functionParameters);
+ String toscaIndexValue = functionParameters.get((functionParameters.size() - 1));
+ if (functionParameters.size() > 1 && (toscaIndexValue.equalsIgnoreCase("INDEX") || StringUtils.isNumeric(toscaIndexValue))) {
+ toscaGetFunction.setPropertyPathFromSource(functionParameters.subList(0,(functionParameters.size() - 1)));
+ toscaGetFunction.setToscaIndex(toscaIndexValue);
+ } else {
+ toscaGetFunction.setPropertyPathFromSource(functionParameters);
+ }
}
final String propertyName = toscaGetFunction.getPropertyPathFromSource().get(toscaGetFunction.getPropertyPathFromSource().size() - 1);
toscaGetFunction.setPropertyName(propertyName);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index f43f7de860..16ec9ade96 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -2543,11 +2543,11 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
referredProperty = findSubProperty(referredProperty, toscaGetFunction, model);
}
- if (!property.getType().equals(referredProperty.getType())) {
+ if (!property.getType().equals(referredProperty.getType()) && !"list".equalsIgnoreCase(referredProperty.getType())) {
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
- if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
+ if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
throw ToscaGetFunctionExceptionSupplier
.propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java
index 083a03fb42..1e485d9b27 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java
@@ -129,11 +129,11 @@ public class ToscaFunctionValidatorImpl implements ToscaFunctionValidator {
referredProperty = findSubProperty(referredProperty, toscaGetFunction, model);
}
- if (!property.getType().equals(referredProperty.getType())) {
+ if (!property.getType().equals(referredProperty.getType()) && !"list".equalsIgnoreCase(referredProperty.getType())) {
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
- if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
+ if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
throw ToscaGetFunctionExceptionSupplier
.propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}