Commit 8b3dca65 authored by yannick legoc's avatar yannick legoc

Correction of the CommandBoxNotFoundException in log: do not access to the...

Correction of the CommandBoxNotFoundException in log: do not access to the command zone value of a property when its containerId is 0. Better identification of the BreakCommandBox when retrieving the list of command boxes by GetCommandList
parent bdedda6a
......@@ -300,8 +300,11 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
}
public String getServerValue() {
try {
if (isCommandBox) {
// Do get the command zone value when containerId is 0 (command box ID), because it cannot success.
// This test prevents from bad access when the property is just created and has no command box ID.
if (isCommandBox && containerId != 0) {
// Get the value from the command zone and format it.
return this.propertyFormat.formatForDisplay(CommandZoneAccessor.getInstance(serverId).getStringValue(containerId, id));
} else {
......
......@@ -45,7 +45,7 @@ public class CommandZoneAccessor {
private Map<Integer, Boolean> commandConflicts = new HashMap<Integer, Boolean>();
public enum ExecutionPhaseState {CONSTRUCTION, RUNNING, FINISHED, PAUSED};
public enum ContainerType {COMMANDZONE, IFTHEN, IFELSE, FORLOOP, SCAN};
public enum ContainerType {COMMANDZONE, IFTHEN, BREAK, IFELSE, FORLOOP, SCAN};
public enum ForLoopType {RANGE, VALUES};
public enum ExpressionStatus {VALID_EXPRESSION, INVALID_EXPRESSION};
public enum ExpressionError {NO_ERROR, PARSER_ERROR, DISABLED_CONTROLLER_ERROR, ENUMERATED_VALUE_ERROR, UNDEFINED_VARIABLE_ERROR};
......@@ -1516,7 +1516,13 @@ public class CommandZoneAccessor {
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.GENERIC) {
content.add(new ServerGenericCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.CONTROL) {
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.IFTHEN) {
content.add(new ServerControlCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.BREAK) {
content.add(new ServerBreakCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.IFTHENELSE) {
content.add(new ServerControlCommandBox(serverId, id));
}
......
......@@ -18,7 +18,7 @@
package fr.ill.ics.nscclient.command;
import java.util.Set;
public class ServerBreakCommandBox extends ServerControlCommandBox {
......@@ -30,4 +30,74 @@ public class ServerBreakCommandBox extends ServerControlCommandBox {
return 1;
}
public Set<ServerCommandBox> getContent(boolean thenBlock) {
// Must never be called.
return null;
}
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(boolean thenBlock, int commandID, boolean isSettings) {
// Must never be called.
return null;
}
public ServerAtomicCommandBox addNewAtomicCommandBox(boolean thenBlock, int commandID, boolean isSettings, ServerCommandBox commandBoxToMove, boolean above) {
// Must never be called.
return null;
}
public ServerScanCommandBox addNewScanCommandBoxAtEnd(boolean thenBlock, String scanName) {
// Must never be called.
return null;
}
public ServerScanCommandBox addNewScanCommandBox(boolean thenBlock, String scanName, ServerCommandBox commandBoxToMove, boolean above) {
// Must never be called.
return null;
}
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(boolean thenBlock, String variableName) {
// Must never be called.
return null;
}
public ServerForLoopCommandBox addNewForLoopCommandBox(boolean thenBlock, String variableName, ServerCommandBox commandBoxToMove, boolean above) {
// Must never be called.
return null;
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int boxType) {
// Must never be called.
return null;
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int boxType, ServerCommandBox commandBoxToMove, boolean above) {
// Must never be called.
return null;
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int boxType) {
// Must never be called.
return null;
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int boxType, ServerCommandBox commandBoxToMove, boolean above) {
// Must never be called.
return null;
}
public boolean moveCommandBox(boolean thenBlock, ServerCommandBox commandBoxToMove, ServerCommandBox commandBoxToShift, boolean above) {
// Must never be called.
return false;
}
public boolean moveCommandBoxToEnd(boolean thenBlock, ServerCommandBox commandBoxToMove) {
// Must never be called.
return false;
}
public boolean deleteCommandBox(boolean thenBlock, ServerCommandBox commandBoxToDelete) {
// Must never be called.
return false;
}
}
\ No newline at end of file
......@@ -28,12 +28,31 @@ import fr.ill.ics.nscclient.command.CommandZoneAccessor.InvalidExpressionExcepti
public class ServerControlCommandBox extends ServerCommandBox {
public final static int IF_BOX = 0;
public final static int BREAK_BOX = 1;
public final static int IF_ELSE_BOX = 2;
private int boxType;
public ServerControlCommandBox(String serverId, int commandBoxId) {
super(serverId, commandBoxId);
boxType = CommandZoneAccessor.getInstance(serverId).getBoxType(commandBoxId);
}
private CommandZoneAccessor.ContainerType convertContainerType(boolean thenBlock) {
return (thenBlock ? CommandZoneAccessor.ContainerType.IFTHEN : CommandZoneAccessor.ContainerType.IFELSE);
private CommandZoneAccessor.ContainerType getContainerType() {
switch (boxType) {
case IF_BOX:
return CommandZoneAccessor.ContainerType.IFTHEN;
case BREAK_BOX:
return CommandZoneAccessor.ContainerType.BREAK;
case IF_ELSE_BOX:
return CommandZoneAccessor.ContainerType.IFELSE;
}
return CommandZoneAccessor.ContainerType.IFTHEN;
}
public void setExpression(String expression) throws InvalidExpressionException {
......@@ -45,63 +64,63 @@ public class ServerControlCommandBox extends ServerCommandBox {
}
public int getBoxType() {
return CommandZoneAccessor.getInstance(serverId).getBoxType(commandBoxId);
return boxType;
}
public Set<ServerCommandBox> getContent(boolean thenBlock) {
return CommandZoneAccessor.getInstance(serverId).getContent(convertContainerType(thenBlock), commandBoxId);
return CommandZoneAccessor.getInstance(serverId).getContent(getContainerType(), commandBoxId);
}
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(boolean thenBlock, int commandID, boolean isSettings) {
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, commandID, isSettings);
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBoxAtEnd(getContainerType(), commandBoxId, commandID, isSettings);
}
public ServerAtomicCommandBox addNewAtomicCommandBox(boolean thenBlock, int commandID, boolean isSettings, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBox(convertContainerType(thenBlock), commandBoxId, commandID, isSettings, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBox(getContainerType(), commandBoxId, commandID, isSettings, commandBoxToMove.getId(), above);
}
public ServerScanCommandBox addNewScanCommandBoxAtEnd(boolean thenBlock, String scanName) {
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, scanName);
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBoxAtEnd(getContainerType(), commandBoxId, scanName);
}
public ServerScanCommandBox addNewScanCommandBox(boolean thenBlock, String scanName, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBox(convertContainerType(thenBlock), commandBoxId, scanName, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBox(getContainerType(), commandBoxId, scanName, commandBoxToMove.getId(), above);
}
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(boolean thenBlock, String variableName) {
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, variableName);
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBoxAtEnd(getContainerType(), commandBoxId, variableName);
}
public ServerForLoopCommandBox addNewForLoopCommandBox(boolean thenBlock, String variableName, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBox(convertContainerType(thenBlock), commandBoxId, variableName, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBox(getContainerType(), commandBoxId, variableName, commandBoxToMove.getId(), above);
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int boxType) {
return CommandZoneAccessor.getInstance(serverId).addNewGenericCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, boxType);
return CommandZoneAccessor.getInstance(serverId).addNewGenericCommandBoxAtEnd(getContainerType(), commandBoxId, boxType);
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int boxType, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewGenericCommandBox(convertContainerType(thenBlock), commandBoxId, boxType, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewGenericCommandBox(getContainerType(), commandBoxId, boxType, commandBoxToMove.getId(), above);
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int boxType) {
return CommandZoneAccessor.getInstance(serverId).addNewControlCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, boxType);
return CommandZoneAccessor.getInstance(serverId).addNewControlCommandBoxAtEnd(getContainerType(), commandBoxId, boxType);
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int boxType, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewControlCommandBox(convertContainerType(thenBlock), commandBoxId, boxType, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewControlCommandBox(getContainerType(), commandBoxId, boxType, commandBoxToMove.getId(), above);
}
public boolean moveCommandBox(boolean thenBlock, ServerCommandBox commandBoxToMove, ServerCommandBox commandBoxToShift, boolean above) {
return CommandZoneAccessor.getInstance(serverId).moveCommandBox(convertContainerType(thenBlock), commandBoxId, commandBoxToMove.getId(), commandBoxToShift.getId(), above);
return CommandZoneAccessor.getInstance(serverId).moveCommandBox(getContainerType(), commandBoxId, commandBoxToMove.getId(), commandBoxToShift.getId(), above);
}
public boolean moveCommandBoxToEnd(boolean thenBlock, ServerCommandBox commandBoxToMove) {
return CommandZoneAccessor.getInstance(serverId).moveCommandBoxToEnd(convertContainerType(thenBlock), commandBoxId, commandBoxToMove.getId());
return CommandZoneAccessor.getInstance(serverId).moveCommandBoxToEnd(getContainerType(), commandBoxId, commandBoxToMove.getId());
}
public boolean deleteCommandBox(boolean thenBlock, ServerCommandBox commandBoxToDelete) {
return CommandZoneAccessor.getInstance(serverId).deleteCommandBox(convertContainerType(thenBlock), commandBoxId, commandBoxToDelete.getId());
return CommandZoneAccessor.getInstance(serverId).deleteCommandBox(getContainerType(), commandBoxId, commandBoxToDelete.getId());
}
public int getNumberOfCommandBoxes() {
......
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