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