Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java @ 55:4439f642f632
Read min/max values for the distance mode in the LocationDistancePanel.
flys-client/trunk@1511 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 Mar 2011 08:45:25 +0000 |
parents | d573ae975330 |
children | 907b61e4d702 |
rev | line source |
---|---|
2
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
25
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
3 import javax.xml.xpath.XPathConstants; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
4 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
5 import org.w3c.dom.Document; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
6 import org.w3c.dom.Node; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
7 import org.w3c.dom.NodeList; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
8 |
2
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
25
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
11 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
12 import de.intevation.artifacts.common.utils.XMLUtils; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
13 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
14 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
15 import de.intevation.artifacts.httpclient.http.HttpClient; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
16 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
2
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.client.client.services.UserService; |
25
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
19 import de.intevation.flys.client.shared.model.DefaultUser; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
20 import de.intevation.flys.client.shared.model.User; |
2
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 */ |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public class UserServiceImpl |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 extends RemoteServiceServlet |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 implements UserService |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 { |
25
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
30 public User getCurrentUser(String serverUrl) { |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
31 HttpClient client = new HttpClientImpl(serverUrl); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
32 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
33 try { |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
34 Document users = (Document) client.listUsers(); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
35 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
36 String XPATH_USERS = "/art:users/art:user"; |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
37 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
38 NodeList theUsers = (NodeList) XMLUtils.xpath( |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
39 users, |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
40 XPATH_USERS, |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
41 XPathConstants.NODESET, |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
42 ArtifactNamespaceContext.INSTANCE); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
43 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
44 if (theUsers != null && theUsers.getLength() > 0) { |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
45 Node user = theUsers.item(0); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
46 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
47 String uuid = XMLUtils.xpathString( |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
48 user, "@art:uuid", ArtifactNamespaceContext.INSTANCE); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
49 String name = XMLUtils.xpathString( |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
50 user, "@art:name", ArtifactNamespaceContext.INSTANCE); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
51 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
52 return new DefaultUser(uuid, name); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
53 } |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
54 } |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
55 catch (ConnectionException ce) { |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
56 System.err.println(ce.getLocalizedMessage()); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
57 } |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
58 |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
59 System.err.println("No users existing in the server."); |
2da6be38d8b6
Added a User interface and a default implementation to handle users in this client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
60 return null; |
2
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 } |
bc5d4d2297b9
Introduced a service that retrieves the user who is currently logged in. This user is displayed in the menu bar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |