Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 29:44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
flys-client/trunk@1431 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Mar 2011 08:00:06 +0000 |
parents | dfdb927b137d |
children | a26489e55730 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Tue Mar 08 16:20:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Mar 09 08:00:06 2011 +0000 @@ -11,10 +11,13 @@ import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.DefaultCollection; +import de.intevation.flys.client.shared.model.River; import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.services.ArtifactService; import de.intevation.flys.client.client.services.ArtifactServiceAsync; +import de.intevation.flys.client.client.services.RiverService; +import de.intevation.flys.client.client.services.RiverServiceAsync; import de.intevation.flys.client.client.services.UserService; import de.intevation.flys.client.client.services.UserServiceAsync; import de.intevation.flys.client.client.ui.CollectionView; @@ -35,6 +38,9 @@ /** The UserService used to retrieve information about the current user. */ protected UserServiceAsync userService = GWT.create(UserService.class); + /** The RiverService used to retrieve the supported rivers of the server.*/ + protected RiverServiceAsync riverService = GWT.create(RiverService.class); + /** The ArtifactService used to communicate with the Artifact server. */ protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class); @@ -54,6 +60,9 @@ /** The user who is currently logged in.*/ protected User currentUser; + /** The list of rivers supported by the server.*/ + protected River[] rivers; + /** * This is the entry point method. @@ -78,6 +87,8 @@ initConfiguration(); String serverUrl = Config.getInstance().getServerUrl(); + getRivers(); + userService.getCurrentUser(serverUrl, new AsyncCallback<User>() { public void onFailure(Throwable caught) { GWT.log("Could not find a logged in user."); @@ -136,6 +147,33 @@ /** + * Returns a list of rivers supported by the artifact server. + * + * @return a list of rivers supported by the artifact server. + */ + public River[] getRivers() { + if (rivers == null) { + String url = Config.getInstance().getServerUrl(); + GWT.log("Fetch rivers from server '" + url + "'"); + + riverService.list(url, new AsyncCallback<River[]>() { + public void onFailure(Throwable caught) { + GWT.log("Could not recieve a list of rivers."); + GWT.log(caught.getMessage()); + } + + public void onSuccess(River[] newRivers) { + GWT.log("Retrieved " + newRivers.length + " new rivers."); + rivers = newRivers; + } + }); + } + + return rivers; + } + + + /** * This method creates a new CollectionView and adds it to the workspace. */ public void newProject() {