diff options
Diffstat (limited to 'src/main')
3 files changed, 59 insertions, 10 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java new file mode 100644 index 0000000..33a0e4a --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java @@ -0,0 +1,41 @@ +package at.knowcenter.wag.egov.egiz.cfg;
+
+import java.util.Properties;
+
+import at.gv.egiz.pdfas.api.sign.SignParameters;
+
+/**
+ * Thread local holder for profile override values.
+ * Don't use this class directly, use {@link SignParameters#setProfileOverrideValue(String, String)}
+ *
+ * @author exthex
+ *
+ */
+public class OverridePropertyHolder {
+
+ private static ThreadLocal propHolder = new ThreadLocal() {
+ protected Object initialValue() { return new Properties();};
+ };
+
+ public static Properties getOverrideProps() {
+ return (Properties) propHolder.get();
+ }
+
+ public static void setOverrideProps(Properties props) {
+ propHolder.set(props);
+ }
+
+ public static void setProperty(String key, String val) {
+ getOverrideProps().setProperty(key, val);
+ }
+
+ public static String getProperty(String key) {
+ return getOverrideProps().getProperty(key);
+ }
+
+ public static void removeProperties() {
+ propHolder.remove();
+ propHolder.set(new Properties());
+ }
+
+}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java index fd700fe..1922627 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/PropertyTree.java @@ -345,4 +345,8 @@ public class PropertyTree implements Serializable { }
return os;
}
+
+ public void removeEntry(String key) {
+ this.keys_.remove(key);
+ }
}
\ No newline at end of file diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java index f4c28c7..6151b24 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java @@ -465,7 +465,10 @@ public class SettingsReader implements Serializable */
public String getSetting(String key) throws SettingNotFoundException
{
- String result = properties_.getProperty(key);
+ String result = OverridePropertyHolder.getProperty(key);
+ if (result == null) {
+ result = properties_.getProperty(key);
+ }
if (result == null)
{
String log_message = "Configuration key not found: '" + key + "'! Check '" + settingsFile_ + "' file.";
@@ -476,10 +479,7 @@ public class SettingsReader implements Serializable SettingNotFoundException snf = new SettingNotFoundException(log_message);
throw snf;
}
-// if (logger_.isDebugEnabled())
-// {
-// logger_.debug("Get Property:" + key + "=" + result);
-// }
+
return result;
}
@@ -659,11 +659,11 @@ public class SettingsReader implements Serializable */
public String getValueFromKey(String key)
{
- String value = pTree_.getFirstValue(key);
-// if (logger_.isDebugEnabled())
-// {
-// logger_.debug("getValueFromKey:" + key + "=" + value);
-// }
+ String value = OverridePropertyHolder.getProperty(key);
+ if (value == null) {
+ value = pTree_.getFirstValue(key);
+ }
+
return value;
}
@@ -889,5 +889,9 @@ public class SettingsReader implements Serializable String paddingString = StringUtils.repeat("*", versionString.length());
logger_.info("PDF-AS info\n" + paddingString + "\n" + versionString + "\n" + paddingString);
}
+
+ public Properties getProperties() {
+ return this.properties_;
+ }
}
\ No newline at end of file |