summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:22:59 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:22:59 +0000
commit7bb4a282de9ebe26aa09b22df746e78b3171c47c (patch)
treefdeba8694cd05cba242c531fc1393c0c220c68a8
parenta1208626fad77d9e09f88f7b9fdaae13d1adf0f2 (diff)
downloadpdf-over-7bb4a282de9ebe26aa09b22df746e78b3171c47c.tar.gz
pdf-over-7bb4a282de9ebe26aa09b22df746e78b3171c47c.tar.bz2
pdf-over-7bb4a282de9ebe26aa09b22df746e78b3171c47c.zip
Guard against empty error messages
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@290 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java9
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java5
-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
6 files changed, 27 insertions, 9 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index 6e1ae0e0..f9ff5b7f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -382,7 +382,10 @@ public class ConfigurationComposite extends StateComposite {
} while (redo);
} catch (Exception e) {
log.error("Settings validation failed!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), e.getMessage(),
+ String message = e.getMessage();
+ if (message == null)
+ message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(), message,
BUTTONS.OK);
dialog.open();
return false;
@@ -435,8 +438,7 @@ public class ConfigurationComposite extends StateComposite {
status = true;
} catch (IOException e) {
log.error("Failed to save configuration to file!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(
- getShell(),
+ ErrorDialog dialog = new ErrorDialog(getShell(),
Messages.getString("error.FailedToSaveSettings"), BUTTONS.RETRY_CANCEL); //$NON-NLS-1$
redo = (dialog.open() == SWT.RETRY);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java
index c373a423..63b7f034 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java
@@ -27,10 +27,16 @@ public class InvalidNumberException extends PDFOverGUIException {
private static final long serialVersionUID = -4201886410518715443L;
/**
- *
+ * Empty constructor
*/
public InvalidNumberException() {
-
}
-
+
+ /**
+ * Constructor with a message parameter
+ * @param msg Error message
+ */
+ public InvalidNumberException(String msg) {
+ super(msg);
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
index 1e8db610..8f1b1f9b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.exceptions.InvalidNumberException;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
+import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper;
import at.asit.pdfover.signator.BKUs;
@@ -153,8 +154,12 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
if(number == null || number.trim().equals("")) { //$NON-NLS-1$
this.mobileNumber = null;
return;
- }
- this.mobileNumber = ATrustHelper.normalizeMobileNumber(number);
+ }
+ try {
+ this.mobileNumber = ATrustHelper.normalizeMobileNumber(number);
+ } catch (InvalidNumberException e) {
+ throw new InvalidNumberException(Messages.getString("error.InvalidPhoneNumber")); //$NON-NLS-1$
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
index 6c3265bc..93ccddce 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
@@ -100,9 +100,12 @@ public class PositioningState extends State {
// FIXME
this.positionComposite = null;
log.error("Failed to display PDF document", e); //$NON-NLS-1$
+ String message = e.getLocalizedMessage();
+ if (message == null)
+ message = Messages.getString("error.IOError"); //$NON-NLS-1$
ErrorDialog dialog = new ErrorDialog(
this.stateMachine.getGUIProvider().getMainShell(),
- e.getLocalizedMessage(), BUTTONS.RETRY_CANCEL);
+ message, BUTTONS.RETRY_CANCEL);
if(dialog.open() == SWT.RETRY) {
this.stateMachine.update();
} else {
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 895da18f..3f86ed1d 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
@@ -71,6 +71,7 @@ error.InvalidBKU=Invalid CCE selection. Please check.
error.InvalidLocale=Locale not valid
error.InvalidPhoneNumber=Given phone number is invalid! Example: +43664123456789
error.InvalidSettings=Invalid settings are still present. Please check your input.
+error.IOError=Input/Output Error
error.LocalBKU=Please check if a local CCE is running
error.MayNotBeAPDF=This may not be a PDF File
error.PositioningNotPossible=Manual positioning currently not possible due to a Java Bug. Using automatic positioning.
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 ec1ce9cb..abd710ee 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
@@ -71,6 +71,7 @@ error.InvalidBKU=Ungültige BKU-Auswahl. Bitte überprüfen.
error.InvalidLocale=Ungültige Sprache
error.InvalidPhoneNumber=Telefonnummer ungültig! Beispiel: +43664123456789
error.InvalidSettings=Ungültige Einstellungen vorhanden. Bitte überprüfen.
+error.IOError=Ein-/Ausgabe-Fehler
error.LocalBKU=Bitte prüfen sie, ob Ihre lokale BKU läuft
error.MayNotBeAPDF=Dies ist möglicherweise keine PDF Datei
error.PositioningNotPossible=Positionsauswahl ist im Moment nicht verfügbar wegen eines Java Fehlers. Die Position wird automatisch bestimmt.