diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-12-23 16:56:21 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-01-03 14:19:17 +0000 |
commit | a81c40773b3c819f079bd741d472ee954572cb34 (patch) | |
tree | 24626c3affd27f8c03473275ddf89baa2ae3af60 /catalog-be/src/main/java/org | |
parent | 4871b522afd7dfee773dc891cb94d3f1eaafb040 (diff) |
Fix 'NPE thrown in editing constraints'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Ibbd8a3baa2a2bfdbd6e2c235db5a1d59875f3e6e
Issue-ID: SDC-4312
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java | 21 | ||||
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java | 4 |
2 files changed, 8 insertions, 17 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java index 51444a2cc1..b773f1fbbc 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.components.impl; import static org.apache.commons.collections.CollectionUtils.isEmpty; import static org.openecomp.sdc.be.components.impl.ResourceImportManager.PROPERTY_NAME_PATTERN_IGNORE_LENGTH; import static org.openecomp.sdc.be.datatypes.elements.Annotation.setAnnotationsName; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonParseException; @@ -48,6 +49,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.Annotation; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; +import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.AnnotationTypeDefinition; @@ -62,9 +64,7 @@ import org.openecomp.sdc.be.model.heat.HeatParameterType; import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; -import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.model.tosca.constraints.AbstractComparablePropertyConstraint; -import org.openecomp.sdc.be.model.tosca.constraints.EqualConstraint; import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint; import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException; @@ -336,17 +336,7 @@ public final class ImportUtils { } } catch (ConstraintValueDoNotMatchPropertyTypeException e) { throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, propertyConstraint.getConstraintType().name(), - ((AbstractComparablePropertyConstraint) propertyConstraint).getConstraintValueAsString(), propertyType); - } - } else if (propertyConstraint instanceof EqualConstraint) { - try { - boolean valid = ((EqualConstraint) propertyConstraint).validateValueType(propertyType); - if (!valid) { - ((EqualConstraint) propertyConstraint).changeConstraintValueTypeTo(propertyType); - } - } catch (ConstraintValueDoNotMatchPropertyTypeException e) { - throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.EQUAL.name(), - String.valueOf(((EqualConstraint) propertyConstraint).getEqual()), propertyType); + propertyConstraint.toString(), propertyType); } } else if (propertyConstraint instanceof InRangeConstraint) { try { @@ -356,7 +346,7 @@ public final class ImportUtils { } } catch (ConstraintValueDoNotMatchPropertyTypeException e) { throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.IN_RANGE.name(), - String.valueOf(((InRangeConstraint) propertyConstraint).getInRange()), propertyType); + String.valueOf(((InRangeConstraint) propertyConstraint).getInRange()), propertyType); } } return propertyConstraint; @@ -712,7 +702,8 @@ public final class ImportUtils { public static boolean containsGetInput(Object propValue) { String value = getPropertyJsonStringValue(propValue, ToscaPropertyType.MAP.getType()); - return value != null && value.contains(TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName()) && !value.contains(TypeUtils.ToscaTagNamesEnum.CONCAT.getElementName()); + return value != null && value.contains(TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName()) && !value.contains( + TypeUtils.ToscaTagNamesEnum.CONCAT.getElementName()); } public static String getPropertyJsonStringValue(Object value, String type) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java index ae97b89b78..9b92adbe6a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java @@ -157,8 +157,8 @@ public class PropertyConvertor { if (constraint instanceof InRangeConstraint) { InRangeConstraint inRangeConstraint = (InRangeConstraint) constraint; List<Object> range = new ArrayList<>(); - range.add(inRangeConstraint.getRangeMinValue()); - range.add(inRangeConstraint.getRangeMaxValue()); + range.add(inRangeConstraint.getMin()); + range.add(inRangeConstraint.getMax()); convertedConstraints.add(new ToscaPropertyConstraintInRange(range)); } if (constraint instanceof ValidValuesConstraint) { |