changeset 1310:c4c957a9c092

Improved exception handling while fetching theme styles. flys-client/trunk@2944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 12 Oct 2011 09:34:38 +0000
parents a95e82d6bcc1
children 981dde77b49f
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java
diffstat 7 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/ChangeLog	Wed Oct 12 09:34:38 2011 +0000
@@ -1,3 +1,18 @@
+2011-10-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java:
+	  Throw a ServerException if no styles were found in the XML document.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java:
+	  Display a warning dialog if no style for the selected theme was found.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties:
+	  New error messages that are displayed if no style was found for a given
+	  theme.
+
 2011-10-12  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Oct 12 09:34:38 2011 +0000
@@ -362,6 +362,8 @@
 
     String error_no_calc_result();
 
+    String error_no_theme_styles_found();
+
 
 
     String bottom_edge();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Oct 12 09:34:38 2011 +0000
@@ -185,6 +185,7 @@
 error_no_meta_data_found = No meta data found.
 error_load_artifact = Error while adding data to the current project.
 error_no_calc_result=No calculation results found.
+error_no_theme_styles_found=No style for the selected theme found.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Oct 12 09:34:38 2011 +0000
@@ -186,6 +186,7 @@
 error_no_meta_data_found = Keine Meta-Daten gefunden.
 error_load_artifact = Fehler beim Hinzu\u00fcgen neuer Daten in das aktuelle Projekt.
 error_no_calc_result=Es wurden keine Berechnungsergebnisse gefunden.
+error_no_theme_styles_found=Es konnten keine Stile f\u00fcr das gew\u00e4hlte Thema gefunden werden.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Wed Oct 12 09:34:38 2011 +0000
@@ -180,6 +180,7 @@
 error_no_meta_data_found = No meta data found.
 error_load_artifact = Error while adding data to the current project.
 error_no_calc_result=No calculation results found.
+error_no_theme_styles_found=No style for the selected theme found.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java	Wed Oct 12 09:34:38 2011 +0000
@@ -535,7 +535,7 @@
             locale,
             new AsyncCallback<CollectionItemAttribute>() {
                 public void onFailure (Throwable caught) {
-                    GWT.log("Could not get Collection item attributes.");
+                    SC.warn(MSG.getString(caught.getMessage()));
                 }
                 public void onSuccess(CollectionItemAttribute cia) {
                     GWT.log("Successfully loaded collectionitem attributes.");
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Wed Oct 12 09:34:38 2011 +0000
@@ -35,6 +35,9 @@
 
     public static final String OPERATION_FAILURE = "FAILED";
 
+    public static final String ERROR_NO_STYLES_FOUND =
+        "error_no_theme_styles_found";
+
 
     public CollectionItemAttribute getCollectionItemAttribute(
         Collection collection,
@@ -76,7 +79,8 @@
         catch (ConnectionException ce) {
             System.err.println(ce.getLocalizedMessage());
         }
-        throw new ServerException("");
+
+        throw new ServerException(ERROR_NO_STYLES_FOUND);
     }
 
 
@@ -108,15 +112,17 @@
         throw new ServerException("");
     }
 
-    protected CollectionItemAttribute readXML (Document doc, String artifact) {
+    protected CollectionItemAttribute readXML(Document doc, String artifact)
+    throws    ServerException
+    {
         CollectionItemAttribute cia = new CollectionItemAttribute();
         cia.setArtifact(artifact);
 
         Element root = doc.getDocumentElement();
         NodeList themes = root.getElementsByTagName("art:themes");
 
-        if (themes.getLength() != 1) {
-            return null;
+        if (themes == null || themes.getLength() == 0) {
+            throw new ServerException(ERROR_NO_STYLES_FOUND);
         }
 
         Element e = (Element) themes.item(0);

http://dive4elements.wald.intevation.org