aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/commandline/Main.java7
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java28
4 files changed, 24 insertions, 15 deletions
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 <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
- * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @return The folder the configuration has been extracted to or <code>null</code> 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 {
* <code>Constants.Constants.USERHOME_CONFIG_FOLDER</code>.
*
* @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
- * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @return The folder the configuration has been extracted to or <code>null</code> 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
* <code>Constants.Constants.USERHOME_CONFIG_FOLDER</code>.
*
- * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @return The folder the configuration has been extracted to or <code>null</code> 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);
}