diff options
19 files changed, 90 insertions, 8 deletions
diff --git a/asdctool/src/main/resources/config/error-configuration.yaml b/asdctool/src/main/resources/config/error-configuration.yaml index 5bd933ab80..4246e0def5 100644 --- a/asdctool/src/main/resources/config/error-configuration.yaml +++ b/asdctool/src/main/resources/config/error-configuration.yaml @@ -2853,4 +2853,11 @@ errors: CAPABILITY_NOT_FOUND: code: 404 message: "Capability '%1' was not found for model '%2'." - messageId: "SVC4014"
\ No newline at end of file + messageId: "SVC4014" + + #---------SVC4015----------------------------- + CANNOT_CHANGE_CONSTRAINTS: { + code: 400, + message: "Cannot change this properties constraints as the resource is an instance.", + messageId: "SVC4015" + }
\ No newline at end of file diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml index a9df460cf2..0530298219 100644 --- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml +++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml @@ -2862,4 +2862,11 @@ errors: CAPABILITY_NOT_FOUND: code: 404 message: "Capability '%1' was not found for model '%2'." - messageId: "SVC4014"
\ No newline at end of file + messageId: "SVC4014" + + #---------SVC4015----------------------------- + CANNOT_CHANGE_CONSTRAINTS: { + code: 400, + message: "Cannot change this properties constraints as the resource is an instance.", + messageId: "SVC4015" + }
\ No newline at end of file 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 fe6ea03562..64c66c5d79 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 @@ -104,6 +104,7 @@ import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.PolicyDefinition; +import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RelationshipInfo; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; @@ -1975,6 +1976,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { for (ComponentInstanceProperty property : properties) { validateMandatoryFields(property); validatePropertyExistsOnComponent(property, containerComponent, foundResourceInstance); + validatePropertyConstraintsNotChanged(properties, foundResourceInstance); String propertyParentUniqueId = property.getParentUniqueId(); if (property.isToscaFunction()) { toscaFunctionValidator.validate(property, containerComponent); @@ -3993,6 +3995,22 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } + private void validatePropertyConstraintsNotChanged(List<ComponentInstanceProperty> newProperties, ComponentInstance originalResourceInstance) { + for (ComponentInstanceProperty newProperty : newProperties) { + Optional<PropertyDefinition> originalProperty = originalResourceInstance.getProperties().stream() + .filter(prop -> prop.getUniqueId().equals(newProperty.getUniqueId())).findAny(); + if (originalProperty.isPresent()) { + List<PropertyConstraint> originalConstraints = originalProperty.get().getConstraints(); + List<PropertyConstraint> newConstraints = newProperty.getConstraints(); + if (!Objects.equals(originalConstraints, newConstraints)) { + throw new ByActionStatusComponentException(ActionStatus.CANNOT_CHANGE_CONSTRAINTS); + } + } else { + throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND, newProperty.getUniqueId()); + } + } + } + private Either<Boolean, ResponseFormat> validatePropertyValueConstraint(List<? extends PropertyDefinition> properties, final String componentId) { try { String propertyModel = propertyBusinessLogic.getComponentModelByComponentId(componentId); diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml index c53efc21b1..56dd54c5e4 100644 --- a/catalog-be/src/main/resources/config/error-configuration.yaml +++ b/catalog-be/src/main/resources/config/error-configuration.yaml @@ -2862,4 +2862,11 @@ errors: CAPABILITY_NOT_FOUND: code: 404 message: "Capability '%1' was not found for model '%2'." - messageId: "SVC4014"
\ No newline at end of file + messageId: "SVC4014" + + #---------SVC4015----------------------------- + CANNOT_CHANGE_CONSTRAINTS: { + code: 400, + message: "Cannot change this properties constraints as the resource is an instance.", + messageId: "SVC4015" + }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index f22b346052..f6a86ac02f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -319,6 +319,7 @@ class ComponentInstanceBusinessLogicTest { property.setName("property"); property.setValue("newVal"); property.setType("string"); + property.setUniqueId("propId"); properties.add(property); List<ComponentInstanceProperty> origProperties = new ArrayList<>(); @@ -328,6 +329,14 @@ class ComponentInstanceBusinessLogicTest { origProperty.setType("string"); origProperties.add(origProperty); + List<PropertyDefinition> ciProperties = new ArrayList<>(); + PropertyDefinition ciProperty = new ComponentInstanceProperty(); + ciProperty.setName("property"); + ciProperty.setValue("value"); + ciProperty.setType("string"); + ciProperty.setUniqueId("propId"); + ciProperties.add(ciProperty); + Map<String, DataTypeDefinition> types = new HashMap<>(); DataTypeDefinition dataTypeDef = new DataTypeDefinition(); types.put("string", dataTypeDef); @@ -340,6 +349,7 @@ class ComponentInstanceBusinessLogicTest { component.setComponentInstancesProperties(componentInstanceProps); ComponentInstance ci = createComponentInstance("ci1"); ci.setUniqueId("resourceId"); + ci.setProperties(ciProperties); component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"), createComponentInstance(componentInstanceID))); diff --git a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml index b3df674126..fc4e7d33b7 100644 --- a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml @@ -2848,4 +2848,11 @@ errors: CAPABILITY_NOT_FOUND: code: 404 message: "Capability '%1' was not found for model '%2'." - messageId: "SVC4014"
\ No newline at end of file + messageId: "SVC4014" + + #---------SVC4015----------------------------- + CANNOT_CHANGE_CONSTRAINTS: { + code: 400, + message: "Cannot change this properties constraints as the resource is an instance.", + messageId: "SVC4015" + }
\ No newline at end of file diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java index 0150ebe891..d2b1409c86 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java @@ -114,7 +114,7 @@ public enum ActionStatus { //InterfaceLifeCycleType INTERFACE_LIFECYCLE_TYPES_NOT_FOUND, INVALID_PROPERTY_NAME, INVALID_INPUT_NAME, //Property Constraints - INVALID_PROPERTY_CONSTRAINTS, INVALID_PROPERTY_CONSTRAINTS_FORMAT, CANNOT_DELETE_VALID_VALUES, + INVALID_PROPERTY_CONSTRAINTS, INVALID_PROPERTY_CONSTRAINTS_FORMAT, CANNOT_DELETE_VALID_VALUES, CANNOT_CHANGE_CONSTRAINTS, //Container CONTAINER_CANNOT_CONTAIN_COMPONENT_IN_STATE, CONTAINER_CANNOT_CONTAIN_INSTANCE, MISSING_MANDATORY_PROPERTY, MANDATORY_PROPERTY_MISSING_VALUE, //Capability related 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 e1c55ac829..7462a7276a 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 @@ -20,6 +20,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -31,11 +32,13 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolatio import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; @SuppressWarnings("serial") +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class EqualConstraint extends AbstractComparablePropertyConstraint { @Getter @Setter @NotNull + @EqualsAndHashCode.Include private Object equal; private Object typed; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java index e90f1c0bf2..35f036b9c6 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -34,6 +35,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint @Getter @Setter @AllArgsConstructor +@EqualsAndHashCode public class GreaterOrEqualConstraint extends AbstractComparablePropertyConstraint { @NotNull diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java index e1293d1bb1..7ecec8aad3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -34,6 +35,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint @Getter @Setter @AllArgsConstructor +@EqualsAndHashCode public class GreaterThanConstraint<T> extends AbstractComparablePropertyConstraint { @NotNull diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java index 26d75bd134..19e215364c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import com.fasterxml.jackson.annotation.JsonIgnore; import java.util.List; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -36,9 +37,11 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint @NoArgsConstructor @Getter @Setter +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class InRangeConstraint extends AbstractPropertyConstraint { @NonNull + @EqualsAndHashCode.Include private List<Object> inRange; @JsonIgnore private Comparable min; 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 3ed6e7fc50..f7952fa3a1 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 @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import java.util.List; import java.util.Map; import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.tosca.ToscaType; @@ -33,6 +34,7 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor +@EqualsAndHashCode public class LengthConstraint extends AbstractPropertyConstraint { @NotNull diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java index 3830ddf811..ece5e403ee 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -34,6 +35,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint @Getter @Setter @AllArgsConstructor +@EqualsAndHashCode public class LessOrEqualConstraint<T> extends AbstractComparablePropertyConstraint { @NotNull diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java index f3e283c98e..d071dbaa07 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -34,6 +35,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraint @Getter @Setter @AllArgsConstructor +@EqualsAndHashCode public class LessThanConstraint extends AbstractComparablePropertyConstraint { @NotNull 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 388eb059e6..dfc0d9bf2c 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 @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import java.util.List; import java.util.Map; import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.tosca.ToscaType; @@ -29,6 +30,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunction import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException; import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; +@EqualsAndHashCode public class MaxLengthConstraint extends AbstractPropertyConstraint { @NotNull diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java index a2ff95512a..fbced6bdda 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java @@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints; import java.util.List; import java.util.Map; import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.tosca.ToscaType; @@ -29,6 +30,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunction import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException; import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; +@EqualsAndHashCode public class MinLengthConstraint extends AbstractPropertyConstraint { @NotNull 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 6ff9524169..6d67847272 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.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -30,11 +31,13 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunction import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException; import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; +@EqualsAndHashCode(onlyExplicitlyIncluded = true) @NoArgsConstructor public class PatternConstraint extends AbstractStringPropertyConstraint { @NotNull @Getter + @EqualsAndHashCode.Include private String pattern; private Pattern compiledPattern; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java index f6bc589521..bf979feea1 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java @@ -25,9 +25,9 @@ import com.google.common.collect.Sets; import java.util.List; import java.util.Set; import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; import lombok.Setter; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ConstraintType; @@ -39,12 +39,14 @@ import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolatio import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; @NoArgsConstructor +@EqualsAndHashCode(onlyExplicitlyIncluded = true) public class ValidValuesConstraint extends AbstractPropertyConstraint { private static final String PROPERTY_TYPE_IS = "> property type is <"; @Getter @Setter @NotNull + @EqualsAndHashCode.Include private List<Object> validValues; private Set<Object> validValuesTyped; diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.html index 6272a4529f..cbe858fbd4 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/constraints/constraints.component.html @@ -78,8 +78,9 @@ <div *ngIf="constraint.type != 'inRange' && constraint.type != 'validValues'"> <input type="text" class="i-sdc-form-input myClass" - (input)="onChangeConstraintValue(constraintIndex, $event.target.value)" - [value]="constraint.value"/> + [disabled]="isViewOnly" + (input)="onChangeConstraintValue(constraintIndex, $event.target.value)" + [value]="constraint.value"/> </div> </div> |