summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java23
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java5
5 files changed, 25 insertions, 9 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index 0803cc8d7d..97f9874301 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -2324,11 +2324,13 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
private Object getJsonPrimitive(JsonPrimitive je) {
- if (je.isBoolean())
+ if (je.isBoolean()) {
return je.getAsBoolean();
- if (je.isString())
+ }
+ if (je.isString()) {
return je.getAsString();
- if (je.isNumber()){
+ }
+ if (je.isNumber()) {
double number = je.getAsNumber().floatValue();
if ((number % 1) == 0) {
return je.getAsNumber().intValue();
@@ -2391,7 +2393,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
propertyConstraint = deserializeConstraintWithIntegerOperand(value, MaxLengthConstraint.class);
break;
case PATTERN:
- propertyConstraint = deserializeConstraintWithStringOperand(value, PatternConstraint.class);
+ propertyConstraint = deserializeConstraintWithStringPatternOperand(value, PatternConstraint.class);
break;
default:
log.warn("Key {} is not supported. Ignored.", field.getKey());
@@ -2415,6 +2417,19 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
}
+ private PropertyConstraint deserializeConstraintWithStringPatternOperand(JsonNode value,
+ Class<? extends PropertyConstraint> constraintClass) {
+ String asString = value.asText();
+ log.debug("Before adding value to {} object. value = {}", constraintClass, asString);
+ try {
+ return constraintClass.getConstructor(String.class).newInstance(asString);
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException exception) {
+ log.error("Error deserializing constraint", exception);
+ return null;
+ }
+ }
+
private PropertyConstraint deserializeConstraintWithIntegerOperand(JsonNode value, Class<? extends PropertyConstraint> constraintClass) {
Integer asInt = value.asInt();
log.debug("Before adding value to {} object. value = {}", constraintClass, asInt);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
index 9e865733c9..f5a9f847ff 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
@@ -70,7 +70,7 @@ public class EqualConstraint extends AbstractPropertyConstraint implements Seria
@Override
public ConstraintType getConstraintType() {
- return null;
+ return ConstraintType.EQUAL;
}
@Override
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
index d2c8b8c17d..3ed6e7fc50 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
@@ -68,7 +68,7 @@ public class LengthConstraint extends AbstractPropertyConstraint {
@Override
public ConstraintType getConstraintType() {
- return null;
+ return ConstraintType.LENGTH;
}
@Override
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
index 004e431485..388eb059e6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
@@ -62,7 +62,7 @@ public class MaxLengthConstraint extends AbstractPropertyConstraint {
@Override
public ConstraintType getConstraintType() {
- return null;
+ return ConstraintType.MAX_LENGTH;
}
@Override
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
index 1ee96311ec..6ff9524169 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.regex.Pattern;
import javax.validation.constraints.NotNull;
+import lombok.Getter;
import lombok.NoArgsConstructor;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
@@ -28,7 +29,6 @@ import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException;
-import lombok.Getter;
@NoArgsConstructor
public class PatternConstraint extends AbstractStringPropertyConstraint {
@@ -56,11 +56,12 @@ public class PatternConstraint extends AbstractStringPropertyConstraint {
@Override
public ConstraintType getConstraintType() {
- return null;
+ return ConstraintType.PATTERN;
}
@Override
public void validateValueOnUpdate(PropertyConstraint newConstraint) throws PropertyConstraintException {
+ // no need for implementation
}
@Override