summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:29:08 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:29:08 +0000
commit3c204ab19773fff240beb4f66a2098afc8ca4397 (patch)
treed7edb07a15a4103c24fba45eaec28e8a21108d7a /pdf-over-gui/src/main
parent9400f7509c97db2706f8d36f816b7719c11fcb4d (diff)
downloadmocca-3c204ab19773fff240beb4f66a2098afc8ca4397.tar.gz
mocca-3c204ab19773fff240beb4f66a2098afc8ca4397.tar.bz2
mocca-3c204ab19773fff240beb4f66a2098afc8ca4397.zip
Display error message (and retry) when saving fails
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@345 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java47
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties1
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties1
3 files changed, 36 insertions, 13 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
index 8c9e21c1..966a0708 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
@@ -44,6 +44,7 @@ import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.controls.Dialog;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.Dialog.ICON;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.DocumentSource;
@@ -265,7 +266,7 @@ public class OutputComposite extends StateComposite {
targetFile = new File(inputFolder, target);
if (targetFile.exists()) {
- Dialog dialog = new Dialog(this.getShell(), Messages.getString("common.warning"), //$NON-NLS-1$
+ Dialog dialog = new Dialog(getShell(), Messages.getString("common.warning"), //$NON-NLS-1$
String.format(Messages.getString("output.file_ask_overwrite"), targetFile.getName()), //$NON-NLS-1$
BUTTONS.OK_CANCEL, ICON.QUESTION);
if (dialog.open() == SWT.CANCEL)
@@ -275,22 +276,42 @@ public class OutputComposite extends StateComposite {
}
DocumentSource source = this.getSignedDocument();
+ boolean retry;
- try {
- FileOutputStream outstream = new FileOutputStream(targetFile);
- outstream.write(source.getByteArray(), 0,
- source.getByteArray().length);
- outstream.close();
- } catch (FileNotFoundException e) {
- log.debug("File not found", e); //$NON-NLS-1$
- return null;
- } catch (IOException e) {
- log.debug("IO Error", e); //$NON-NLS-1$
- return null;
- }
+ do {
+ retry = false;
+ try {
+ FileOutputStream outstream = new FileOutputStream(targetFile);
+ outstream.write(source.getByteArray(), 0,
+ source.getByteArray().length);
+ outstream.close();
+ } catch (FileNotFoundException e) {
+ log.error("File not found", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
+ targetFile.getName(), e.getLocalizedMessage()),
+ BUTTONS.RETRY_CANCEL);
+ if (dialog.open() == SWT.CANCEL)
+ return null;
+ retry = true;
+ } catch (IOException e) {
+ log.error("IO Error", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
+ targetFile.getName(), e.getLocalizedMessage()),
+ BUTTONS.RETRY_CANCEL);
+ if (dialog.open() == SWT.CANCEL)
+ return null;
+ retry = true;
+ }
+ } while (retry);
if (!targetFile.exists())
+ {
+ log.error("Tried to save file " + targetFile.getName() + //$NON-NLS-1$
+ ", but it doesn't exist"); //$NON-NLS-1$
return null;
+ }
return targetFile;
}
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
index 5b945769..13798f7e 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
@@ -103,6 +103,7 @@ mobileBKU.password=Password:
output.file_ask_overwrite=File %s already exists, do you want to overwrite it?
output.link_open_message=You can open the signed file <a>here</a>
output.link_save_message=You can save the signed file
+output.save_failed=Saving file %s failed: %s
output.success_message=Signature was successful
positioning.newPage=Create &new Page
positioning.page=Page %d of %d
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
index a4f0dd8f..6f36a45c 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
@@ -103,6 +103,7 @@ mobileBKU.password=Passwort:
output.file_ask_overwrite=Datei %s existiert bereits, wollen Sie sie überschreiben?
output.link_open_message=Sie können das signierte Dokument <a>hier</a> öffnen
output.link_save_message=Sie können das signierte Dokument speichern
+output.save_failed=Datei %s konnte nicht gespeichert werden: %s
output.success_message=Signatur war erfolgreich
positioning.newPage=&Neue Seite anlegen
positioning.page=Seite %d von %d