aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-06-20 15:48:51 +0100
committerMichael Morris <michael.morris@est.tech>2023-06-29 12:35:26 +0000
commit1c9375a06ee65147418b17af2a382e0c6cdb64f1 (patch)
treedb12b7e8ed607bb1ebf0e0c57f8dd31cbb6eb961 /catalog-be/src/main/java/org/openecomp
parent2e4af1e0c0611851f450b2e215485064f6795958 (diff)
Validation problems when trying to set an operation input of complex type
Issue-ID: SDC-4551 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I6227284e0183de5e5fd9b6f33214bac3c2ff14ab
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java9
1 files changed, 6 insertions, 3 deletions
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 fcaa840832..f3354d6158 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
@@ -143,6 +143,7 @@ public class PropertyValueConstraintValidationUtil {
private void evaluateConstraintsOnProperty(PropertyDefinition propertyDefinition) {
ToscaType toscaType = ToscaType.isValidType(propertyDefinition.getType());
+ String value = propertyDefinition.getValue() != null ? propertyDefinition.getValue() : propertyDefinition.getDefaultValue();
if (!isValueAToscaFunction(propertyDefinition) && CollectionUtils.isNotEmpty(propertyDefinition.getConstraints())) {
for (PropertyConstraint propertyConstraint : propertyDefinition.getConstraints()) {
try {
@@ -155,10 +156,11 @@ public class PropertyValueConstraintValidationUtil {
}
}
} else if (!isValueAToscaFunction(propertyDefinition) && ToscaType.isPrimitiveType(propertyDefinition.getType())
- && !propertyDefinition.isToscaFunction() && !toscaType.isValidValue(
- propertyDefinition.getValue() != null ? propertyDefinition.getValue() : propertyDefinition.getDefaultValue())) {
+ && !propertyDefinition.isToscaFunction() && !toscaType.isValidValue(value)) {
errorMessages.add(String.format("Unsupported value provided for %s property supported value type is %s.",
getCompletePropertyName(propertyDefinition), toscaType.getType()));
+ } else if (propertyDefinition.isRequired() && StringUtils.isEmpty(value)) {
+ errorMessages.add(String.format("Property %s is required. Please enter a value.", getCompletePropertyName(propertyDefinition)));
}
}
@@ -215,7 +217,8 @@ public class PropertyValueConstraintValidationUtil {
}
}
if (ToscaType.isPrimitiveType(prop.getType())) {
- newPropertyWithValue = copyPropertyWithNewValue(prop, String.valueOf(valueMap.get(prop.getName())), prop.getName());
+ String value = valueMap.get(prop.getName()) == null ? null : String.valueOf(valueMap.get(prop.getName()));
+ newPropertyWithValue = copyPropertyWithNewValue(prop, value, prop.getName());
if (isPropertyToEvaluate(newPropertyWithValue)) {
evaluateConstraintsOnProperty(newPropertyWithValue);
}