aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ToscaFunctionYamlParsingHandler.java54
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImpl.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImplTest.java2
4 files changed, 44 insertions, 16 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 80608a82db..40604322d6 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
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.components.csar;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +29,6 @@ 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;
@@ -77,13 +77,27 @@ public class ToscaFunctionYamlParsingHandler {
toscaGetFunction.setSourceName(propertySourceType);
}
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);
+ List<String> propertySourcePath = new ArrayList<>();
+ propertySourcePath.add((String)propertySourceIndex.get(0));
+ if (propertySourceIndex.size() > 1 ) {
+ List<Object> indexParsedList = new ArrayList<Object>();
+ List<String> indexObjectList = propertySourceIndex.subList(1,propertySourceIndex.size());
+ boolean loopFlag = true;
+ for (String indexValue : indexObjectList) {
+ if (!indexValue.equalsIgnoreCase("INDEX") && !StringUtils.isNumeric(indexValue) && loopFlag) {
+ propertySourcePath.add(indexValue);
+ } else {
+ loopFlag = false;
+ if (StringUtils.isNumeric(indexValue)) {
+ indexParsedList.add(Integer.parseInt(indexValue));
+ } else {
+ indexParsedList.add(indexValue);
+ }
+ }
+ }
+ toscaGetFunction.setToscaIndexList(indexParsedList);
}
+ toscaGetFunction.setPropertyPathFromSource(propertySourcePath);
final String propertyName = toscaGetFunction.getPropertyPathFromSource().get(toscaGetFunction.getPropertyPathFromSource().size() - 1);
toscaGetFunction.setPropertyName(propertyName);
return Optional.of(toscaGetFunction);
@@ -108,13 +122,27 @@ public class ToscaFunctionYamlParsingHandler {
} catch (final ClassCastException ignored) {
return Optional.empty();
}
- 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);
+ List<String> propertySourcePath = new ArrayList<>();
+ propertySourcePath.add((String)functionParameters.get(0));
+ if (functionParameters.size() > 1 ) {
+ List<Object> indexParsedList = new ArrayList<Object>();
+ List<String> indexObjectList = functionParameters.subList(1,functionParameters.size());
+ boolean loopFlag = true;
+ for (String indexValue : indexObjectList) {
+ if (!indexValue.equalsIgnoreCase("INDEX") && !StringUtils.isNumeric(indexValue) && loopFlag) {
+ propertySourcePath.add(indexValue);
+ } else {
+ loopFlag = false;
+ if (StringUtils.isNumeric(indexValue)) {
+ indexParsedList.add(Integer.parseInt(indexValue));
+ } else {
+ indexParsedList.add(indexValue);
+ }
+ }
+ }
+ toscaGetFunction.setToscaIndexList(indexParsedList);
}
+ toscaGetFunction.setPropertyPathFromSource(propertySourcePath);
}
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 16ec9ade96..c6007a3608 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
@@ -2547,7 +2547,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
- if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
+ if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !"list".equalsIgnoreCase(referredProperty.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 1e485d9b27..b76ae596a1 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
@@ -133,7 +133,7 @@ public class ToscaFunctionValidatorImpl implements ToscaFunctionValidator {
throw ToscaGetFunctionExceptionSupplier
.propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
}
- if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
+ if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getType()) && !"list".equalsIgnoreCase(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
throw ToscaGetFunctionExceptionSupplier
.propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImplTest.java
index 3b86d9db78..5ff31ba667 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/validation/ToscaFunctionValidatorImplTest.java
@@ -283,7 +283,7 @@ class ToscaFunctionValidatorImplTest {
final String inputId = String.format("%s.%s", containerComponentId, inputName);
final String propertyName = "getInputProperty";
final String propertyId = String.format("%s.%s", containerComponentId, propertyName);
- final String propertyType = "list";
+ final String propertyType = "map";
final ComponentInstanceProperty propertyGetInput = createComponentInstanceProperty(
propertyId,
"getInputProperty",