aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java2
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java7
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java46
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ErrorPage.java6
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java8
5 files changed, 67 insertions, 2 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
index 6306852e..0fbd9163 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
@@ -143,7 +143,7 @@ public class WebConfiguration implements IConfigurationConstants {
}
File f = new File(pdfASDir);
-
+
if (!f.exists() || !f.isDirectory()) {
logger.error("Pdf As working directory does not exists or is not a directory!: "
+ pdfASDir);
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index 83dd2610..9e3fb3fe 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -746,6 +746,13 @@ public class PdfAsHelper {
return xml;
}
+ public static String getGenericTemplate() throws IOException {
+ String xml = FileUtils.readFileToString(FileUtils
+ .toFile(PdfAsHelper.class
+ .getResource("/template_generic_param.html")));
+ return xml;
+ }
+
public static String getInvokeRedirectTemplateSL() throws IOException {
String xml = FileUtils.readFileToString(FileUtils
.toFile(PdfAsHelper.class
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java
new file mode 100644
index 00000000..4c793524
--- /dev/null
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/UrlParameterExtractor.java
@@ -0,0 +1,46 @@
+package at.gv.egiz.pdfas.web.helper;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class UrlParameterExtractor {
+
+
+ public static Map<String, String> splitQuery(URL url) throws UnsupportedEncodingException {
+ Map<String, String> query_pairs = new LinkedHashMap<String, String>();
+ String query = url.getQuery();
+ String[] pairs = query.split("&");
+ for (String pair : pairs) {
+ int idx = pair.indexOf("=");
+ query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
+ }
+ return query_pairs;
+ }
+
+ public static String buildParameterFormString(URL url) throws IOException {
+ Map<String, String> query_pairs = splitQuery(url);
+ Iterator<Entry<String, String>> entryIt = query_pairs.entrySet().iterator();
+
+ if(query_pairs.isEmpty()) {
+ return "";
+ }
+ String genericTemplate = PdfAsHelper.getGenericTemplate();
+ StringBuilder sb = new StringBuilder();
+ while(entryIt.hasNext()) {
+ Entry<String, String> entry = entryIt.next();
+
+ String current = genericTemplate.replace("##NAME##", entry.getKey());
+ current = current.replace("##VALUE##", entry.getValue());
+ sb.append(current);
+ }
+
+ return sb.toString();
+ }
+
+}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ErrorPage.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ErrorPage.java
index 12693797..8e59ff1c 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ErrorPage.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ErrorPage.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.web.servlets;
import java.io.IOException;
+import java.net.URL;
import java.net.URLEncoder;
import javax.servlet.ServletException;
@@ -37,6 +38,7 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
import at.gv.egiz.pdfas.web.helper.HTMLFormater;
import at.gv.egiz.pdfas.web.helper.PdfAsHelper;
+import at.gv.egiz.pdfas.web.helper.UrlParameterExtractor;
/**
* Servlet implementation class ErrorPage
@@ -93,6 +95,10 @@ public class ErrorPage extends HttpServlet {
template = template.replace("##ERROR_URL##",
errorURL);
+ URL url = new URL(errorURL);
+ String extraParams = UrlParameterExtractor.buildParameterFormString(url);
+ template = template.replace("##ADD_PARAMS##", extraParams);
+
String target = PdfAsHelper.getInvokeTarget(request, response);
if(target == null) {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java
index 1ee96602..7909e926 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.web.servlets;
import java.io.IOException;
+import java.net.URL;
import java.net.URLEncoder;
import javax.servlet.ServletException;
@@ -37,6 +38,7 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
import at.gv.egiz.pdfas.web.helper.PdfAsHelper;
+import at.gv.egiz.pdfas.web.helper.UrlParameterExtractor;
/**
* Servlet implementation class ProvidePDF
@@ -95,7 +97,11 @@ public class ProvidePDFServlet extends HttpServlet {
// Redirect Browser
String template = PdfAsHelper.getInvokeRedirectTemplateSL();
template = template.replace("##INVOKE_URL##", invokeURL);
-
+
+ URL url = new URL(invokeURL);
+ String extraParams = UrlParameterExtractor.buildParameterFormString(url);
+ template = template.replace("##ADD_PARAMS##", extraParams);
+
byte[] signedData = PdfAsHelper.getSignedPdf(request, response);
if (signedData != null) {
template = template.replace("##PDFLENGTH##",