...
 
Commits (4)
3.2.2 04/06/2019
------
* Added GetWholeDynamicProperties request to get the alias of dynamic properties.
* 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.
3.2.1 29/04/2019
------
* Overwritten equals method in Property class.
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>3.2.1-SNAPSHOT</version>
<version>3.2.2</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......
......@@ -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);
}
}
......
......@@ -38,13 +38,6 @@ public class ServerControlCommandBox extends ServerCommandBox {
public void setExpression(String expression) throws InvalidExpressionException {
ExpressionResult result = CommandZoneAccessor.getInstance(serverId).setExpression(commandBoxId, expression);
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
System.out.println("ServerControlCommandBox : Expression " + expression + " is " + result.getStatus() + ", error : " + result.getError() + ", message = " + result.getMessage());
}
else {
System.out.println("ServerControlCommandBox : Expression " + expression + " is " + result.getStatus());
}
}
public String getExpression() {
......