boolean isPreview = Boolean.parseBoolean(request.getParameter("isPreview"));
boolean isUserInteraction = Boolean.parseBoolean(request.getParameter("isUserInteraction"));
boolean isExecute = Boolean.parseBoolean(request.getParameter("execute"));
if (isUserInteraction) {
String commandId = request.getParameter("commandId");
Command currentCommand = (Command) ctrl.getWorkspace().getCommandHistory().getPreviewCommand(commandId);
try {
UpdateContainer updateContainer;
if (!isExecute)
updateContainer = ((IPreviewable) currentCommand).handleUserActions(request);
else {
((IPreviewable) currentCommand).handleUserActions(request);
updateContainer = ctrl.invokeCommand(currentCommand);
}
updateContainer.applyUpdates(vWorkspace);
responseString = updateContainer.generateJson(vWorkspace);
} catch (Exception e) {
responseString = getErrorMessage(vWorkspace, e);
}
}
else if (isPreview) {
Command command = ctrl.getCommand(request);
try {
UpdateContainer updateContainer = ((IPreviewable) command).showPreview(request);
ctrl.getWorkspace().getCommandHistory().addPreviewCommand(command);
updateContainer.applyUpdates(vWorkspace);
responseString = updateContainer.generateJson(vWorkspace);
} catch (CommandException e) {
responseString = getErrorMessage(vWorkspace, e);
}
}
else {
Command command = ctrl.getCommand(request);
try {
UpdateContainer updateContainer =ctrl.invokeCommand(command);
updateContainer.applyUpdates(vWorkspace);
responseString = updateContainer.generateJson(vWorkspace);
} catch(Exception e) {