Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java @ 48:6e191588a295
Render the Single-W panel initially when the WQInputPanel is rendered.
flys-client/trunk@1496 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Mar 2011 11:23:07 +0000 |
parents | 2da6be38d8b6 |
children | d573ae975330 |
line wrap: on
line source
package de.intevation.flys.client.server; import javax.xml.xpath.XPathConstants; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.core.client.GWT; 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.artifacts.httpclient.http.response.DocumentResponseHandler; import de.intevation.flys.client.client.services.UserService; 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> */ public class UserServiceImpl extends RemoteServiceServlet implements UserService { public User getCurrentUser(String serverUrl) { HttpClient client = new HttpClientImpl(serverUrl); try { Document users = (Document) client.listUsers(); String XPATH_USERS = "/art:users/art:user"; NodeList theUsers = (NodeList) XMLUtils.xpath( users, XPATH_USERS, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE); if (theUsers != null && theUsers.getLength() > 0) { Node user = theUsers.item(0); String uuid = XMLUtils.xpathString( user, "@art:uuid", ArtifactNamespaceContext.INSTANCE); String name = XMLUtils.xpathString( user, "@art:name", ArtifactNamespaceContext.INSTANCE); return new DefaultUser(uuid, name); } } catch (ConnectionException ce) { System.err.println(ce.getLocalizedMessage()); } System.err.println("No users existing in the server."); return null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :