changeset 6480:d19a0ffb9ccf

More robustness in FLYS.onModuleLoad() service calls.
author Christian Lins <christian.lins@intevation.de>
date Thu, 27 Jun 2013 17:42:22 +0200
parents ac6c41fcae55
children b07cfc319781
files gwt-client/src/main/java/org/dive4elements/river/client/client/FLYS.java
diffstat 1 files changed, 28 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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();
             }
         });
     }

http://dive4elements.wald.intevation.org