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
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
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;
for (ComponentInstanceProperty property : properties) {
validateMandatoryFields(property);
validatePropertyExistsOnComponent(property, containerComponent, foundResourceInstance);
+ validatePropertyConstraintsNotChanged(properties, foundResourceInstance);
String propertyParentUniqueId = property.getParentUniqueId();
if (property.isToscaFunction()) {
toscaFunctionValidator.validate(property, containerComponent);
}
}
+ 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);
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
property.setName("property");
property.setValue("newVal");
property.setType("string");
+ property.setUniqueId("propId");
properties.add(property);
List<ComponentInstanceProperty> origProperties = new ArrayList<>();
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);
component.setComponentInstancesProperties(componentInstanceProps);
ComponentInstance ci = createComponentInstance("ci1");
ci.setUniqueId("resourceId");
+ ci.setProperties(ciProperties);
component.setComponentInstances(Arrays.asList(ci, createComponentInstance("ci2"),
createComponentInstance(componentInstanceID)));
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
//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
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;
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;
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;
@Getter
@Setter
@AllArgsConstructor
+@EqualsAndHashCode
public class GreaterOrEqualConstraint extends AbstractComparablePropertyConstraint {
@NotNull
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;
@Getter
@Setter
@AllArgsConstructor
+@EqualsAndHashCode
public class GreaterThanConstraint<T> extends AbstractComparablePropertyConstraint {
@NotNull
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@NoArgsConstructor
@Getter
@Setter
+@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class InRangeConstraint extends AbstractPropertyConstraint {
@NonNull
+ @EqualsAndHashCode.Include
private List<Object> inRange;
@JsonIgnore
private Comparable min;
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;
@AllArgsConstructor
@NoArgsConstructor
+@EqualsAndHashCode
public class LengthConstraint extends AbstractPropertyConstraint {
@NotNull
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;
@Getter
@Setter
@AllArgsConstructor
+@EqualsAndHashCode
public class LessOrEqualConstraint<T> extends AbstractComparablePropertyConstraint {
@NotNull
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;
@Getter
@Setter
@AllArgsConstructor
+@EqualsAndHashCode
public class LessThanConstraint extends AbstractComparablePropertyConstraint {
@NotNull
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;
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
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;
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
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;
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;
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;
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;
<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>