summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java11
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java5
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java38
4 files changed, 59 insertions, 1 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java
index 82bfd2a0..39244f4f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java
@@ -16,9 +16,13 @@
package at.asit.pdfover.gui;
//Imports
+import java.io.File;
+
+import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
import at.asit.pdfover.gui.workflow.StateMachineImpl;
/**
@@ -42,6 +46,13 @@ public class DeveloperMain {
// Set PDF-AS log4j configuration:
//System.setProperty("log4j.configuration", "log4j.properties");
+ File configDir = new File(System.getProperty("user.home")+"/.pdfover"); //$NON-NLS-1$//$NON-NLS-2$
+ if(!configDir.exists()) {
+ configDir.mkdir();
+ } else {
+ PropertyConfigurator.configure(configDir.getAbsolutePath() + "/" + ConfigManipulator.DEFAULT_LOG4J_FILE); //$NON-NLS-1$
+ }
+
StringBuilder sb = new StringBuilder();
for(int i = 0; i < args.length; i++) {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
index 35fc6b5e..7318ec7c 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
@@ -20,12 +20,14 @@ import java.io.File;
import javax.swing.JOptionPane;
+import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.exceptions.InitializationException;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.utils.SWTLoader;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
import at.asit.pdfover.gui.workflow.StateMachineImpl;
/**
@@ -56,8 +58,10 @@ public class Main {
File configDir = new File(System.getProperty("user.home")+"/.pdfover"); //$NON-NLS-1$//$NON-NLS-2$
if(!configDir.exists()) {
configDir.mkdir();
+ } else {
+ PropertyConfigurator.configure(configDir.getAbsolutePath() + "/" + ConfigManipulator.DEFAULT_LOG4J_FILE); //$NON-NLS-1$
}
-
+
StateMachineImpl stateMachine = new StateMachineImpl(args);
log.debug("Starting stateMachine ..."); //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
index 02633774..c3a88fe5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java
@@ -32,6 +32,11 @@ public interface ConfigManipulator {
public static final String DEFAULT_CONFIG_FILE = "PDFOver.config"; //$NON-NLS-1$
/**
+ * The default log4j file
+ */
+ public static final String DEFAULT_LOG4J_FILE = "log4j.properties"; //$NON-NLS-1$
+
+ /**
* The bku config parameter
*/
public static final String BKU_CONFIG = "BKU"; //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index 41d44f52..6c8181d4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -192,6 +192,44 @@ public class PrepareConfigurationState extends State {
}
}
+ inputStream = null;
+ pdfOverConfig = null;
+ try {
+ inputStream = this.getClass().getResourceAsStream(
+ "/" + ConfigManipulator.DEFAULT_LOG4J_FILE); //$NON-NLS-1$
+ pdfOverConfig = new FileOutputStream(this.stateMachine.getConfigProvider().getConfigurationDirectory()
+ + "/" //$NON-NLS-1$
+ + ConfigManipulator.DEFAULT_LOG4J_FILE);
+
+ while ((byteCount = inputStream.read(buffer)) >= 0) {
+ pdfOverConfig.write(buffer, 0, byteCount);
+ }
+ } catch (Exception e) {
+ log.error(
+ "Failed to write log4j config file to config directory", e); //$NON-NLS-1$
+ throw new InitializationException(
+ "Failed to write log4j config file to config directory", //$NON-NLS-1$
+ e);
+ } finally {
+ if (pdfOverConfig != null) {
+ try {
+ pdfOverConfig.close();
+ } catch (IOException e) {
+ log.warn(
+ "Failed to close File stream for log4j config", e); //$NON-NLS-1$
+ }
+ }
+
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.warn(
+ "Failed to close Resource stream for log4j config", e); //$NON-NLS-1$
+ }
+ }
+ }
+
InputStream is = this.getClass().getResourceAsStream(
"/cfg/PDFASConfig.zip"); //$NON-NLS-1$