diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-07 13:29:21 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-07 13:29:21 +0200 |
commit | 8610371549aacedf5dc7bf7435a401b410e1ffef (patch) | |
tree | f0bfab43554cb6949c4b2cd4f105798c352bcec8 /pdf-over-gui | |
parent | 3c1e373f9fdf83da4b2083101c77a664ea756091 (diff) | |
download | pdf-over-8610371549aacedf5dc7bf7435a401b410e1ffef.tar.gz pdf-over-8610371549aacedf5dc7bf7435a401b410e1ffef.tar.bz2 pdf-over-8610371549aacedf5dc7bf7435a401b410e1ffef.zip |
don't try to read a resource file that doesn't exist
Diffstat (limited to 'pdf-over-gui')
3 files changed, 11 insertions, 32 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java index 29728caa..78e7b21d 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java @@ -51,7 +51,7 @@ public class ConfigFileArgument extends Argument { String configFile = args[argOffset + 1]; - getConfiguration().setConfigurationFile(configFile); + getConfiguration().setConfigurationFileName(configFile); return argOffset + 1; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java index 386f4763..2dfe879b 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java @@ -293,7 +293,7 @@ public class ConfigProviderImpl { /* save to file */ public void saveCurrentConfiguration() throws IOException { - String filename = this.getConfigurationFile(); + String filename = this.getConfigurationFileName(); File configFile = new File(this.getConfigurationDirectory() + File.separator + filename); Properties props = new Properties(); @@ -409,8 +409,8 @@ public class ConfigProviderImpl { public String getConfigurationDirectory() { return Constants.CONFIG_DIRECTORY; } // TODO review this - public void setConfigurationFile(String configurationFile) { this.configurationFile = configurationFile; } - public String getConfigurationFile() { return this.configurationFile; } + public void setConfigurationFileName(String configurationFile) { this.configurationFile = configurationFile; } + public String getConfigurationFileName() { return this.configurationFile; } public void setDefaultBKU(BKUs bku) { this.configuration.defaultBKU = bku; 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 616fa63f..3f4f9086 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 @@ -105,33 +105,13 @@ public class PrepareConfigurationState extends State { this.configFileHandler.addCLIArgument(ConfigFileArgument.class); } - private void initializeFromConfigurationFile(String filename) + private void initializeFromConfigurationFile() throws InitializationException { try { + String filename = getStateMachine().configProvider.getConfigurationFileName(); + getStateMachine().configProvider.loadConfiguration(new FileInputStream(getStateMachine().configProvider.getConfigurationDirectory() + FILE_SEPARATOR + filename)); - // TODO: move this to ConfigProviderImpl to mirror save logic - try { - getStateMachine().configProvider.loadConfiguration(new FileInputStream(getStateMachine().configProvider.getConfigurationDirectory() + FILE_SEPARATOR + filename)); - - log.info("Loaded config from file : " + filename); - } catch (FileNotFoundException ex) { - if (filename.equals(Constants.DEFAULT_CONFIG_FILENAME)) { - // we only check for resource config file if it is the - // default value! - try { - InputStream is = getClass().getResourceAsStream( - Constants.RES_PKG_PATH + filename); - getStateMachine().configProvider - .loadConfiguration(is); - - log.info("Loaded config from resource : " + filename); - } catch (Exception eex) { - throw ex; - } - } else { - throw ex; - } - } + log.info("Loaded config from file : " + filename); } catch (IOException ex) { throw new InitializationException( @@ -292,8 +272,7 @@ public class PrepareConfigurationState extends State { } private void initializeConfig() throws InitializationException { - initializeFromConfigurationFile(getStateMachine() - .configProvider.getConfigurationFile()); + initializeFromConfigurationFile(); resetSignatureNoteField(getStateMachine().configProvider); @@ -416,7 +395,7 @@ public class PrepareConfigurationState extends State { } - // Read cli arguments for config file first + // Read cli arguments for config file location first try { initializeFromArguments(stateMachine.cmdLineArgs, this.configFileHandler); } catch (InitializationException e) { @@ -430,7 +409,7 @@ public class PrepareConfigurationState extends State { } // initialize from config file - initializeFromConfigurationFile(config.getConfigurationFile()); + initializeFromConfigurationFile(); updateConfiguration(); // Read cli arguments |