aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-01 14:02:31 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-01 14:02:31 +0000
commita4f9018bf6a9fd74312ad62a3633a71a9724f3ab (patch)
tree0fc521352559bb102c105496100ad9c7b9a1d1ec /src/main/java/at/knowcenter
parent23b3cb0f072ccbe12163dc25e10da64baeec2f54 (diff)
downloadpdf-as-3-a4f9018bf6a9fd74312ad62a3633a71a9724f3ab.tar.gz
pdf-as-3-a4f9018bf6a9fd74312ad62a3633a71a9724f3ab.tar.bz2
pdf-as-3-a4f9018bf6a9fd74312ad62a3633a71a9724f3ab.zip
fixed override properties for binsig with placeholders
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@659 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter')
-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);
}
}