Mercurial > dive4elements > river
changeset 3695:5e4d91304484
Be more defensive about fetchimg users from session.
flys-client/trunk@5394 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 07 Sep 2012 15:58:10 +0000 |
parents | 0a277b041770 |
children | a050cb5f303f |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/server/auth/UserClient.java |
diffstat | 3 files changed, 24 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Sep 07 13:15:28 2012 +0000 +++ b/flys-client/ChangeLog Fri Sep 07 15:58:10 2012 +0000 @@ -1,3 +1,9 @@ +2012-09-07 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/client/server/UserServiceImpl.java, + src/main/java/de/intevation/flys/client/server/auth/UserClient.java: + Be more defensive about fetchimg users from session. + 2012-09-07 Felix Wolfsteller <felix.wolfsteller@intevation.de> Improved panning in TimeseriesCharts (issue715).
--- a/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java Fri Sep 07 13:15:28 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java Fri Sep 07 15:58:10 2012 +0000 @@ -1,15 +1,10 @@ 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 de.intevation.artifacts.common.ArtifactNamespaceContext; -import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.httpclient.exceptions.ConnectionException; @@ -39,6 +34,11 @@ UserClient client = new UserClient(url); de.intevation.flys.client.server.auth.User loginuser = getUser(); + if (loginuser == null) { + logger.debug("no session user"); + throw new AuthenticationException(ERROR_NO_SUCH_USER); + } + try { Element user = client.findUser(loginuser);
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/UserClient.java Fri Sep 07 13:15:28 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/UserClient.java Fri Sep 07 15:58:10 2012 +0000 @@ -31,11 +31,12 @@ } public boolean userExists(User user) throws ConnectionException { - Element data = this.findUser(user); - if (user == null) { return false; } + + Element data = this.findUser(user); + String XPATH_USERACCOUNT = "/art:user/art:account/@art:name"; String account = XMLUtils.xpathString( @@ -127,11 +128,19 @@ action.appendChild(account); document.appendChild(action); - logger.debug("Find user request xml: " + XMLUtils.toString(document)); + boolean debug = logger.isDebugEnabled(); + + if (debug) { + logger.debug("Find user request xml: " + + XMLUtils.toString(document)); + } Document resp = client.findUser(document); - logger.debug("Find user request response xml: " + XMLUtils.toString(resp)); + if (debug) { + logger.debug("Find user request response xml: " + + XMLUtils.toString(resp)); + } return resp.getDocumentElement(); }