summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintEqual.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterOrEqual.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterThan.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLength.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessOrEqual.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessThan.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintValidValues.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java2
11 files changed, 50 insertions, 13 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 181c860b9f..9c2c070c74 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
@@ -63,6 +63,9 @@ 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;
import org.openecomp.sdc.be.utils.TypeUtils;
@@ -315,12 +318,46 @@ public final class ImportUtils {
if (propertyConstraint instanceof ValidValuesConstraint) {
try {
((ValidValuesConstraint) propertyConstraint).validateType(propertyType);
+ boolean valid = ((ValidValuesConstraint) propertyConstraint).validateValueType(propertyType);
+ if (!valid) {
+ ((ValidValuesConstraint) propertyConstraint).changeConstraintValueTypeTo(propertyType);
+ }
} catch (ConstraintValueDoNotMatchPropertyTypeException e) {
BeEcompErrorManager.getInstance()
.logInternalFlowError("GetInitializedPropertyConstraint", e.getMessage(), BeEcompErrorManager.ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.VALID_VALUES.name(),
((ValidValuesConstraint) propertyConstraint).getValidValues().toString(), propertyType);
}
+ } else if (propertyConstraint instanceof AbstractComparablePropertyConstraint) {
+ try {
+ boolean valid = ((AbstractComparablePropertyConstraint) propertyConstraint).validateValueType(propertyType);
+ if (!valid) {
+ ((AbstractComparablePropertyConstraint) propertyConstraint).changeConstraintValueTypeTo(propertyType);
+ }
+ } 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);
+ }
+ } else if (propertyConstraint instanceof InRangeConstraint) {
+ try {
+ boolean valid = ((InRangeConstraint) propertyConstraint).validateValueType(propertyType);
+ if (!valid) {
+ ((InRangeConstraint) propertyConstraint).changeConstraintValueTypeTo(propertyType);
+ }
+ } catch (ConstraintValueDoNotMatchPropertyTypeException e) {
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.IN_RANGE.name(),
+ String.valueOf(((InRangeConstraint) propertyConstraint).getInRange()), propertyType);
+ }
}
return propertyConstraint;
}
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 f1c8a17108..2ad6a942d0 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
@@ -158,16 +158,17 @@ public class PropertyConvertor {
}
if (constraint instanceof InRangeConstraint) {
InRangeConstraint inRangeConstraint = (InRangeConstraint) constraint;
- List<String> range = new ArrayList<>();
+ List<Object> range = new ArrayList<>();
range.add(inRangeConstraint.getRangeMinValue());
range.add(inRangeConstraint.getRangeMaxValue());
convertedConstraints.add(new ToscaPropertyConstraintInRange(range));
}
if (constraint instanceof ValidValuesConstraint) {
- convertedConstraints.add(new ToscaPropertyConstraintValidValues(((ValidValuesConstraint) constraint).getValidValues()));
+ List validValues = ((ValidValuesConstraint) constraint).getValidValues();
+ convertedConstraints.add(new ToscaPropertyConstraintValidValues(validValues));
}
if (constraint instanceof LengthConstraint) {
- convertedConstraints.add(new ToscaPropertyConstraintLength(((LengthConstraint) constraint).getLength().toString()));
+ convertedConstraints.add(new ToscaPropertyConstraintLength(((LengthConstraint) constraint).getLength()));
}
if (constraint instanceof MinLengthConstraint) {
convertedConstraints.add(new ToscaPropertyConstraintMinLength(((MinLengthConstraint) constraint).getMinLength()));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintEqual.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintEqual.java
index 532cb8c91b..e52f8dfa87 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintEqual.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintEqual.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintEqual implements ToscaPropertyConstraint {
- private String equal;
+ private Object equal;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.EQUAL;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterOrEqual.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterOrEqual.java
index fcc9dcc884..89c563bdbc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterOrEqual.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterOrEqual.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintGreaterOrEqual implements ToscaPropertyConstraint {
- private String greaterOrEqual;
+ private Object greaterOrEqual;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.GREATER_OR_EQUAL;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterThan.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterThan.java
index 6f2268bd9e..2168cf4b67 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterThan.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintGreaterThan.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintGreaterThan implements ToscaPropertyConstraint {
- private String greaterThan;
+ private Object greaterThan;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.GREATER_THAN;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java
index 6c8cfba620..91e1f553f5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintInRange.java
@@ -32,7 +32,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintInRange implements ToscaPropertyConstraint {
- private List<String> inRange;
+ private List<Object> inRange;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.IN_RANGE;
@Override
@@ -40,7 +40,6 @@ public class ToscaPropertyConstraintInRange implements ToscaPropertyConstraint {
if ("inRange".equals(attributeName)) {
return CONSTRAINT_TYPE.getType();
}
-
return attributeName;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLength.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLength.java
index 67aaca0188..998a7283bb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLength.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLength.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintLength implements ToscaPropertyConstraint {
- private String length;
+ private Integer length;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.LENGTH;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessOrEqual.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessOrEqual.java
index 3d51ec9419..75e661d15c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessOrEqual.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessOrEqual.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintLessOrEqual implements ToscaPropertyConstraint {
- private String lessOrEqual;
+ private Object lessOrEqual;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.LESS_OR_EQUAL;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessThan.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessThan.java
index ad51f66fde..a64382d8a8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessThan.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintLessThan.java
@@ -31,7 +31,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintLessThan implements ToscaPropertyConstraint {
- private String lessThan;
+ private Object lessThan;
private static final ConstraintType CONSTRAINT_TYPE = ConstraintType.LESS_THAN;
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintValidValues.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintValidValues.java
index c23be5725c..4f9a65cfc1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintValidValues.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaPropertyConstraintValidValues.java
@@ -32,7 +32,7 @@ import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@AllArgsConstructor
public class ToscaPropertyConstraintValidValues implements ToscaPropertyConstraint {
- private List<String> validValues;
+ private List<Object> validValues;
@Override
public String getEntryToscaName(final String attributeName) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index b7559e3836..8fcc06ba81 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -329,7 +329,7 @@ public class ImportUtilsTest {
assertTrue(property.getConstraints() != null && property.getConstraints().size() == 1);
assertTrue(property.getConstraints().get(0) instanceof ValidValuesConstraint);
assertNotNull(((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues());
- List<String> validValues = ((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues();
+ List<Object> validValues = ((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues();
assertTrue(validValues.containsAll(Lists.newArrayList("firewall", "analyzer", "source-nat", "loadbalancer")));
assertTrue(properties.containsKey("service_interface_type_list"));