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", "Producer.ImageRoot", "Producer.Image.Path",
+ "Producer.Media.Path", "Producer.RealMedia.Path", "Producer.Image.IconPath"
+ };
+
//if one of these properties is not present a new
//emtpy property is added
- private String[] needed = {"Producer.DocRoot"};
+ private String[] neededWithValue = { "" };
/**
* Constructor for MirPropertiesConfiguration.
MirPropertiesConfiguration.context = context;
}
+ /**
+ * Returns the context.
+ * @return ServletContext
+ */
+ public static ServletContext getContext() {
+ return context;
+ }
+
+ /**
+ * Returns all properties in a Map
+ * @return Map
+ */
public Map allSettings() {
Iterator iterator = this.getKeys();
Map returnMap = new HashMap();
while (iterator.hasNext()) {
String key = (String) iterator.next();
Object o = this.getString(key);
- if(o == null){
- o = new Object();
+
+ if (o == null) {
+ o = new Object();
}
+
returnMap.put(key, o);
}
return returnMap;
}
+
/**
- * Returns the context.
- * @return ServletContext
+ * Returns a String-property concatenated with the home-dir of the
+ * installation
+ * @param key
+ * @return String
*/
- public static ServletContext getContext() {
- return context;
- }
-
public String getStringWithHome(String key) {
String returnString = getString(key);
return getString("Home") + returnString;
}
- private void checkMissing(){
- for(int i = 0; i < needed.length; i++){
- if(super.getProperty(needed[i]) == null){
- addProperty(needed[i],"");
- }
- }
+ /**
+ * Checks if one property is missing and adds a default value
+ */
+ 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)
*/
if (super.getProperty(key) == null) {
return new String();
}
+
return super.getProperty(key);
}