# HG changeset patch # User Ingo Weinzierl # Date 1318412078 0 # Node ID c4c957a9c0928918763ac3331abff889508c17d5 # Parent a95e82d6bcc12863daeda64a8855d5ab4eb99179 Improved exception handling while fetching theme styles. flys-client/trunk@2944 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java, diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.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(); diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- 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 diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- 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 diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- 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 diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java --- 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() { 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."); diff -r a95e82d6bcc1 -r c4c957a9c092 flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java --- 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);