From 7be16d5f6a9e48137232d7bece96d30825229911 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Mon, 12 Oct 2015 14:46:03 +0200 Subject: More specific error when keystore file does not exist --- .../gui/composites/KeystoreConfigurationComposite.java | 2 +- .../gui/exceptions/KeystoreDoesntExistException.java | 2 +- .../at/asit/pdfover/gui/workflow/states/KSState.java | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java index 0596f708..6dda2956 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java @@ -278,7 +278,7 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite { } catch (FileNotFoundException ex) { log.error("Error loading keystore", ex); //$NON-NLS-1$ showErrorDialog(String.format(Messages.getString( - "error.FileNotExist"), f.getName())); //$NON-NLS-1$ + "error.KeyStoreFileNotExist"), f.getName())); //$NON-NLS-1$ } catch (NoSuchAlgorithmException ex) { log.error("Error loading keystore", ex); //$NON-NLS-1$ showErrorDialog(Messages.getString("error.KeyStore")); //$NON-NLS-1$ diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java index f0b4f8f0..7578d1c3 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java @@ -33,6 +33,6 @@ public class KeystoreDoesntExistException extends ResumableException { * @param resumeIndex The resume Index */ public KeystoreDoesntExistException(final File keystore, int resumeIndex) { - super(String.format(Messages.getString("error.FileNotExist"), keystore.getPath()), resumeIndex); //$NON-NLS-1$ + super(String.format(Messages.getString("error.KeyStoreFileNotExist"), keystore.getPath()), resumeIndex); //$NON-NLS-1$ } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java index eaeba4c8..2e5c0d75 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java @@ -16,6 +16,8 @@ package at.asit.pdfover.gui.workflow.states; // Imports +import java.io.File; + import org.eclipse.swt.SWT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,6 +68,21 @@ public class KSState extends State { try { String file = config.getKeyStoreFile(); + File f = new File(file); + if (!f.isFile()) { + log.error("Keystore not found"); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog( + getStateMachine().getGUIProvider().getMainShell(), + String.format(Messages.getString("error.KeyStoreFileNotExist"), f.getName()), //$NON-NLS-1$ + BUTTONS.RETRY_CANCEL); + if (dialog.open() != SWT.RETRY) { + //getStateMachine().exit(); + this.setNextState(new BKUSelectionState(getStateMachine())); + return; + } + this.run(); + return; + } String alias = config.getKeyStoreAlias(); String storePass = config.getKeyStoreStorePass(); if (storePass.isEmpty()) { -- cgit v1.2.3