[PATCH] More robustness in FLYS.onModuleLoad() service calls

Wald Commits scm-commit at wald.intevation.org
Thu Jun 27 17:42:24 CEST 2013


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1372347742 -7200
# Node ID d19a0ffb9ccffc8594da994a58641d9da517c1bf
# Parent  ac6c41fcae55e390619ed6cb6e302c7d9ac02473
More robustness in FLYS.onModuleLoad() service calls.

diff -r ac6c41fcae55 -r d19a0ffb9ccf gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java	Thu Jun 27 17:36:51 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java	Thu Jun 27 17:42:22 2013 +0200
@@ -165,29 +165,7 @@
                 Config.getInstance().setWikiUrl(result.get("help-url"));
 
                 // Start user service; somewhat nested here...
-                userService.getCurrentUser(locale, new AsyncCallback<User>() {
-                    @Override
-                    public void onFailure(Throwable caught) {
-                        GWT.log("Could not find a logged in user.");
-                        String msg = getExceptionString(MSG, caught);
-                        SC.warn(msg);
-                    }
-
-                    @Override
-                    public void onSuccess(User user) {
-                        GWT.log("Found a user. Set '"+ user.getName() + "'");
-                        setCurrentUser(user);
-
-                        header.setCurrentUser(user);
-
-                        projectList = new ProjectList(FLYS.this, user);
-                        workspace   = new FLYSWorkspace(FLYS.this);
-                        view.setProjectList(projectList);
-                        view.setFLYSWorkspace(workspace);
-
-                        readRivers();
-                    }
-                });
+                startUserService(locale);
             }
 
             @Override
@@ -195,6 +173,33 @@
                GWT.log("Could not read server information.");
                String msg = getExceptionString(MSG, caught);
                SC.warn(msg);
+               startUserService(locale);
+            }
+        });
+    }
+
+    protected void startUserService(String locale) {
+        userService.getCurrentUser(locale, new AsyncCallback<User>() {
+            @Override
+            public void onFailure(Throwable caught) {
+                GWT.log("Could not find a logged in user.");
+                String msg = getExceptionString(MSG, caught);
+                SC.warn(msg);
+            }
+
+            @Override
+            public void onSuccess(User user) {
+                GWT.log("Found a user. Set '"+ user.getName() + "'");
+                setCurrentUser(user);
+
+                header.setCurrentUser(user);
+
+                projectList = new ProjectList(FLYS.this, user);
+                workspace   = new FLYSWorkspace(FLYS.this);
+                view.setProjectList(projectList);
+                view.setFLYSWorkspace(workspace);
+
+                readRivers();
             }
         });
     }


More information about the Dive4elements-commits mailing list