changeset 3692:d18e6811e924

Refactor UserServiceImpl getCurrentUser method Return the logged in user in getCurrentUser method. flys-client/trunk@5378 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 07 Sep 2012 11:58:11 +0000
parents b0c1d9e06a69
children b63e6fdd8cd0
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java
diffstat 2 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Sep 07 11:37:00 2012 +0000
+++ b/flys-client/ChangeLog	Fri Sep 07 11:58:11 2012 +0000
@@ -1,3 +1,9 @@
+2012-09-04	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/UserServiceImpl.java:
+	  Refactor getCurrentUser to return the logged in user and not the first
+	  user from the artifact database.
+
 2012-09-04	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/RemoteServiceServlet.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java	Fri Sep 07 11:37:00 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java	Fri Sep 07 11:58:11 2012 +0000
@@ -8,21 +8,17 @@
 
 import org.apache.log4j.Logger;
 
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
 import de.intevation.artifacts.common.ArtifactNamespaceContext;
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
-import de.intevation.artifacts.httpclient.http.HttpClient;
-import de.intevation.artifacts.httpclient.http.HttpClientImpl;
 
 import de.intevation.flys.client.client.services.UserService;
+import de.intevation.flys.client.server.auth.UserClient;
 import de.intevation.flys.client.shared.exceptions.AuthenticationException;
 import de.intevation.flys.client.shared.model.DefaultUser;
 import de.intevation.flys.client.shared.model.User;
 
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
@@ -40,22 +36,13 @@
     {
         String url = getServletContext().getInitParameter("server-url");
 
-        HttpClient client = new HttpClientImpl(url);
+        UserClient client = new UserClient(url);
+        de.intevation.flys.client.server.auth.User loginuser = getUser();
 
         try {
-            Document users = (Document) client.listUsers();
-
-            String XPATH_USERS = "/art:users/art:user";
+            Element user = client.findUser(loginuser);
 
-            NodeList theUsers = (NodeList) XMLUtils.xpath(
-                users,
-                XPATH_USERS,
-                XPathConstants.NODESET,
-                ArtifactNamespaceContext.INSTANCE);
-
-            if (theUsers != null && theUsers.getLength() > 0) {
-                Element user = (Element)theUsers.item(0);
-
+            if (user != null) {
                 String uuid = user.getAttributeNS(
                         ArtifactNamespaceContext.NAMESPACE_URI, "uuid");
                 String name = user.getAttributeNS(

http://dive4elements.wald.intevation.org