aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java95
1 files changed, 52 insertions, 43 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
index 5fd67d2..8dea466 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
@@ -26,12 +26,14 @@ import iaik.utils.RFC2253NameParser;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrSubstitutor;
import org.apache.commons.logging.Log;
@@ -58,16 +60,6 @@ import at.knowcenter.wag.egov.egiz.pdf.Utils;
*
* <pre>
*
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
* #SettingNotFoundException
* error.code.100=Interner Fehler
* error.code.101=Die Konfigurationsdatei konnte nicht geladen werden
@@ -76,22 +68,13 @@ import at.knowcenter.wag.egov.egiz.pdf.Utils;
* error.code.200=Das Dokument konnte nicht geladen werden
*
* #SignatureException
- * error.code.300=Die Signatur ist ungültig
+ * error.code.300=Die Signatur ist ung�ltig
*
* #NormalizeException
* error.code.400=Die angegebene Version ist nicht bekannt
*
* normalizer.version=V01
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
+
*
* </pre>
*
@@ -99,35 +82,16 @@ import at.knowcenter.wag.egov.egiz.pdf.Utils;
*
* <pre>
*
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
+
* .error|
* |.code|
* | |.200=Das Dokument konnte nicht geladen werden
* | |.100=Interner Fehler
* | |.400=Die angegebene Version ist nicht bekannt
* | |.101=Die Konfigurationsdatei konnte nicht geladen werden
- * | |.300=Die Signatur ist ungültig
+ * | |.300=Die Signatur ist ung�ltig
* .normalizer|
- * |.version=V01
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
+ * |.version=V01
*
* </pre>
*
@@ -172,6 +136,11 @@ public class SettingsReader implements Serializable
* The file path postfix where certificates are stored
*/
private static final String CERT = "certificates";
+
+ /**
+ * pdf-as internal properties resource path
+ */
+ private static final String PDF_AS_PROP_RESOURCE = "/config/pdf-as.properties";
// /**
// * The web application path
@@ -264,6 +233,9 @@ public class SettingsReader implements Serializable
*/
private static final Log logger_ = LogFactory.getLog(SettingsReader.class);
+ private static final String INTERNAL_RESOURCE_PATH = "/config/";
+
+
/**
* Make this constructor private. Use the method
* {@link SettingsReader#getInstance()}to get an instance from this class.
@@ -303,6 +275,9 @@ public class SettingsReader implements Serializable
}
FileInputStream sfs = new FileInputStream(settingsFile_);
properties_.load(sfs);
+
+ // dferbas override with system props
+ properties_.load(SettingsReader.class.getResourceAsStream(PDF_AS_PROP_RESOURCE));
Properties help_prop = new Properties();
FileInputStream hfs = new FileInputStream(cfg_path + HELP_TEXT_FILE_DEFAULT_NAME);
@@ -633,6 +608,40 @@ public class SettingsReader implements Serializable
{
return pTree_;
}
+
+ /**
+ * Reads internal resource as string.
+ * @param relativePath
+ * @return null in case of error
+ */
+ public String readInternalResourceAsString(String relativePath) {
+ return readAsString(getInternalResource(relativePath));
+ }
+
+ /**
+ * Get resource as stream, relative to internal resource path {@value #INTERNAL_RESOURCE_PATH}
+ *
+ * @param relativePath
+ * @return
+ */
+ public InputStream getInternalResource(String relativePath) {
+ return this.getClass().getResourceAsStream(INTERNAL_RESOURCE_PATH + relativePath);
+ }
+
+ /**
+ * Read resource as utf8 string.
+ * @param is
+ * @return <code>null</code> in case of error
+ */
+ public String readAsString(InputStream is) {
+ if (is == null) return null;
+ try {
+ return IOUtils.toString(is, "utf-8");
+ } catch (IOException e) {
+ logger_.info("error reading stream to string ", e);
+ }
+ return null;
+ }
// /**
// * This method checks the application context.