summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-12-06 11:40:17 +0000
committerJvD_Ericsson <jeff.van.dam@est.tech>2023-01-10 16:06:58 +0000
commitaa92493c97b43075c18696d79f7d1bf62aa4805a (patch)
treef409319debbaeabd6051fb1a83dec96aba8cbd50 /catalog-be/src/main/java
parent01482efa58dd30e82e640f237a654b8b079a7554 (diff)
Fix resource property constraint values mutable in Service design
Issue-ID: SDC-4290 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: Ica942b7a8bb1f03cbf6baec709135287e31def06
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java18
1 files changed, 18 insertions, 0 deletions
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);