diff options
-rw-r--r-- | pdf-as-common/build.gradle | 1 | ||||
-rw-r--r-- | pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java | 296 | ||||
-rw-r--r-- | pdf-as-lib/src/main/resources/config/config.zip | bin | 1041855 -> 1205859 bytes | |||
-rw-r--r-- | pdf-as-web/src/main/resources/template_sl.html | 17 | ||||
-rw-r--r-- | pdf-as-web/src/main/webapp/index.jsp | 10 |
5 files changed, 214 insertions, 110 deletions
diff --git a/pdf-as-common/build.gradle b/pdf-as-common/build.gradle index 22c25e14..1ef6b6c8 100644 --- a/pdf-as-common/build.gradle +++ b/pdf-as-common/build.gradle @@ -15,6 +15,7 @@ dependencies { compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.5' compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.5' compile group: 'commons-collections', name: 'commons-collections', version: '3.2' + compile group: 'commons-io', name: 'commons-io', version: '2.4' compile group: 'ognl', name: 'ognl', version: '3.0.6' testCompile group: 'junit', name: 'junit', version: '4.+' } diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java index abeba8b2..4eda8254 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/Settings.java @@ -25,123 +25,207 @@ package at.gv.egiz.pdfas.common.settings; import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOCase; +import org.apache.commons.io.filefilter.WildcardFileFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; import java.io.IOException; import java.util.*; -public class Settings implements ISettings, IProfileConstants{ - - private static final Logger logger = LoggerFactory.getLogger(Settings.class); - - protected Properties properties = new Properties(); - - protected File workDirectory; - - public Settings(File workDirectory) { - try { - this.workDirectory = workDirectory; - loadSettings(workDirectory); - } catch (PdfAsSettingsException e) { - logger.error(e.getMessage(), e); - } - } - - public void loadSettings(File workDirectory) throws PdfAsSettingsException { - try { - - String configDir = workDirectory.getAbsolutePath() + File.separator + CFG_DIR; - String configFile = configDir + File.separator + CFG_FILE; - logger.debug("Loading cfg file: " + configFile); - properties.load(new FileInputStream(configFile)); - - Map<String, String> includes = this.getValuesPrefix(INCLUDE); - - if(includes != null) { - Iterator<String> includeIterator = includes.values().iterator(); - while(includeIterator.hasNext()) { - String includeFile = configDir + File.separator + includeIterator.next(); - logger.debug("Loading included cfg file: " + includeFile); - try { - properties.load(new FileInputStream(includeFile)); - } catch(Throwable e) { - logger.error("Failed to load cfg file " + includeFile, e); - } - } - } - - logger.debug("Configured Properties:"); - /*if(logger.isDebugEnabled()) { - properties.list(System.out); - }*/ - - } catch (IOException e) { - throw new PdfAsSettingsException("Failed to read settings!", e); - } - } - - public String getValue(String key) { - return properties.getProperty(key); - } - - public boolean hasValue(String key) { - return properties.containsKey(key); - } - - public Map<String, String> getValuesPrefix(String prefix) { - Iterator<Object> keyIterator = properties.keySet().iterator(); - Map<String, String> valueMap = new HashMap<String, String>(); - while(keyIterator.hasNext()) { - String key = keyIterator.next().toString(); - - if(key.startsWith(prefix)) { - valueMap.put(key, properties.getProperty(key)); - } - } - - if(valueMap.isEmpty()) { - return null; - } - - return valueMap; - } - - public Vector<String> getFirstLevelKeys(String prefix) { - String mPrefix = prefix.endsWith(".")?prefix:prefix+"."; - Iterator<Object> keyIterator = properties.keySet().iterator(); - Vector<String> valueMap = new Vector<String>(); - while(keyIterator.hasNext()) { - String key = keyIterator.next().toString(); - - if(key.startsWith(prefix)) { - int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key.indexOf('.', mPrefix.length()) : key.length(); - String firstLevels = key.substring(0, keyIdx); - if(!valueMap.contains(firstLevels)) { - valueMap.add(firstLevels); - } - } - } - - if(valueMap.isEmpty()) { - return null; - } - - return valueMap; - } +public class Settings implements ISettings, IProfileConstants { + + private static final Logger logger = LoggerFactory + .getLogger(Settings.class); + + protected Properties properties = new Properties(); + + protected File workDirectory; + + public Settings(File workDirectory) { + try { + this.workDirectory = workDirectory; + loadSettings(workDirectory); + } catch (PdfAsSettingsException e) { + logger.error(e.getMessage(), e); + } + } + + private void loadSettingsRecursive(File workDirectory, File file) + throws PdfAsSettingsException { + try { + String configDir = workDirectory.getAbsolutePath() + File.separator + + CFG_DIR; + Properties tmpProps = new Properties(); + logger.info("Loading: " + file.getName()); + tmpProps.load(new FileInputStream(file)); + + properties.putAll(tmpProps); + + Map<String, String> includes = this.getValuesPrefix(INCLUDE, + tmpProps); + File contextFolder = new File(configDir); + if (includes != null) { + Iterator<String> includeIterator = includes.values().iterator(); + while (includeIterator.hasNext()) { + String includeFileName = includeIterator.next(); + + File includeInstruction = new File(contextFolder, includeFileName); + contextFolder = includeInstruction.getParentFile(); + String includeName = includeInstruction.getName(); + + WildcardFileFilter fileFilter = new WildcardFileFilter( + includeName, IOCase.SENSITIVE); + Collection<File> includeFiles = null; + + if (contextFolder != null && contextFolder.exists() + && contextFolder.isDirectory()) { + includeFiles = FileUtils.listFiles(contextFolder, + fileFilter, null); + } + if (includeFiles != null && !includeFiles.isEmpty()) { + logger.info("Including '" + includeFileName + "'."); + for (File includeFile : includeFiles) { + loadSettingsRecursive(workDirectory, includeFile); + } + } + } + } + + } catch (IOException e) { + throw new PdfAsSettingsException("Failed to read settings!", e); + } + } + + public void loadSettings(File workDirectory) throws PdfAsSettingsException { + //try { + String configDir = workDirectory.getAbsolutePath() + File.separator + + CFG_DIR; + String configFile = configDir + File.separator + CFG_FILE; + loadSettingsRecursive(workDirectory, new File(configFile)); + + /* + logger.debug("Loading cfg file: " + configFile); + + + properties.load(new FileInputStream(configFile)); + + Map<String, String> includes = this.getValuesPrefix(INCLUDE); + File contextFolder = new File(configDir); + if (includes != null) { + Iterator<String> includeIterator = includes.values().iterator(); + while (includeIterator.hasNext()) { + String includeFileName = includeIterator.next(); + if (includeFileName.contains("*")) { + WildcardFileFilter fileFilter = new WildcardFileFilter( + includeFileName, IOCase.SENSITIVE); + Collection<File> includeFiles = null; + + if (contextFolder != null && contextFolder.exists() + && contextFolder.isDirectory()) { + includeFiles = FileUtils.listFiles(contextFolder, + fileFilter, null); + } + if (includeFiles != null && !includeFiles.isEmpty()) { + logger.info("Including '" + includeFileName + "'."); + for (File includeFile : includeFiles) { + properties + .load(new FileInputStream(includeFile)); + } + } + } else { + String includeFile = configDir + File.separator + + includeFileName; + logger.debug("Loading included cfg file: " + + includeFile); + try { + properties.load(new FileInputStream(includeFile)); + } catch (Throwable e) { + logger.error("Failed to load cfg file " + + includeFile, e); + } + } + } + } + */ + logger.debug("Configured Properties:"); + /* + * if(logger.isDebugEnabled()) { properties.list(System.out); } + */ + + //} catch (IOException e) { + // throw new PdfAsSettingsException("Failed to read settings!", e); + //} + } + + public String getValue(String key) { + return properties.getProperty(key); + } + + public boolean hasValue(String key) { + return properties.containsKey(key); + } + + private Map<String, String> getValuesPrefix(String prefix, Properties props) { + Iterator<Object> keyIterator = props.keySet().iterator(); + Map<String, String> valueMap = new HashMap<String, String>(); + while (keyIterator.hasNext()) { + String key = keyIterator.next().toString(); + + if (key.startsWith(prefix)) { + valueMap.put(key, props.getProperty(key)); + } + } + + if (valueMap.isEmpty()) { + return null; + } + + return valueMap; + } + + public Map<String, String> getValuesPrefix(String prefix) { + return getValuesPrefix(prefix, properties); + } + + public Vector<String> getFirstLevelKeys(String prefix) { + String mPrefix = prefix.endsWith(".") ? prefix : prefix + "."; + Iterator<Object> keyIterator = properties.keySet().iterator(); + Vector<String> valueMap = new Vector<String>(); + while (keyIterator.hasNext()) { + String key = keyIterator.next().toString(); + + if (key.startsWith(prefix)) { + int keyIdx = key.indexOf('.', mPrefix.length()) > 0 ? key + .indexOf('.', mPrefix.length()) : key.length(); + String firstLevels = key.substring(0, keyIdx); + if (!valueMap.contains(firstLevels)) { + valueMap.add(firstLevels); + } + } + } + + if (valueMap.isEmpty()) { + return null; + } + + return valueMap; + } public boolean hasPrefix(String prefix) { Iterator<Object> keyIterator = properties.keySet().iterator(); - while(keyIterator.hasNext()) { - String key = keyIterator.next().toString(); - - if(key.startsWith(prefix)) { - return true; - } - } - return false; + while (keyIterator.hasNext()) { + String key = keyIterator.next().toString(); + + if (key.startsWith(prefix)) { + return true; + } + } + return false; } public String getWorkingDirectory() { diff --git a/pdf-as-lib/src/main/resources/config/config.zip b/pdf-as-lib/src/main/resources/config/config.zip Binary files differindex 8452de9e..ca7869d0 100644 --- a/pdf-as-lib/src/main/resources/config/config.zip +++ b/pdf-as-lib/src/main/resources/config/config.zip diff --git a/pdf-as-web/src/main/resources/template_sl.html b/pdf-as-web/src/main/resources/template_sl.html index 8399706c..5568ec7a 100644 --- a/pdf-as-web/src/main/resources/template_sl.html +++ b/pdf-as-web/src/main/resources/template_sl.html @@ -31,7 +31,17 @@ div.content { } </style> <script language="javascript" type="text/javascript"> + function adaptWindowSizes() { + var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 221) + var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 221) + var appletWidth = document.getElementById("appletWidth"); + var appletHeight = document.getElementById("appletHeight"); + appletWidth.value = w; + appletHeight.value = h; + } + function onAnmeldeSubmit() { + adaptWindowSizes(); document.CustomizedForm.submit(); document.CustomizedForm.Senden.disabled=true; document.CustomizedForm.Senden.hidden = "hidden"; @@ -45,12 +55,15 @@ div.content { <div class="frameTC"> <div class="content"> <form name="CustomizedForm" action="##BKU##" method="post" - enctype="multipart/form-data"> + enctype="multipart/x-www-form-urlencoded"> <input class="button" type="submit" value="Starte Anmeldung" name="Senden"> <input type="hidden" name="XMLRequest" value="##XMLRequest##"> <input type="hidden" name="DataURL" value="##DataURL##"> - <input type="hidden" name="locale_" value="##LOCALE##" /> + <input type="hidden" name="locale" value="##LOCALE##" /> + <input type="hidden" name="iframe_" value="on" /> + <input type="hidden" id="appletWidth" name="appletWidth" value="221" /> + <input type="hidden" id="appletHeight" name="appletHeight" value="221" /> ##ADDITIONAL## </form> <span id="spin" style="display:block; diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp index 42f2a168..d8729e8f 100644 --- a/pdf-as-web/src/main/webapp/index.jsp +++ b/pdf-as-web/src/main/webapp/index.jsp @@ -7,8 +7,8 @@ <body> <form action="Sign" method="POST" enctype="multipart/form-data"> - <input type="hidden" name="source" id="source" value="internal" /> <input - type="file" name="pdf-file" id="pdf-file" accept="application/pdf"> + <input type="hidden" name="source" id="source" value="internal" /> + <input type="file" name="pdf-file" id="pdf-file" accept="application/pdf"> <% if (request.getAttribute("FILEERR") != null) { %> @@ -60,6 +60,12 @@ <% } %> + + <select name="locale" id="locale" size="3"> + <option>EN</option> + <option>DE</option> + </select> + </form> <p><small>Version: <%= PdfAsHelper.getVersion() %> - <%= PdfAsHelper.getSCMRevision() %></small></p> |