Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java @ 3530:8c9c202292fe
Set the default value of the RadioGroupItem if a loaded module is selected
flys-client/trunk@5333 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 31 Aug 2012 13:29:26 +0000 |
parents | 3a8884e06aaa |
children | fed914a42a10 |
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.Element; import org.w3c.dom.NodeList; 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.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> */ public class UserServiceImpl extends RemoteServiceServlet implements UserService { private static final Logger logger = Logger.getLogger(UserServiceImpl.class); public static final String ERROR_NO_SUCH_USER = "error_no_such_user"; public User getCurrentUser(String locale) throws AuthenticationException { String url = getServletContext().getInitParameter("server-url"); HttpClient client = new HttpClientImpl(url); 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) { Element user = (Element)theUsers.item(0); String uuid = user.getAttributeNS( ArtifactNamespaceContext.NAMESPACE_URI, "uuid"); String name = user.getAttributeNS( ArtifactNamespaceContext.NAMESPACE_URI, "name"); return new DefaultUser(uuid, name); } } catch (ConnectionException ce) { logger.error(ce, ce); } logger.error("No users existing in the server."); throw new AuthenticationException(ERROR_NO_SUCH_USER); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :