From 7565f810f9fa50c8140843b2f81e8fb428815154 Mon Sep 17 00:00:00 2001 From: imamSidero Date: Thu, 23 Mar 2023 11:25:23 +0000 Subject: Provide tosca function capability to all nested levels Tosca function capability is provided to all nested levels of list, map and custom types Issue-ID: SDC-4445 Signed-off-by: Imam hussain Change-Id: I29907bdac83d3cadf90aa0a2ed538002132b4789 --- .../components/impl/ComponentInstanceBusinessLogic.java | 2 +- .../utils/PropertyValueConstraintValidationUtil.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'catalog-be/src/main/java') 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 96366194d3..f43f7de860 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 @@ -2077,7 +2077,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { if (jsonObject.has(path.get(0))) { objectForPath = jsonObject.get(path.get(0)); } else { - if (StringUtils.isNumeric(path.get(0))) { + if (path.size() > 1 && StringUtils.isNumeric(path.get(1))) { objectForPath = new JSONArray(); } else { objectForPath = new JSONObject(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java index 247fff9bc6..ef7363a1a3 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java @@ -61,6 +61,9 @@ public class PropertyValueConstraintValidationUtil { private static final String IGNORE_PROPERTY_VALUE_START_WITH_INPUT = "{\"get_input\":"; private static final String IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY = "{\"get_property\":"; private static final String IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE = "{\"get_attribute\":"; + private static final String IGNORE_PROPERTY_VALUE_INPUT = "{get_input="; + private static final String IGNORE_PROPERTY_VALUE_PROPERTY = "{get_property="; + private static final String IGNORE_PROPERTY_VALUE_ATTRIBUTE = "{get_attribute="; private Map dataTypeDefinitionCache; private final ObjectMapper objectMapper = new ObjectMapper(); private final List errorMessages = new ArrayList<>(); @@ -159,8 +162,10 @@ public class PropertyValueConstraintValidationUtil { } private boolean isValueAToscaFunction(PropertyDefinition propertyDefinition) { - return propertyDefinition.getToscaFunction() != null || propertyDefinition.getValue() != null && (propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_INPUT) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY) - || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE)); + return (propertyDefinition.getToscaFunction() != null) || (propertyDefinition.getValue() != null + && ((propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_INPUT) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_PROPERTY) + || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_START_WITH_ATTRIBUTE) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_ATTRIBUTE) + || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_PROPERTY) || propertyDefinition.getValue().startsWith(IGNORE_PROPERTY_VALUE_INPUT)))); } private void checkAndEvaluatePrimitiveProperty(PropertyDefinition propertyDefinition, DataTypeDefinition dataTypeDefinition) { @@ -197,10 +202,8 @@ public class PropertyValueConstraintValidationUtil { if (propertyDefinition.getSubPropertyToscaFunctions() != null) { for (SubPropertyToscaFunction subPropertyToscaFunction : propertyDefinition.getSubPropertyToscaFunctions()) { final List path = subPropertyToscaFunction.getSubPropertyPath(); - if (path.size() == 1) { - if (path.get(0).equals(prop.getName())) { - return; - } + if (path.size() == 1 && path.get(0).equals(prop.getName())) { + return; } if (path.size() > 1) { if (path.get(0).equals(propertyDefinition.getToscaSubPath()) && path.get(1).equals(prop.getName())) { -- cgit 1.2.3-korg