Commit ffc64272 authored by helene ortiz's avatar helene ortiz
Browse files

No commit message

No commit message
parent b3ac1340
...@@ -557,10 +557,10 @@ public class PropertyManager { ...@@ -557,10 +557,10 @@ public class PropertyManager {
* @param propertyName * @param propertyName
* @return * @return
*/ */
public Property getDynamicPropertyChild(Controller controller, String realPropertyName) { public Property getDynamicPropertyChild(Controller controller, String realPropertyName) throws PropertyNotFoundException {
String parentPropertyName = realPropertyName.substring(0, realPropertyName.lastIndexOf(".")); String parentPropertyName = realPropertyName.substring(0, realPropertyName.lastIndexOf("."));
int index = Integer.parseInt(realPropertyName.substring(realPropertyName.lastIndexOf(".")+1)); int index = Integer.parseInt(realPropertyName.substring(realPropertyName.lastIndexOf(".")+1));
Property property = null;
if (controller instanceof CorbaServant) { if (controller instanceof CorbaServant) {
if (dynamicPropertyMap == null || !this.dynamicPropertyMap.containsKey(((CorbaServant)controller).getId())) { if (dynamicPropertyMap == null || !this.dynamicPropertyMap.containsKey(((CorbaServant)controller).getId())) {
createDynamicPropertiesForController((CorbaServant)controller); createDynamicPropertiesForController((CorbaServant)controller);
...@@ -570,21 +570,27 @@ public class PropertyManager { ...@@ -570,21 +570,27 @@ public class PropertyManager {
DynamicProperty dynamicProperty = map.get(parentPropertyName); DynamicProperty dynamicProperty = map.get(parentPropertyName);
if (dynamicProperty != null) { if (dynamicProperty != null) {
if (dynamicProperty.getProperties().size() > index) { if (dynamicProperty.getProperties().size() > index) {
return (Property)dynamicProperty.getProperties().toArray()[index]; property = (Property)dynamicProperty.getProperties().toArray()[index];
} }
} }
return null;
} }
return null; } else {
if (property == null) {
property = getDynamicPropertyForCommandBox((AtomicCommandWrapper)controller, realPropertyName);
}
} }
return getDynamicPropertyForCommandBox((AtomicCommandWrapper)controller, realPropertyName); if (property == null) {
PropertyNotFoundException pnfe = new PropertyNotFoundException(realPropertyName, controller.getType(), controller.getName(), getClass().getCanonicalName(), "getDynamicPropertyChild");
throw pnfe;
}
return property;
} }
/** /**
* Search dynamic property * Search dynamic property
*/ */
public Property getDynamicProperty(Controller controller, String propertyName) { public Property getDynamicProperty(Controller controller, String propertyName) throws PropertyNotFoundException {
String parentPropertyName = propertyName.substring(0, propertyName.lastIndexOf(".")); String parentPropertyName = propertyName.substring(0, propertyName.lastIndexOf("."));
int index = Integer.parseInt(propertyName.substring(propertyName.lastIndexOf(".")+1)); int index = Integer.parseInt(propertyName.substring(propertyName.lastIndexOf(".")+1));
...@@ -600,9 +606,9 @@ public class PropertyManager { ...@@ -600,9 +606,9 @@ public class PropertyManager {
return (Property)dynamicProperty.getProperties().toArray()[index]; return (Property)dynamicProperty.getProperties().toArray()[index];
} }
} }
return null;
} }
return null; PropertyNotFoundException pnfe = new PropertyNotFoundException(propertyName, controller.getType(), controller.getName(), getClass().getCanonicalName(), "getDynamicProperty");
throw pnfe;
} }
......
...@@ -34,6 +34,7 @@ import fr.ill.ics.bridge.ControllerManager; ...@@ -34,6 +34,7 @@ import fr.ill.ics.bridge.ControllerManager;
import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener; import fr.ill.ics.bridge.listeners.ServerConfigurationChangeListener;
import fr.ill.ics.nscclient.dataprovider.ServantDatabase; import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager; import fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager;
import fr.ill.ics.util.exception.ControllerNotFoundException;
public class CorbaControllerManager extends ControllerManager implements ServerConfigurationChangeListener { public class CorbaControllerManager extends ControllerManager implements ServerConfigurationChangeListener {
...@@ -75,6 +76,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -75,6 +76,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
CorbaController controller = servantManager.getController(descriptor); CorbaController controller = servantManager.getController(descriptor);
return controller; return controller;
} }
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "getController");
return null; return null;
} }
...@@ -84,6 +86,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -84,6 +86,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
CorbaController controller = servantManager.cloneController(descriptor); CorbaController controller = servantManager.cloneController(descriptor);
return controller; return controller;
} }
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "cloneController");
return null; return null;
} }
...@@ -283,13 +286,13 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -283,13 +286,13 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
servantManager.updateDynamicProperties(servantID); servantManager.updateDynamicProperties(servantID);
} }
@Override
public void reloadControllers() { public void reloadControllers() {
// reset controller information // reset controller information
reset(); reset();
} }
@Override
public String getControllerNameWithRole(Controller controller, String role) { public String getControllerNameWithRole(Controller controller, String role) {
CorbaController corbaController = (CorbaController)controller; CorbaController corbaController = (CorbaController)controller;
return servantManager.getControllerNameWithRole(corbaController.getId(), role); return servantManager.getControllerNameWithRole(corbaController.getId(), role);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
*/ */
package fr.ill.ics.util.exception; package fr.ill.ics.util.exception;
import fr.ill.ics.util.ConfigManager;
/** /**
* *
* @author ortizh * @author ortizh
...@@ -35,6 +37,7 @@ public class ConfigurationException extends Exception { ...@@ -35,6 +37,7 @@ public class ConfigurationException extends Exception {
this.controllerType = controllerType; this.controllerType = controllerType;
this.className = className; this.className = className;
this.methodName = methodName; this.methodName = methodName;
addToConfigManager();
} }
...@@ -96,4 +99,9 @@ public class ConfigurationException extends Exception { ...@@ -96,4 +99,9 @@ public class ConfigurationException extends Exception {
public String format() { public String format() {
return getMessage() + ((dynamicPropertyNamePrefix != null) ? " " + dynamicPropertyNamePrefix : ""); return getMessage() + ((dynamicPropertyNamePrefix != null) ? " " + dynamicPropertyNamePrefix : "");
} }
protected void addToConfigManager() {
ConfigManager.getInstance().addConfigurationException(this);
}
} }
/*
* 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 ControllerNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("controllerNotFoundExceptionMessage");
private String controllerName;
public ControllerNotFoundException(String controllerName, String controllerType, String className, String methodName) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.controllerName = controllerName;
ConfigManager.getInstance().addConfigurationException(this);
}
private String getControllerName() {
return controllerName;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof ControllerNotFoundException)) {
return false;
}
ControllerNotFoundException controllerNotFoundException = (ControllerNotFoundException)object;
if (this.controllerName.equals(controllerNotFoundException.getControllerName())) {
if (this.controllerName != null) {
return (this.controllerName.equals(controllerNotFoundException.getControllerName()));
}
return (this.controllerType.equals(controllerNotFoundException.getControllerType()));
}
return false;
}
public int hashCode() {
return (this.getMessage() + this.getControllerName() + this.getControllerType()).hashCode();
}
protected void addToConfigManager() {
// Already called in constructor => must not do anything
}
public String toString() {
return getMessage() + controllerName + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName();
}
public String format() {
return getMessage() + " " + 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 DriverNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("driverNotFoundExceptionMessage");
private String driverName;
public DriverNotFoundException(String driverName, String driverType, String className, String methodName) {
super(DEFAULT_MESSAGE, driverType, null, className, methodName);
this.driverName = driverName;
ConfigManager.getInstance().addConfigurationException(this);
}
private String getDriverName() {
return driverName;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof DriverNotFoundException)) {
return false;
}
DriverNotFoundException controllerNotFoundException = (DriverNotFoundException)object;
if (this.driverName.equals(controllerNotFoundException.getDriverName())) {
if (this.driverName != null) {
return (this.driverName.equals(controllerNotFoundException.getDriverName()));
}
return (this.controllerType.equals(controllerNotFoundException.getControllerType()));
}
return false;
}
public int hashCode() {
return (this.getMessage() + this.getDriverName() + this.getControllerType()).hashCode();
}
protected void addToConfigManager() {
// Already called in constructor => must not do anything
}
public String toString() {
return getMessage() + driverName + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName();
}
public String format() {
return getMessage() + " " + driverName;
}
}
...@@ -97,4 +97,8 @@ public class PropertyNotFoundException extends ConfigurationException { ...@@ -97,4 +97,8 @@ public class PropertyNotFoundException extends ConfigurationException {
public String format() { public String format() {
return getMessage() + " " + propertyName; return getMessage() + " " + propertyName;
} }
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