# HG changeset patch # User Bjoern Ricks # Date 1347019091 0 # Node ID d18e6811e92483db0c9531a338502b981407939d # Parent b0c1d9e06a694e97165e6f086d9eaa78a15e34d2 Refactor UserServiceImpl getCurrentUser method Return the logged in user in getCurrentUser method. flys-client/trunk@5378 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b0c1d9e06a69 -r d18e6811e924 flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/server/RemoteServiceServlet.java, diff -r b0c1d9e06a69 -r d18e6811e924 flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.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 Ingo Weinzierl */ @@ -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(