changeset 4062:145980c21700

Handle error conditions more robust.
author Christian Lins <christian.lins@intevation.de>
date Mon, 08 Oct 2012 12:10:50 +0200
parents c3b959de4d83
children 7c03d3bd9262
files .hgignore flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java
diffstat 5 files changed, 115 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Oct 08 11:01:20 2012 +0200
+++ b/.hgignore	Mon Oct 08 12:10:50 2012 +0200
@@ -14,5 +14,6 @@
 flys-client/\.project   # eclipse
 flys-client/\.settings  # eclipse
 flys-client/test-output # eclipse junit/testng plugin output
+flys-client/src/main/webapp/OpenLayers-2.11
 \.swp
 \.swo
--- a/flys-client/ChangeLog	Mon Oct 08 11:01:20 2012 +0200
+++ b/flys-client/ChangeLog	Mon Oct 08 12:10:50 2012 +0200
@@ -1,3 +1,13 @@
+2012-10-08	Christian Lins	<christian.lins@intevation.de>
+
+	* ../.hgignore:
+	  Add OpenLayers to ignore file.
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java,
+	  src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
+	  Handle error conditions more robust (#912 #897).
+
 2012-10-08	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Mon Oct 08 11:01:20 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Mon Oct 08 12:10:50 2012 +0200
@@ -104,9 +104,9 @@
     protected List<String> openProjects;
 
 
-    protected String getExceptionString(Throwable caught) {
+    public static String getExceptionString(FLYSConstants msg, Throwable caught) {
         try {
-            return MSG.getString(caught.getMessage());
+            return msg.getString(caught.getMessage());
         }
         catch(MissingResourceException ex) {
             // There are some server error exceptions with
@@ -162,7 +162,7 @@
             @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not find a logged in user.");
-                String msg = getExceptionString(caught);
+                String msg = getExceptionString(MSG, caught);
                 SC.warn(msg);
             }
 
@@ -282,7 +282,7 @@
             @Override
             public void onFailure(Throwable caught) {
                 GWT.log("Could not recieve a list of rivers.");
-                SC.warn(getExceptionString(caught));
+                SC.warn(getExceptionString(MSG, caught));
             }
 
             @Override
@@ -362,7 +362,7 @@
             new AsyncCallback<Collection>() {
                 @Override
                 public void onFailure(Throwable caught) {
-                    SC.warn(getExceptionString(caught));
+                    SC.warn(getExceptionString(MSG, caught));
                 }
 
                 @Override
@@ -399,7 +399,7 @@
                             @Override
                             public void onFailure(Throwable caught) {
                                 unlockProject(collectionID);
-                                SC.warn(getExceptionString(caught));
+                                SC.warn(getExceptionString(MSG, caught));
                             }
 
                             @Override
@@ -440,7 +440,7 @@
                 @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create the new artifact.");
-                    SC.warn(getExceptionString(caught));
+                    SC.warn(getExceptionString(MSG, caught));
                 }
 
                 @Override
@@ -470,7 +470,7 @@
                 @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not create new collection.");
-                    SC.warn(getExceptionString(caught));
+                    SC.warn(getExceptionString(MSG, caught));
                 }
 
                 @Override
@@ -483,7 +483,7 @@
                             @Override
                             public void onFailure(Throwable caught) {
                                 GWT.log("Could not create the new artifact.");
-                                SC.warn(getExceptionString(caught));
+                                SC.warn(getExceptionString(MSG, caught));
                             }
 
                             @Override
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Mon Oct 08 11:01:20 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Mon Oct 08 12:10:50 2012 +0200
@@ -1,38 +1,33 @@
 package de.intevation.flys.client.client.ui;
 
-import java.util.List;
-import java.util.LinkedHashMap;
-
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
+import com.smartgwt.client.types.Encoding;
+import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Button;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLPane;
 import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.events.ResizedEvent;
-import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
-import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
+import com.smartgwt.client.widgets.events.ResizedEvent;
+import com.smartgwt.client.widgets.events.ResizedHandler;
+import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
 import com.smartgwt.client.widgets.events.VisibilityChangedHandler;
-import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
-import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.UploadItem;
 import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.HTMLPane;
-import com.smartgwt.client.types.Encoding;
+import com.smartgwt.client.widgets.form.fields.UploadItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
+import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
 
-import org.gwtopenmaps.openlayers.client.Map;
-import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
-import org.gwtopenmaps.openlayers.client.format.GeoJSON;
-import org.gwtopenmaps.openlayers.client.layer.WMS;
-import org.gwtopenmaps.openlayers.client.layer.WMSParams;
-import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
-
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.services.MapInfoService;
+import de.intevation.flys.client.client.services.MapInfoServiceAsync;
+import de.intevation.flys.client.client.ui.map.FloodMap;
+import de.intevation.flys.client.client.ui.map.MapPanel;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 import de.intevation.flys.client.shared.model.DataList;
@@ -40,11 +35,15 @@
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.MapInfo;
 
-import de.intevation.flys.client.client.Config;
-import de.intevation.flys.client.client.ui.map.FloodMap;
-import de.intevation.flys.client.client.ui.map.MapPanel;
-import de.intevation.flys.client.client.services.MapInfoService;
-import de.intevation.flys.client.client.services.MapInfoServiceAsync;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
+import org.gwtopenmaps.openlayers.client.format.GeoJSON;
+import org.gwtopenmaps.openlayers.client.layer.WMS;
+import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
+import org.gwtopenmaps.openlayers.client.layer.WMSParams;
 
 
 public class DigitizePanel
@@ -100,6 +99,7 @@
 
         String river = getDataValue("state.winfo.river", "river");
         mapInfo.getMapInfo(locale, river, new AsyncCallback<MapInfo>() {
+            @Override
             public void onFailure(Throwable caught) {
                 String msg = caught.getMessage();
 
@@ -107,6 +107,7 @@
                 SC.warn(MSG.getString(msg));
             }
 
+            @Override
             public void onSuccess(MapInfo info) {
                 createMapWidget(info, geojson[0]);
             }
@@ -123,6 +124,7 @@
      *
      * @return a combobox.
      */
+    @Override
     protected Canvas createWidget(DataList data) {
         GWT.log("DigitizePanel - createWidget()");
 
@@ -191,6 +193,7 @@
             uploadForm.setFields(uploadItem);
             Button submit = new Button(MSG.upload_file());
             submit.addClickHandler(new ClickHandler() {
+                @Override
                 public void onClick(ClickEvent e) {
                     uploadForm.submitForm();
                 }
@@ -216,12 +219,17 @@
         Data[] data  = super.getData();
         Data[] total = new Data[2];
 
-        DataItem item = new DefaultDataItem(
-            UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON());
-
-        total[0] = data[0];
-        total[1] = new DefaultData(
-            UESK_BARRIERS, null, null, new DataItem[] { item });
+        if (floodMap != null) {
+            DataItem item = new DefaultDataItem(
+                UESK_BARRIERS, UESK_BARRIERS, floodMap.getFeaturesAsGeoJSON());
+            total[0] = data[0];
+            total[1] = new DefaultData(
+                UESK_BARRIERS, null, null, new DataItem[] { item });
+        }
+        else {
+            // Happens when OpenLayers is missing
+            GWT.log("floodMap is null -> OpenLayers missing?");
+        }
 
         return total;
     }
@@ -235,6 +243,7 @@
 
         helperContainer.addMember(mapPanel);
         helperContainer.addResizedHandler(new ResizedHandler() {
+            @Override
             public void onResized(ResizedEvent e) {
                 Integer height = helperContainer.getHeight();
                 Integer width  = helperContainer.getWidth();
@@ -291,6 +300,7 @@
     }
 
 
+    @Override
     public void onTabSelected(TabSelectedEvent tse) {
         if (tse.getTabNum () != 0) {
             floodMap.hideBarrierLayer();
@@ -300,6 +310,7 @@
         }
     }
 
+    @Override
     public void onVisibilityChanged(VisibilityChangedEvent vce) {
         if (!vce.getIsVisible()) {
             floodMap.hideBarrierLayer();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Mon Oct 08 11:01:20 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Mon Oct 08 12:10:50 2012 +0200
@@ -1,11 +1,5 @@
 package de.intevation.flys.client.client.ui;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
@@ -20,19 +14,6 @@
 import com.smartgwt.client.widgets.tab.Tab;
 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
 
-import de.intevation.flys.client.shared.model.Artifact;
-import de.intevation.flys.client.shared.model.WINFOArtifact;
-import de.intevation.flys.client.shared.model.ArtifactDescription;
-import de.intevation.flys.client.shared.model.Collection;
-import de.intevation.flys.client.shared.model.Data;
-import de.intevation.flys.client.shared.model.DataItem;
-import de.intevation.flys.client.shared.model.DataList;
-import de.intevation.flys.client.shared.model.DefaultData;
-import de.intevation.flys.client.shared.model.DefaultDataItem;
-import de.intevation.flys.client.shared.model.ReportMode;
-import de.intevation.flys.client.shared.model.ExportMode;
-import de.intevation.flys.client.shared.model.OutputMode;
-import de.intevation.flys.client.shared.model.River;
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYS;
 import de.intevation.flys.client.client.FLYSConstants;
@@ -51,13 +32,32 @@
 import de.intevation.flys.client.client.event.StepForwardEvent;
 import de.intevation.flys.client.client.event.StepForwardHandler;
 import de.intevation.flys.client.client.services.AdvanceService;
-import de.intevation.flys.client.client.services.ReportService;
 import de.intevation.flys.client.client.services.AdvanceServiceAsync;
 import de.intevation.flys.client.client.services.ArtifactService;
 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
+import de.intevation.flys.client.client.services.ReportService;
+import de.intevation.flys.client.client.services.ReportServiceAsync;
 import de.intevation.flys.client.client.services.StepForwardService;
 import de.intevation.flys.client.client.services.StepForwardServiceAsync;
-import de.intevation.flys.client.client.services.ReportServiceAsync;
+import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.ArtifactDescription;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
+import de.intevation.flys.client.shared.model.ExportMode;
+import de.intevation.flys.client.shared.model.OutputMode;
+import de.intevation.flys.client.shared.model.ReportMode;
+import de.intevation.flys.client.shared.model.River;
+import de.intevation.flys.client.shared.model.WINFOArtifact;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
 
 
 public class ParameterList
@@ -213,11 +213,13 @@
         gaugeSection.setExpanded(false);
         gaugeSection.setTitle(MSG.gaugePanelTitle());
         gaugePanel = new GaugePanel(flys, gaugeSection) {
+            @Override
             public void addMember(Canvas component) {
                 super.addMember(component);
                 gaugeSection.setExpanded(true);
             }
 
+            @Override
             public void removeMembers(Canvas[] components) {
                 super.removeMembers(components);
                 gaugeSection.setExpanded(false);
@@ -231,11 +233,13 @@
         helperSection.setExpanded(false);
         helperSection.setTitle(MSG.helperPanelTitle());
         helperPanel = new VLayout() {
+            @Override
             public void addMember(Canvas component) {
                 super.addMember(component);
                 stack.expandSection(helperSection.getID());
             }
 
+            @Override
             public void removeMembers(Canvas[] components) {
                 super.removeMembers(components);
                 helperSection.setExpanded(false);
@@ -250,11 +254,13 @@
         tableSection.setExpanded(false);
         tableSection.setTitle(MSG.calcTableTitle());
         tablePanel = new VLayout() {
+            @Override
             public void addMember(Canvas component) {
                 super.addMember(component);
                 tableSection.setExpanded(true);
             }
 
+            @Override
             public void removeMembers(Canvas[] components) {
                 super.removeMembers(components);
                 tableSection.setExpanded(false);
@@ -296,6 +302,7 @@
      *
      * @param handler The new ParameterChangeHandler.
      */
+    @Override
     public void addParameterChangeHandler(ParameterChangeHandler handler) {
         if (handler != null) {
             parameterHandlers.add(handler);
@@ -343,11 +350,12 @@
             items);
 
         LinkSelection widget           = new LinkSelection();
-        HasStepForwardHandlers handler = (HasStepForwardHandlers) widget;
+        HasStepForwardHandlers handler = widget;
 
         widget.setContainer(helperPanel);
 
         handler.addStepForwardHandler(new StepForwardHandler() {
+            @Override
             public void onStepForward(StepForwardEvent event) {
                 lockUI();
                 Data[] data = event.getData();
@@ -375,23 +383,27 @@
                 artifactService.create(
                     locale, module.toLowerCase(), null,
                     new AsyncCallback<Artifact>() {
+                        @Override
                         public void onFailure(Throwable caught) {
                             unlockUI();
                             GWT.log("Could not create the new artifact.");
                             SC.warn(MSG.getString(caught.getMessage()));
                         }
 
+                        @Override
                         public void onSuccess(Artifact artifact) {
                             GWT.log("Successfully created a new artifact.");
 
                             forwardService.go(locale, artifact, feedData,
                             new AsyncCallback<Artifact>() {
+                                @Override
                                 public void onFailure(Throwable caught) {
                                     unlockUI();
                                     GWT.log("Could not feed the artifact.");
                                     SC.warn(caught.getMessage());
                                 }
 
+                                @Override
                                 public void onSuccess(Artifact artifact) {
                                     GWT.log("Successfully feed the artifact.");
                                     old.clear();
@@ -604,6 +616,7 @@
      *
      * @param event The StepForwardEvent.
      */
+    @Override
     public void onStepForward(StepForwardEvent event) {
         GWT.log("CollectionView - onStepForward()");
         lockUI();
@@ -613,12 +626,14 @@
 
         forwardService.go(locale, artifact, event.getData(),
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     unlockUI();
                     GWT.log("Could not feed the artifact.");
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(FLYS.getExceptionString(MSG, caught));
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Successfully feed the artifact.");
                     old.clear();
@@ -636,6 +651,7 @@
      *
      * @param e The StepBackEvent that holds the identifier of the target state.
      */
+    @Override
     public void onStepBack(StepBackEvent e) {
         lockUI();
         final String target    = e.getTarget();
@@ -645,12 +661,14 @@
 
         advanceService.advance(locale, artifact, target,
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     unlockUI();
                     GWT.log("Could not go back to '" + target + "'");
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(FLYS.getExceptionString(MSG, caught));
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Successfully step back to '" + target + "'");
 
@@ -664,17 +682,20 @@
     }
 
 
+    @Override
     public void onAdvance(final String target) {
         Config config          = Config.getInstance();
         final String locale    = config.getLocale();
 
         advanceService.advance(locale, artifact, target,
             new AsyncCallback<Artifact>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Could not go to '" + target + "'");
-                    SC.warn(MSG.getString(caught.getMessage()));
+                    SC.warn(FLYS.getExceptionString(MSG, caught));
                 }
 
+                @Override
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Successfully advanced to '" + target + "'");
 
@@ -693,6 +714,7 @@
      *
      * @param event The ParameterChangeEvent.
      */
+    @Override
     public void onParameterChange(ParameterChangeEvent event) {
         GWT.log("ParameterList.onParameterChange");
 
@@ -758,6 +780,7 @@
     }
 
 
+    @Override
     public void onCollectionChange(CollectionChangeEvent event) {
         Collection                 c = event.getNewValue();
         Map<String, OutputMode> outs = c.getOutputModes();
@@ -775,6 +798,7 @@
     }
 
 
+    @Override
     public void onOutputModesChange(OutputModesChangeEvent event) {
 
         Collection c = cView.getCollection();
@@ -855,10 +879,12 @@
 
             reportService.report(cid, locale, report.getName(),
                 new AsyncCallback<String>() {
+                    @Override
                     public void onFailure(Throwable caught) {
-                        SC.warn(caught.getMessage());
+                        SC.warn(FLYS.getExceptionString(MSG, caught));
                     }
 
+                    @Override
                     public void onSuccess(String msg) {
                         setReportMessage(msg);
                     }

http://dive4elements.wald.intevation.org