private static MirPropertiesConfiguration instance;
private static ServletContext context;
private static String contextPath;
+
+ //if one of these properties is not present a new
+ //emtpy property is added
+ private String[] needed = {"Producer.DocRoot"};
/**
* Constructor for MirPropertiesConfiguration.
throws IOException {
super(ctx.getRealPath("/WEB-INF/etc/") + "/config.properties",
ctx.getRealPath("/WEB-INF/etc/") + "/default.properties");
- this.addProperty("Home", ctx.getRealPath("/WEB-INF/") + "/");
+ addProperty("Home", ctx.getRealPath("/WEB-INF/") + "/");
+ checkMissing();
}
public static synchronized MirPropertiesConfiguration instance()
while (iterator.hasNext()) {
String key = (String) iterator.next();
- returnMap.put(key, this.getProperty(key));
+ Object o = this.getString(key);
+ if(o == null){
+ o = new Object();
+ }
+ returnMap.put(key, o);
}
return returnMap;
return getString("Home") + returnString;
}
+ private void checkMissing(){
+ for(int i = 0; i < needed.length; i++){
+ if(super.getProperty(needed[i]) == null){
+ addProperty(needed[i],"");
+ }
+ }
+ }
+
public File getFile(String key) throws FileNotFoundException {
String path = getStringWithHome(key);
File returnFile = new File(path);
if (super.getString(key) == null) {
return new String();
}
-
return super.getString(key);
}
+
+ /**
+ * @see org.apache.commons.configuration.Configuration#getString(java.lang.String)
+ */
+ public Object getProperty(String key) {
+ if (super.getProperty(key) == null) {
+ return new String();
+ }
+ return super.getProperty(key);
+ }
/**
* @author idefix