aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java28
1 files changed, 17 insertions, 11 deletions
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);
}