From 1eac16f95618fc4bc1e90b5d44cc94252647f136 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 10 Jun 2008 10:47:02 +0000 Subject: Manual deployment of pdf-as configuration (commandline parameter -ddc) considers the system property pdf-as.work-dir. Internal default configuration updated. log4.properties within the workdir is now being considered using the api. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@280 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- dok/Hinweise-zur-PDF-AS-Konfiguration.pdf | Bin 353139 -> 360126 bytes .../at/gv/egiz/pdfas/api/commons/Constants.java | 2 +- .../java/at/gv/egiz/pdfas/commandline/Main.java | 7 +++--- .../at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 2 ++ .../java/at/gv/egiz/pdfas/utils/ConfigUtils.java | 28 +++++++++++++-------- .../java/at/knowcenter/wag/egov/egiz/PdfAS.java | 2 +- .../wag/egov/egiz/cfg/SettingsReader.java | 25 ++++++++++-------- .../egov/egiz/web/PdfASServletContextListener.java | 4 +-- src/main/resources/DefaultConfiguration.zip | Bin 192100 -> 190303 bytes src/site/changes.xml | 6 +++++ 10 files changed, 48 insertions(+), 28 deletions(-) diff --git a/dok/Hinweise-zur-PDF-AS-Konfiguration.pdf b/dok/Hinweise-zur-PDF-AS-Konfiguration.pdf index de035ce..52b239b 100644 Binary files a/dok/Hinweise-zur-PDF-AS-Konfiguration.pdf and b/dok/Hinweise-zur-PDF-AS-Konfiguration.pdf differ diff --git a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java index 33a418e..f9a3c03 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java +++ b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java @@ -78,7 +78,7 @@ public final class Constants /** * The system property that may be used to declare the pdf-as configuration folder. */ - public final static String CONFIG_SYSTEM_PROPERTY = "pdf-as.work-dir"; + public final static String CONFIG_DIR_SYSTEM_PROPERTY = "pdf-as.work-dir"; /** * The zip file containing the default configuration. diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java index 0ec6a55..dea19b6 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java @@ -177,10 +177,11 @@ public abstract class Main for (int i = 0; i < args.length; i++) { if (args[i].trim().equals(PARAMETER_DEPLOY_DEFAULT_CONFIGURATION)) { try { - if (ConfigUtils.deployDefaultConfiguration()) { - System.out.println("Default configuration successfully deployed to the current user's home."); + String defaultConfigurationDeployedTo = ConfigUtils.deployDefaultConfiguration(); + if (defaultConfigurationDeployedTo != null) { + System.out.println("Default configuration successfully deployed to \"" + defaultConfigurationDeployedTo + "\"."); } else { - System.out.println("Default configuration NOT deployed because to the current user's home because it already exists."); + System.out.println("Default configuration has NOT been deployed. Maybe the configuration already exists."); } System.exit(0); } catch (ConfigUtilsException e) { diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java index 303d48f..0450a50 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java @@ -14,6 +14,7 @@ import java.util.Vector; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.log4j.PropertyConfigurator; import at.gv.egiz.pdfas.api.PdfAs; import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; @@ -105,6 +106,7 @@ public class PdfAsObject implements PdfAs */ public void reloadConfig() throws PdfAsException { + PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); SettingsReader.createInstance(); SignatureTypes.createInstance(); } diff --git a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java index c98cb59..0e606d7 100644 --- a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java +++ b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java @@ -102,17 +102,17 @@ public final class ConfigUtils { * * @param destination The destination folder. * @param overwriteExisting If set true an already existing configuration is overwritten. If false nothing is being copied if the destination folder already exists. - * @return true if the configuration has been deployed, false if not. + * @return The folder the configuration has been extracted to or null if the configuration has NOT been deployed. * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration. */ - public static boolean deployDefaultConfiguration(String destination, boolean overwriteExisting) throws ConfigUtilsException { + public static String deployDefaultConfiguration(String destination, boolean overwriteExisting) throws ConfigUtilsException { if (destination == null) { throw new NullPointerException("Destination must not be null."); } if (destination.length() == 0) { throw new IllegalArgumentException("Destination must not be empty."); } - return deployFromZIP(destination, overwriteExisting); + return deployFromZIP(destination, overwriteExisting) ? destination : null; } /** @@ -120,27 +120,33 @@ public final class ConfigUtils { * Constants.Constants.USERHOME_CONFIG_FOLDER. * * @param overwriteExisting If set true an already existing configuration is overwritten. If false nothing is being copied if the destination folder already exists. - * @return true if the configuration has been deployed, false if not. + * @return The folder the configuration has been extracted to or null if the configuration has NOT been deployed. * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration. * @see Constants#USERHOME_CONFIG_FOLDER */ - public static boolean deployDefaultConfiguration(boolean overwriteExisting) throws ConfigUtilsException { - String userHome = System.getProperty("user.home"); - if (userHome == null || userHome.length() == 0) { - return false; + public static String deployDefaultConfiguration(boolean overwriteExisting) throws ConfigUtilsException { + String configdir = System.getProperty(Constants.CONFIG_DIR_SYSTEM_PROPERTY); + if (configdir == null) { + configdir = System.getProperty("user.home"); + if (configdir != null) { + configdir = configdir + File.separator + Constants.USERHOME_CONFIG_FOLDER; + } } - return deployDefaultConfiguration(userHome + File.separator + Constants.USERHOME_CONFIG_FOLDER, overwriteExisting); + if (configdir == null || configdir.length() == 0) { + return null; + } + return deployDefaultConfiguration(configdir, overwriteExisting); } /** * Deploys the default configuration to the user's home directory to the subdirectory specified by * Constants.Constants.USERHOME_CONFIG_FOLDER. * - * @return true if the configuration has been deployed, false if not. + * @return The folder the configuration has been extracted to or null if the configuration has NOT been deployed. * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration. * @see Constants#USERHOME_CONFIG_FOLDER */ - public static boolean deployDefaultConfiguration() throws ConfigUtilsException { + public static String deployDefaultConfiguration() throws ConfigUtilsException { return deployDefaultConfiguration(false); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 5dbc7fb..7def267 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -96,7 +96,7 @@ public abstract class PdfAS * The current version of the pdf-as library. This version string is logged on every invocation * of the api or the web application. */ - public static final String PDFAS_VERSION = "3.0.5-20080603"; + public static final String PDFAS_VERSION = "3.0.5-20080610"; /** * The key of the strict mode setting. 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 231da06..31ca5e1 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 @@ -694,14 +694,14 @@ public class SettingsReader implements Serializable public static synchronized void initialize(String configdir, String tmpdir) { - boolean defaultConfigDeployed = false; + String defaultConfigDeployedTo = null; // resolve work directory // configuration explicitely given ? if (configdir == null) { // configuration via system property ? - logger_.debug("No configuration directory given. Looking for system property \"" + Constants.CONFIG_SYSTEM_PROPERTY + "\"."); - configdir = System.getProperty(Constants.CONFIG_SYSTEM_PROPERTY); + logger_.debug("No configuration directory given. Looking for system property \"" + Constants.CONFIG_DIR_SYSTEM_PROPERTY + "\"."); + configdir = System.getProperty(Constants.CONFIG_DIR_SYSTEM_PROPERTY); if (configdir == null) { // configuration via user's home directory ? @@ -712,17 +712,20 @@ public class SettingsReader implements Serializable } configdir = assertFileSeparator(userHome) + Constants.USERHOME_CONFIG_FOLDER; try { - defaultConfigDeployed = ConfigUtils.deployDefaultConfiguration(configdir, false); + defaultConfigDeployedTo = ConfigUtils.deployDefaultConfiguration(configdir, false); } catch (ConfigUtilsException e) { throw new RuntimeException(e); } - if (defaultConfigDeployed) { - logger_.info("** Default configuration successfully deployed to the current user's home. **"); + if (defaultConfigDeployedTo != null) { + logger_.info("** Default configuration successfully deployed to \"" + defaultConfigDeployedTo + "\" **"); } else { - logger_.debug("Default configuration NOT deployed because to the current user's home because it already exists."); + logger_.debug("Default configuration has NOT been deployed. Maybe the configuration already exists."); } } else { logger_.debug("Configuration set by system property."); + if (tmpdir == null) { + tmpdir = configdir; + } } } else { logger_.debug("Configuration path explicitely set."); @@ -768,10 +771,12 @@ public class SettingsReader implements Serializable logger_.debug(" configuration path = \"" + CONFIG_PATH + "\""); logger_.debug(" certstore path = \"" + CERT_PATH + "\""); logger_.debug(" temporary path = \"" + TMP_PATH + "\""); - if (defaultConfigDeployed) { - logger_.debug(" default configuration was deployed to the current user's home directory "); - } logger_.debug(StringUtils.repeat("*", length + 25)); + if (defaultConfigDeployedTo != null) { + logger_.debug("** Default configuration successfully deployed to \"" + defaultConfigDeployedTo + "\" **"); + } + logger_.debug("Setting system property \"" + Constants.CONFIG_DIR_SYSTEM_PROPERTY + "\" to \"" + configdirFile.getPath() + "\"."); + System.setProperty(Constants.CONFIG_DIR_SYSTEM_PROPERTY, configdirFile.getPath()); } public static void initialize(String base_dir) diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java index e33a5ec..219fec2 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java @@ -58,7 +58,7 @@ public class PdfASServletContextListener implements ServletContextListener { logger.info("PDF-AS Context init"); //$NON-NLS-1$ - String sysPropWorkdir = System.getProperty(Constants.CONFIG_SYSTEM_PROPERTY); + String sysPropWorkdir = System.getProperty(Constants.CONFIG_DIR_SYSTEM_PROPERTY); String scWorkdir = sce.getServletContext().getInitParameter(CONFIG_SERVLET_INIT_PARAMETER); String work_dir; @@ -66,7 +66,7 @@ public class PdfASServletContextListener implements ServletContextListener // search for system property if (sysPropWorkdir != null && sysPropWorkdir.length() > 0) { work_dir = sysPropWorkdir; - logger.debug("Work-dir configuration via system property \"" + Constants.CONFIG_SYSTEM_PROPERTY + "\" = \"" + sysPropWorkdir + "\"."); + logger.debug("Work-dir configuration via system property \"" + Constants.CONFIG_DIR_SYSTEM_PROPERTY + "\" = \"" + sysPropWorkdir + "\"."); // search for servlet parameter } else if (scWorkdir != null && scWorkdir.length() > 0){ diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip index 693ed95..a8a9a06 100644 Binary files a/src/main/resources/DefaultConfiguration.zip and b/src/main/resources/DefaultConfiguration.zip differ diff --git a/src/site/changes.xml b/src/site/changes.xml index df953a6..25e5838 100644 --- a/src/site/changes.xml +++ b/src/site/changes.xml @@ -13,6 +13,12 @@ --> + + Manual deployment of pdf-as configuration (commandline parameter -ddc) considers the system property pdf-as.work-dir. + Internal default configuration updated. + log4.properties within the workdir is now being considered using the api. + + Support of a minimal signature mark layout for binary signatures added. -- cgit v1.2.3