diff options
author | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-11-19 14:16:45 +0000 |
---|---|---|
committer | ferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-11-19 14:16:45 +0000 |
commit | a391d9aeba69d93c07d9e3ccc69d2a75408ac89b (patch) | |
tree | 3a53d93c69cf6270004e2d702e7efebbe67dde07 /src/main/java | |
parent | 2226daf4acb2bd6f5a81406df91f53522245cde7 (diff) | |
download | pdf-as-3-a391d9aeba69d93c07d9e3ccc69d2a75408ac89b.tar.gz pdf-as-3-a391d9aeba69d93c07d9e3ccc69d2a75408ac89b.tar.bz2 pdf-as-3-a391d9aeba69d93c07d9e3ccc69d2a75408ac89b.zip |
configuration extension: internal vs. (old)external config file
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@440 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java | 95 |
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.
|