aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 16:34:52 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 16:34:52 +0000
commit29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d (patch)
tree5b75b34c822a79f70b83c266465dda70b9baeaf2 /pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java
parent04375406fc1634adbf9b37143a2125327da6a11e (diff)
downloadpdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.tar.gz
pdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.tar.bz2
pdf-as-3-29ad090c29567ff1a4d3a2ec9b8ad0b5d80ee24d.zip
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@671 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java196
1 files changed, 196 insertions, 0 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java
new file mode 100644
index 0000000..bc768b4
--- /dev/null
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/FormFields.java
@@ -0,0 +1,196 @@
+/**
+ * <copyright> Copyright (c) 2006 by Know-Center, Graz, Austria </copyright>
+ *
+ * This software is the confidential and proprietary information of Know-Center,
+ * Graz, Austria. You shall not disclose such Confidential Information and shall
+ * use it only in accordance with the terms of the license agreement you entered
+ * into with Know-Center.
+ *
+ * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
+ * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES.
+ *
+ * $Id: FormFields.java,v 1.4 2006/10/11 07:39:13 wprinz Exp $
+ */
+package at.gv.egiz.pdfas.web;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import at.gv.egiz.pdfas.api.PdfAs;
+import at.gv.egiz.pdfas.api.commons.SignatureProfile;
+import at.gv.egiz.pdfas.api.internal.PdfAsInternal;
+import at.gv.egiz.pdfas.web.helper.ApiHelper;
+import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
+
+/**
+ * Helper class that provides methods and constants for creating and dealing
+ * with the various form fields.
+ *
+ * @author wprinz
+ */
+public abstract class FormFields
+{
+ public static final String FIELD_UPLOAD = "upload";
+
+ public static final String FIELD_CONNECTOR = "connector";
+
+ public static final String FIELD_MODE = "mode";
+
+ public static final String FIELD_PREVIEW = "preview";
+
+ public static final String FIELD_RAW_DOCUMENT_TEXT = "raw_document_text";
+
+ public static final String FIELD_SIGNATURE_TYPE = "sig_type";
+
+ // tknall: PDF/A-1b enabled
+ public static final String FIELD_PDFA_ENABLED = "pdfa_enabled";
+
+ public static final String FIELD_VERIFY_WHICH = "verify_which";
+
+ public static final String FIELD_SIGNED_TEXT = "signed_text";
+
+ public static final String FIELD_DOWNLOAD = "download";
+
+ public static final String VALUE_TRUE = "true";
+
+ public static final String VALUE_FALSE = "false";
+
+ public static final String VALUE_MODE_BINARY = "binary";
+
+ public static final String VALUE_MODE_TEXTUAL = "textual";
+
+ public static final String VALUE_MODE_DETACHED = "detached";
+
+ public static final String VALUE_VERIFY_WHICH_ALL = "all";
+
+ public static final String VALUE_DOWNLOAD_INLINE = "inline";
+
+ public static final String VALUE_DOWNLOAD_ATTACHMENT = "attachment";
+
+ protected static final String STYLE_CLASS_FIELD = "field";
+
+ // tzefferer: added fields for URL requests
+
+ public static final String FIELD_FILENAME = "filename";
+
+ public static final String FIELD_PDF_URL = "pdf-url";
+
+ public static final String FIELD_PDF_ID = "pdf-id";
+
+ public static final String FIELD_PDFAS_SESSION_ID = "pdfas-session-id";
+
+ public static final String FIELD_FILE_LENGTH = "num-bytes";
+
+ public static final String FIELD_INVOKE_APP_URL = "invoke-app-url";
+
+ public static final String FIELD_INVOKE_APP_ERROR_URL = "invoke-app-error-url";
+
+ public static final String FIELD_SESSION_ID = "session-id";
+
+ public static final String FIELD_SIGPOS_Y = "sig-pos-y";
+
+ public static final String FIELD_SIGPOS_P = "sig-pos-p";
+
+ public static final String FIELD_SOURCE = "source_filefreetext";
+
+ public static final String VALUE_SOURCE_FILE = "source-is-file";
+
+ public static final String VALUE_SOURCE_FREETEXT = "source-is-freetext";
+
+ public static final String FIELD_FREETEXT = "freetext";
+
+ // end add
+ /**
+ * The settings key prefix for signature definitions. <code>"sig_obj."</code>
+ */
+ public static final String SIG_OBJ = "sig_obj.";
+
+ /**
+ * The settings key postfix for the type description
+ */
+ public static final String SIG_DESCR = "description";
+
+
+ /**
+ * Generates the HTML snippet of a FIELD_CONNECTOR select box that allows to
+ * choose a connector.
+ *
+ * @return Returns the HTML snippet.
+ * @throws SettingsException
+ * Forwarded exception.
+ * @throws ConnectorFactoryException
+ * Forwarded exception.
+ */
+ public static String generateConnectorSelectBox(ServletContext sc) throws ConnectorFactoryException
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter writer = new PrintWriter(sw);
+
+ writer.println("<select name=\"" + FIELD_CONNECTOR + "\" class=\"" + STYLE_CLASS_FIELD + "\">");
+
+ PdfAsInternal pdfAsInternal = ApiHelper.getPdfAsInternalFromContext(sc);
+ Map webConnectors = pdfAsInternal.getConnectorsAvailableForWeb();
+
+ Iterator ids = webConnectors.keySet().iterator();
+ while (ids.hasNext())
+ {
+ String id = (String)ids.next();
+ writer.print("<option value=\"" + id + "\"");
+ writer.println(">" + webConnectors.get(id) + "</option>");
+ }
+
+ writer.println("</select>");
+
+ return sw.toString();
+ }
+
+ /**
+ * Generates a HTML snippet of a FIELD_SIGNATURE_TYPE select box that allows
+ * to choose the signature type.
+ *
+ * @return Returns the HTML snippet.
+ * @throws ServletException
+ * Forwarded exception.
+ */
+ public static String generateTypeSelectBox(ServletContext sc) throws ServletException
+ {
+ try
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter writer = new PrintWriter(sw);
+
+ PdfAs pdfAs = ApiHelper.getPdfAsFromContext(sc);
+ List profiles = pdfAs.getProfileInformation();
+
+ writer.println("<select class=\"" + STYLE_CLASS_FIELD + "\" name=\"" + FIELD_SIGNATURE_TYPE + "\">");
+ for (int i = 0; i < profiles.size(); i++)
+ {
+ SignatureProfile profile = (SignatureProfile)profiles.get(i);
+ String descr_key = SIG_OBJ + profile.getProfileId() + "." + SIG_DESCR;
+ String type_descr = profile.getProfileDescription();
+
+ writer.println("<option value=\"" + profile.getProfileId() + "\" " + (profile.isDefault() ? "selected=\"selected\"" : "") + ">" + type_descr + "</option>");
+
+ }
+ writer.println("</select>");
+
+ return sw.toString();
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+}