Commit e4dbd9bf authored by yannick legoc's avatar yannick legoc

In Property.checkServerValue, check also the constant by the server because a...

In Property.checkServerValue, check also the constant by the server because a value can be accepted by the client but not the server e.g. 24d is not a numeric constant for the mu parser
parent e1aeaa39
......@@ -325,34 +325,44 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
*/
public ExpressionResult checkServerValue(String value) {
if (isConstant(value)) {
boolean constant = isConstant(value);
// Test the validity of the expression by the server even for constant expression (a constant can be accepted by the client check but not the server so we check both).
CommandZoneAccessor.ExpressionResult result = null;
if (isCommandBox) {
result = CommandZoneAccessor.getInstance(serverId).checkPropertyExpression(containerId, id, value);
}
else {
result = CommandZoneAccessor.getInstance(serverId).checkStaticPropertyExpression(id, value);
}
// If the expression is invalid for the server, return an ExpressionResult for constants and expressions.
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
if (constant) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
} else {
return new ExpressionResult(ExpressionStatus.INVALID_EXPRESSION, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
}
}
// Check the client conditions in case of a constant.
if (constant) {
// Check the value and set the value.
String serverValue = this.propertyFormat.unformat(value);
// Check the client conditions.
CheckConditionResult result = isOk(serverValue);
if (!result.isOk()) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionError.NO_ERROR, result.getErrorMessage());
} else {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
CheckConditionResult conditionResult = isOk(serverValue);
if (!conditionResult.isOk()) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionError.NO_ERROR, conditionResult.getErrorMessage());
}
} else {
// Expression: first check it without setting it.
CommandZoneAccessor.ExpressionResult result = null;
if (isCommandBox) {
result = CommandZoneAccessor.getInstance(serverId).checkPropertyExpression(containerId, id, value);
} else {
// First check the expression without setting it.
result = CommandZoneAccessor.getInstance(serverId).checkStaticPropertyExpression(id, value);
}
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
return new ExpressionResult(ExpressionStatus.INVALID_EXPRESSION, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
} else {
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
else {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
}
}
else {
// The expression is valid.
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment