Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs, component.getModel());
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
+ unlockComponent(true, component);
return Either.right(constraintValidatorResponse.right().value());
}
validateCanWorkOnComponent(component, userId);
if (currInput == null) {
ActionStatus actionStatus = ActionStatus.COMPONENT_NOT_FOUND;
log.debug("Failed to found newInput {} under component {}, error: {}", newInput.getUniqueId(), componentId, actionStatus);
- result = Either.right(componentsUtils.getResponseFormat(actionStatus));
- return result;
+ unlockComponent(true, component);
+ return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
String updateInputObjectValue = updateInputObjectValue(currInput, newInput, dataTypes);
currInput.setDefaultValue(updateInputObjectValue);
Either<InputDefinition, StorageOperationStatus> status = toscaOperationFacade.updateInputOfComponent(component, currInput);
if (status.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForResourceInstanceProperty(status.right().value());
- result = Either.right(componentsUtils.getResponseFormat(actionStatus, ""));
- return result;
+ unlockComponent(true, component);
+ return Either.right(componentsUtils.getResponseFormat(actionStatus, ""));
} else {
returnInputs.add(status.left().value());
}
List<InputDefinition> inputDefinitions = new ArrayList<>();
for (InputDefinition inputDefinition : inputs) {
InputDefinition inputDef = new InputDefinition();
+ inputDef.setName(inputDefinition.getName());
inputDef.setDefaultValue(inputDefinition.getDefaultValue());
inputDef.setInputPath(inputDefinition.getSubPropertyInputPath());
inputDef.setType(inputDefinition.getType());
+ inputDef.setConstraints(inputDefinition.getConstraints());
if (Objects.nonNull(inputDefinition.getParentPropertyType())) {
ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
propertyDefinition.setType(inputDefinition.getParentPropertyType());
propertyDefinition.setType(inputDefinition.getType());
propertyDefinition.setValue(inputDefinition.getDefaultValue());
propertyDefinition.setName(inputDefinition.getName());
+ propertyDefinition.setConstraints(inputDefinition.getConstraints());
} else if (Objects.nonNull(inputDefinition.getInputPath())) {
propertyDefinition = evaluateComplexTypeInputs(inputDefinition);
+ propertyDefinition.setConstraints(inputDefinition.getConstraints());
}
return propertyDefinition;
}
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s property value must be %s", String.valueOf(equal));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be %s", String.valueOf(equal));
}
@Override
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s property value must be greater than or equal to %s", String.valueOf(greaterOrEqual));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be greater than or equal to %s", String.valueOf(greaterOrEqual));
}
@Override
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s property value must be greater than %s", String.valueOf(greaterThan));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be greater than %s", String.valueOf(greaterThan));
}
@Override
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s property value must be less than or equal to %s", String.valueOf(lessOrEqual));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be less than or equal to %s", String.valueOf(lessOrEqual));
}
@Override
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s value must be less than %s", String.valueOf(lessThan));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be less than %s", String.valueOf(lessThan));
}
@Override
@Override
public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException e, String propertyName) {
- return getErrorMessage(toscaType, e, propertyName, "%s valid value must be one of the following: [%s]", String.join(",", String.valueOf(validValues)));
+ return getErrorMessage(toscaType, e, propertyName, "'%s' value must be one of the following: [%s]", String.join(",", String.valueOf(validValues)));
}
public boolean validateValueType(String propertyType) throws ConstraintValueDoNotMatchPropertyTypeException {
public updateProperty = (inputProperty: InputFEModel): void => {
let modelProperty : PropertyModel = this.createPropertyModel(inputProperty);
- if (inputProperty.instanceUniqueId != null && this.componentInstancePropertyMap != null && modelProperty.constraints == null) {
+ if (inputProperty.instanceUniqueId != null && this.componentInstancePropertyMap != null && modelProperty.constraints == null && this.componentInstancePropertyMap[inputProperty.instanceUniqueId]) {
this.componentInstancePropertyMap[inputProperty.instanceUniqueId].forEach(tempProperty => {
modelProperty.constraints = tempProperty.constraints;
});