diff options
Diffstat (limited to 'catalog-be/src/main')
3 files changed, 34 insertions, 2 deletions
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 |