diff options
author | imamSidero <imam.hussain@est.tech> | 2022-10-11 09:56:47 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-10-24 13:05:56 +0000 |
commit | aa361f84ec4d137e7a64df8c7feaec6d2304c03e (patch) | |
tree | ed509b7988c16cae1124eea86e03baf31957cb32 /catalog-be/src | |
parent | 5007c94c7106972d9958125660a210fe58297b65 (diff) |
Constraint validation for instance attributes in a service
Validating the attributes of instance in a service against it's constraints
Signed-off-by: imamSidero <imam.hussain@est.tech>
Issue-ID: SDC-4209
Change-Id: I7f28f1bd2b209c2d765687e06350711ef9be3c6d
Diffstat (limited to 'catalog-be/src')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java | 18 |
1 files changed, 17 insertions, 1 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 0b3610a611..e867d0639e 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 @@ -2086,6 +2086,22 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } final ComponentInstance foundResourceInstance = resourceInstanceStatus.left().value(); + // Validate instance attributes against it's constraints + List<PropertyDefinition> attributesToValidate = new ArrayList<>(); + attributes.forEach((componentInstanceAttribute) -> { + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setValue(componentInstanceAttribute.getValue()); + propertyDefinition.setType(componentInstanceAttribute.getType()); + propertyDefinition.setName(componentInstanceAttribute.getName()); + propertyDefinition.setUniqueId(componentInstanceAttribute.getUniqueId()); + attributesToValidate.add(propertyDefinition); + }); + Either<Boolean, ResponseFormat> constraintValidatorResponse = validatePropertyValueConstraint(attributesToValidate,componentId); + if (constraintValidatorResponse.isRight()) { + log.error("Failed validation value and constraint of attribute: {}", constraintValidatorResponse.right().value()); + return Either.right(constraintValidatorResponse.right().value()); + } + // lock resource final StorageOperationStatus lockStatus = graphLockOperation.lockComponent(componentId, componentTypeEnum.getNodeType()); if (lockStatus != StorageOperationStatus.OK) { @@ -3918,7 +3934,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } - private Either<Boolean, ResponseFormat> validatePropertyValueConstraint(List<ComponentInstanceProperty> properties, final String componentId) { + private Either<Boolean, ResponseFormat> validatePropertyValueConstraint(List<? extends PropertyDefinition> properties, final String componentId) { try { String propertyModel = propertyBusinessLogic.getComponentModelByComponentId(componentId); PropertyValueConstraintValidationUtil propertyValueConstraintValidationUtil = new PropertyValueConstraintValidationUtil(); |