comparison flys-client/src/main/java/de/intevation/flys/client/server/auth/UserClient.java @ 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 2c306a3dacef
children a050cb5f303f
comparison
equal deleted inserted replaced
3694:0a277b041770 3695:5e4d91304484
29 public UserClient(String url) { 29 public UserClient(String url) {
30 this.url = url; 30 this.url = url;
31 } 31 }
32 32
33 public boolean userExists(User user) throws ConnectionException { 33 public boolean userExists(User user) throws ConnectionException {
34 Element data = this.findUser(user);
35
36 if (user == null) { 34 if (user == null) {
37 return false; 35 return false;
38 } 36 }
37
38 Element data = this.findUser(user);
39
39 String XPATH_USERACCOUNT = "/art:user/art:account/@art:name"; 40 String XPATH_USERACCOUNT = "/art:user/art:account/@art:name";
40 41
41 String account = XMLUtils.xpathString( 42 String account = XMLUtils.xpathString(
42 data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE); 43 data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE);
43 44
125 126
126 action.appendChild(type); 127 action.appendChild(type);
127 action.appendChild(account); 128 action.appendChild(account);
128 document.appendChild(action); 129 document.appendChild(action);
129 130
130 logger.debug("Find user request xml: " + XMLUtils.toString(document)); 131 boolean debug = logger.isDebugEnabled();
132
133 if (debug) {
134 logger.debug("Find user request xml: " +
135 XMLUtils.toString(document));
136 }
131 137
132 Document resp = client.findUser(document); 138 Document resp = client.findUser(document);
133 139
134 logger.debug("Find user request response xml: " + XMLUtils.toString(resp)); 140 if (debug) {
141 logger.debug("Find user request response xml: " +
142 XMLUtils.toString(resp));
143 }
135 144
136 return resp.getDocumentElement(); 145 return resp.getDocumentElement();
137 } 146 }
138 } 147 }
139 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80: 148 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80:

http://dive4elements.wald.intevation.org