aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java28
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java16
3 files changed, 39 insertions, 7 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
index 33a0e4a..049ce06 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java
@@ -3,6 +3,7 @@ package at.knowcenter.wag.egov.egiz.cfg;
import java.util.Properties;
import at.gv.egiz.pdfas.api.sign.SignParameters;
+import at.gv.egiz.pdfas.utils.OgnlUtil;
/**
* Thread local holder for profile override values.
@@ -16,6 +17,7 @@ public class OverridePropertyHolder {
private static ThreadLocal propHolder = new ThreadLocal() {
protected Object initialValue() { return new Properties();};
};
+ private static ThreadLocal ognlHolder = new ThreadLocal();
public static Properties getOverrideProps() {
return (Properties) propHolder.get();
@@ -30,12 +32,32 @@ public class OverridePropertyHolder {
}
public static String getProperty(String key) {
- return getOverrideProps().getProperty(key);
+
+ String res = getOverrideProps().getProperty(key);
+ if (res != null) {
+ OgnlUtil ognl = getOgnl();
+ if (ognl != null && ognl.containsExpression(res)) {
+ // evaluate expression
+ res = ognl.compileMessage(res);
+ }
+ }
+ return res;
}
- public static void removeProperties() {
- propHolder.remove();
+ public static void removeProperties() {
propHolder.set(new Properties());
}
+
+ public static void setOgnlUtil(OgnlUtil ognl) {
+ ognlHolder.set(ognl);
+ }
+
+ private static OgnlUtil getOgnl() {
+ return (OgnlUtil) ognlHolder.get();
+ }
+
+ public static void removeOgnlUtil() {
+ ognlHolder.set(null);
+ }
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
index 2782f2b..b62e504 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
@@ -53,6 +53,8 @@ public class SignatureEntry implements Serializable {
* The starting index position of the key if it is found in the signature text.
*/
private int startIndex_ = -1;
+
+ public boolean isPlaceholder = false;
/**
* The empty constructor.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
index 44363d7..25e996e 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
@@ -357,7 +357,11 @@ public class SignatureObject implements Serializable
* @return <code>true</code> if a new signature value is created,
* <code>false</code> otherwise
*/
- public boolean setSigValue(String key, String value)
+ public boolean setSigValue(String key, String value) {
+ return setSigValue(key, value, false);
+ }
+
+ public boolean setSigValue(String key, String value, boolean placeholder)
{
SignatureEntry sig_entry = null;
boolean is_new = false;
@@ -377,6 +381,7 @@ public class SignatureObject implements Serializable
value = removeAllWhiteSpaces(value);
}
sig_entry.setValue(value);
+ sig_entry.isPlaceholder = placeholder;
return is_new;
}
@@ -428,16 +433,19 @@ public class SignatureObject implements Serializable
{
String value = null;
+ SignatureEntry sigEntry = null;
if (sigEntries_.containsKey(key))
{
- value = ((SignatureEntry) sigEntries_.get(key)).getValue();
+ sigEntry = (SignatureEntry) sigEntries_.get(key);
+ value = sigEntry.getValue();
}
if (value == null && SignatureTypes.SIG_NORM.equals(key))
{
value = normalizer_.getVersion();
}
+
String overrideVal = OverridePropertyHolder.getProperty(key);
- if (overrideVal != null) {
+ if (value != null && sigEntry != null && !sigEntry.isPlaceholder && overrideVal != null) { // TODO this!! SignatureEntry.isPlaceholder
value = overrideVal;
if (logger_.isDebugEnabled()) {
logger_.debug("Using override property for key '" + key + "' = " + value);
@@ -1742,7 +1750,7 @@ public class SignatureObject implements Serializable
variable_fields.add(sfd);
- setSigValue(sfd.field_name, value_string);
+ setSigValue(sfd.field_name, value_string, true);
}
}