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

Modifications for 0-crash version

parent 511f7bbf
......@@ -271,8 +271,7 @@ public class PropertyManager {
property = getPropertyForCommandBox((AtomicCommandWrapper)controller, propertyName);
}
if (property == null) {
PropertyNotFoundException pnfe = new PropertyNotFoundException(propertyName, controller.getType(), controller.getName());
ConfigManager.getInstance().addConfigurationException(pnfe);
PropertyNotFoundException pnfe = new PropertyNotFoundException(propertyName, controller.getType(), controller.getName(), getClass().getCanonicalName(), "getProperty");
throw pnfe;
}
return property;
......@@ -1020,9 +1019,8 @@ public class PropertyManager {
String genericPropertyName = propertyName.substring(0, propertyName.indexOf("."));
exists = dynamicPropertiesByControllerType.get(controllerType).containsKey(genericPropertyName);
} else {
exists = propertiesByControllerType.get(controllerType).containsKey(propertyName);
exists = (propertiesByControllerType.containsKey(controllerType)) && (propertiesByControllerType.get(controllerType).containsKey(propertyName));
}
return exists;
}
}
......@@ -79,7 +79,13 @@ public class CorbaResourceManager extends ResourceManager {
}
public void setFileContent(String controllerType, String fileName, String content) {
servantManager.writeResourceFile(controllerType, fileName, content);
System.out.println("H.ORTIZ: call to writeResourceFile commented .................................................." + fileName);
// servantManager.writeResourceFile(controllerType, fileName, content);
/*
String fullFilePath = "/home/dpt/ortizh/tmp/" + fileName;
if (!new File(fullFilePath).exists()) {
......
......@@ -39,6 +39,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import fr.ill.ics.util.exception.ConfigurationException;
import fr.ill.ics.util.exception.PropertyNotFoundException;
/**
*
......@@ -95,9 +96,9 @@ public class ConfigManager {
private Set<String> instrumentsAllowingPALFiles;
public static boolean CONFIGURATION_ERROR = false;
private static Set<ConfigurationException> configurationExceptions;
/**
* @return the unique instance of this class
......@@ -458,30 +459,47 @@ public class ConfigManager {
public String toString() {
return "ConfigManager preferences = " + preferences + "\n\n properties = " + properties;
}
public void addConfigurationException(ConfigurationException configurationException) {
if (configurationExceptions == null) {
configurationExceptions = new HashSet<ConfigurationException>();
}
if (configurationExceptions.add(configurationException)) {
System.out.println("Exception added: " + configurationException);
// First time for this property
System.out.println("Exception added: " + configurationException + " FROM " + configurationException.getClassName() + ".." + configurationException.getMethodName());
} else {
configurationException.setFirst(false);
}
}
public Set<ConfigurationException> getConfigurationExceptionsForControllerType(String controllerType) {
Set<ConfigurationException> set = new HashSet<ConfigurationException>();
for (ConfigurationException configurationException : configurationExceptions) {
if (configurationException.getControllerType().equals(controllerType)) {
set.add(configurationException);
public Set<ConfigurationException> getConfigurationExceptions(String controllerType, String controllerName) {
Set<ConfigurationException> set = null;
if (configurationExceptions != null) {
for (ConfigurationException configurationException : configurationExceptions) {
if (configurationException instanceof PropertyNotFoundException) {
PropertyNotFoundException pnfe = (PropertyNotFoundException)configurationException;
if (pnfe.getControllerType().equals(controllerType) && pnfe.getControllerName().equals(controllerName)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
set.add(pnfe);
}
} else if (configurationException instanceof ConfigurationException) {
if (configurationException.getControllerType().equals(controllerType)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
set.add(configurationException);
}
}
}
}
return set;
}
}
......@@ -22,13 +22,19 @@ package fr.ill.ics.util.exception;
* @author ortizh
*
*/
public abstract class ConfigurationException extends Exception {
public class ConfigurationException extends Exception {
protected String controllerType;
private String dynamicPropertyNamePrefix;
private String className;
private String methodName;
private boolean first = true;
public ConfigurationException(String message, String controllerType) {
public ConfigurationException(String message, String controllerType, String dynamicPropertyNamePrefix, String className, String methodName) {
super(message);
this.controllerType = controllerType;
this.className = className;
this.methodName = methodName;
}
......@@ -40,5 +46,54 @@ public abstract class ConfigurationException extends Exception {
public void setControllerType(String controllerType) {
this.controllerType = controllerType;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof ConfigurationException)) {
return false;
}
ConfigurationException configurationException = (ConfigurationException)object;
if (this.controllerType.equals(configurationException.getControllerType())) {
return (this.getMessage().equals(configurationException.getMessage()));
}
return false;
}
public int hashCode() {
return (this.getMessage() + this.getControllerType()).hashCode();
}
public String toString() {
return getMessage() + " (controller type: " + controllerType +")";
}
public String getClassName() {
return className;
}
public String getMethodName() {
return methodName;
}
public void setFirst(boolean first) {
this.first = first;
}
public boolean isFirst() {
return first;
}
public String format() {
return getMessage() + ((dynamicPropertyNamePrefix != null) ? " " + dynamicPropertyNamePrefix : "");
}
}
......@@ -29,19 +29,20 @@ public class PropertyNotFoundException extends ConfigurationException {
private final static String DEFAULT_MESSAGE = ConfigManager.getInstance().getString("propertyNotFoundExceptionMessage");
private String controllerName;
private String propertyName;
public PropertyNotFoundException(String message, String propertyName, String controllerType, String controllerName) {
super(message, controllerType);
public PropertyNotFoundException(String message, String propertyName, String controllerType, String controllerName, String className, String methodName) {
super(message, controllerType, null, className, methodName);
this.propertyName = propertyName;
this.controllerName = controllerName;
ConfigManager.getInstance().addConfigurationException(this);
}
public PropertyNotFoundException(String propertyName, String controllerType, String controllerName) {
super(DEFAULT_MESSAGE, controllerType);
public PropertyNotFoundException(String propertyName, String controllerType, String controllerName, String className, String methodName) {
super(DEFAULT_MESSAGE, controllerType, null, className, methodName);
this.propertyName = propertyName;
this.controllerName = controllerName;
this.controllerType = controllerType;
ConfigManager.getInstance().addConfigurationException(this);
}
......@@ -90,6 +91,10 @@ public class PropertyNotFoundException extends ConfigurationException {
public String toString() {
return getMessage() + propertyName + (controllerName == null ? "" : " (controller name: " + controllerName +")") + (controllerType == null ? "" : " (controller type: " + controllerType +")");
return getMessage() + propertyName + (controllerName == null ? "" : " (controller name: " + controllerName +")") + (controllerType == null ? "" : " (controller type: " + controllerType +")") + "\n" + getClassName() + ".." + getMethodName();
}
public String format() {
return getMessage() + " " + propertyName;
}
}
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