annotate 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
rev   line source
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server.auth;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
2
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
3 import javax.xml.xpath.XPathConstants;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
4
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
6
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Document;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Element;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
9 import org.w3c.dom.Node;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
10 import org.w3c.dom.NodeList;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
11
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.common.ArtifactNamespaceContext;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.common.utils.XMLUtils;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
14
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.httpclient.http.HttpClient;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19 /**
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20 * UserClient is a class to allow easier communication
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21 * with the REST based artifact user protocol
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
22 */
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 public class UserClient {
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25 private static final Logger logger = Logger.getLogger(UserClient.class);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
27 private String url;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29 public UserClient(String url) {
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30 this.url = url;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31 }
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 public boolean userExists(User user) throws ConnectionException {
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
34 if (user == null) {
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 return false;
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 }
3695
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
37
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
38 Element data = this.findUser(user);
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
39
3524
2c306a3dacef Use xml namespace for XPath query to get the accout name attribute.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3507
diff changeset
40 String XPATH_USERACCOUNT = "/art:user/art:account/@art:name";
3505
637d114232b2 Don't use XPath Query to get attribute of a XML Node
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 2984
diff changeset
41
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
42 String account = XMLUtils.xpathString(
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
43 data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
44
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
45 if (account == null) {
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
46 return false;
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47 }
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
48
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
49 return account.equals(user.getAccount());
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50 }
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 public boolean createUser(User user) throws ConnectionException {
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53 logger.debug("Creating new user " + user.getName());
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
54 HttpClient client = new HttpClientImpl(this.url);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
56 Document document = XMLUtils.newDocument();
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
57
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
59 document,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 ArtifactNamespaceContext.NAMESPACE_URI,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
61 ArtifactNamespaceContext.NAMESPACE_PREFIX
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 );
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
64 Element action = creator.create("action");
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
65
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 Element type = creator.create("type");
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67 type.setAttribute("name", "create");
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
68 Element artuser = creator.create("user");
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
69 artuser.setAttribute("name", user.getName());
3506
f2a4e6e92ffd Send account data to artifact rest interface to create a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3505
diff changeset
70 Element account = creator.create("account");
f2a4e6e92ffd Send account data to artifact rest interface to create a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3505
diff changeset
71 account.setAttribute("name", user.getAccount());
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
72
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
73 //TODO create roles
3506
f2a4e6e92ffd Send account data to artifact rest interface to create a user
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3505
diff changeset
74 artuser.appendChild(account);
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 action.appendChild(type);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
76 action.appendChild(artuser);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
77 document.appendChild(action);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
78
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
79 logger.debug("Create user request xml: " + XMLUtils.toString(document));
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
80
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
81 Document resp = client.createUser(document);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
82
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
83 logger.debug("Create user response xml: " + XMLUtils.toString(resp));
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
84
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
85 String XPATH_RESPONSE = "/art:result";
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
86 Node nresult = (Node) XMLUtils.xpath(
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
87 resp,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
88 XPATH_RESPONSE,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
89 XPathConstants.NODE,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
90 ArtifactNamespaceContext.INSTANCE);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
91 String result = nresult.getTextContent();
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
92 return (result != null && result.equalsIgnoreCase("success"));
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
93 }
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
94
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
95 public NodeList listUsers() throws ConnectionException {
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
96 HttpClient client = new HttpClientImpl(this.url);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
97
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98 Document users = (Document) client.listUsers();
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
99
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
100 String XPATH_USERS = "/art:users/art:user";
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
101
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
102 return (NodeList) XMLUtils.xpath(
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
103 users,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
104 XPATH_USERS,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
105 XPathConstants.NODESET,
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
106 ArtifactNamespaceContext.INSTANCE);
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
107 }
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
108
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
109 public Element findUser(User user) throws ConnectionException {
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
110 HttpClient client = new HttpClientImpl(this.url);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
111
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
112 Document document = XMLUtils.newDocument();
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
113
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
114 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
115 document,
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
116 ArtifactNamespaceContext.NAMESPACE_URI,
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
117 ArtifactNamespaceContext.NAMESPACE_PREFIX
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
118 );
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
119
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
120 Element action = creator.create("action");
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
121
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
122 Element type = creator.create("type");
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
123 type.setAttribute("name", "find");
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
124 Element account = creator.create("account");
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
125 account.setAttribute("name", user.getAccount());
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
126
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
127 action.appendChild(type);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
128 action.appendChild(account);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
129 document.appendChild(action);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
130
3695
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
131 boolean debug = logger.isDebugEnabled();
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
132
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
133 if (debug) {
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
134 logger.debug("Find user request xml: " +
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
135 XMLUtils.toString(document));
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
136 }
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
137
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
138 Document resp = client.findUser(document);
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
139
3695
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
140 if (debug) {
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
141 logger.debug("Find user request response xml: " +
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
142 XMLUtils.toString(resp));
5e4d91304484 Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3524
diff changeset
143 }
3507
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
144
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
145 return resp.getDocumentElement();
59c77a9551c8 User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3506
diff changeset
146 }
2984
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
147 }
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
148 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80:
06d999e95615 Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
149

http://dive4elements.wald.intevation.org