Commit 4a025bc0 authored by helene ortiz's avatar helene ortiz
Browse files

Modifications for 0-crash version

parent 40fb0e74
......@@ -32,6 +32,7 @@ public abstract class CommandAction {
protected static final Logger LOGGER = Logger.getLogger(CommandAction.class.getName());
public static final String START_COMMAND_NAME = ConfigManager.getInstance().getString("commandStart");
public static final String STOP_COMMAND_NAME = ConfigManager.getInstance().getString("commandStop");
public static final String PAUSE_COMMAND_NAME = ConfigManager.getInstance().getString("commandPause");
public static final String CONTINUE_COMMAND_NAME = ConfigManager.getInstance().getString("commandContinue");
......
......@@ -25,6 +25,8 @@ import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.command.AtomicCommandWrapper;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.servant.CorbaServant;
import fr.ill.ics.util.exception.CommandNotFoundException;
import fr.ill.ics.util.exception.ConfigurationException.PluginType;
public class CommandManager {
......@@ -42,7 +44,7 @@ public class CommandManager {
return instance;
}
public Command getCommand(Controller controller, String commandName) {
public Command getCommand(Controller controller, String commandName, boolean createExceptionIfNotFound, PluginType pluginType) throws CommandNotFoundException {
// Create a new Map of commandName:Command instance if it doesn't exist for the abstract controller
if (controllerCommands == null) {
......@@ -74,8 +76,10 @@ public class CommandManager {
}
}
if (command == null && createExceptionIfNotFound) {
throw new CommandNotFoundException(commandName, controller.getType(), controller.getName(), this.getClass().getCanonicalName(), "getCommand", pluginType);
}
return command;
}
}
\ No newline at end of file
......@@ -38,6 +38,7 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import fr.ill.ics.util.exception.CommandNotFoundException;
import fr.ill.ics.util.exception.ConfigurationException;
import fr.ill.ics.util.exception.ConfigurationException.PluginType;
import fr.ill.ics.util.exception.ParticularWidgetNotFoundException;
......@@ -495,6 +496,16 @@ public class ConfigManager {
set.add(pnfe);
}
} else if (configurationException instanceof CommandNotFoundException) {
CommandNotFoundException cnfe = (CommandNotFoundException)configurationException;
if (cnfe.getControllerName().equals(controllerName)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
set.add(cnfe);
}
} else if (configurationException instanceof ParticularWidgetNotFoundException) {
ParticularWidgetNotFoundException pwnfe = (ParticularWidgetNotFoundException)configurationException;
if (pwnfe.getControllerName().equals(controllerName)) {
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.util.exception;
import fr.ill.ics.util.ConfigManager;
/**
*
* @author ortizh
*
*/
public class CommandNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("commandNotFoundExceptionMessage");
private String controllerName;
private String commandName;
public CommandNotFoundException(String commandName, String controllerType, String controllerName, String className, String methodName) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.commandName = commandName;
this.controllerName = controllerName;
ConfigManager.getInstance().addConfigurationException(this);
}
public CommandNotFoundException(String commandName, String controllerType, String controllerName, String className, String methodName, PluginType pluginType) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName, pluginType);
this.commandName = commandName;
this.controllerName = controllerName;
ConfigManager.getInstance().addConfigurationException(this);
}
public String getControllerName() {
return controllerName;
}
public void setControllerName(String controllerName) {
this.controllerName = controllerName;
}
public String getCommandName() {
return commandName;
}
public void setCommandName(String commandName) {
this.commandName = commandName;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof CommandNotFoundException)) {
return false;
}
CommandNotFoundException commandNotFoundException = (CommandNotFoundException)object;
if (this.commandName.equals(commandNotFoundException.getCommandName()) && this.getPluginType() == commandNotFoundException.getPluginType()) {
if (this.controllerName != null) {
return (this.controllerName.equals(commandNotFoundException.getControllerName()));
}
return (this.controllerType.equals(commandNotFoundException.getControllerType()));
}
return false;
}
public int hashCode() {
return (this.getMessage() + this.getCommandName() + this.getControllerName() + this.getControllerType() + this.getPluginType()).hashCode();
}
public String toString() {
return getMessage() + commandName + (controllerName == null ? "" : " (controller name: " + controllerName +")") + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName() + " (" + getPluginType() + ")";
}
public String format() {
return getMessage() + " " + commandName;
}
protected void addToConfigManager() {
// Already called in constructor => must not do anything
}
}
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