Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/auth/UserClient.java @ 4215:c179cd02177d
Logout the current user
Add code to the logout button to remove the current user from the session and to
redirect the browser window to the login page.
Part of flys/issue916 (Logout: "Abmelden" Knopf mit Funktion belegen)
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 23 Oct 2012 09:59:16 +0200 |
parents | 2e12518ff5b4 |
children |
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 { |
3696 | 53 if(user == null) { |
54 logger.warn("createUser: given user is null"); | |
55 return false; | |
56 } | |
3697
2e12518ff5b4
Removed trailing whitespace. Reverted functional change in parsing plain user file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3696
diff
changeset
|
57 |
2984
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 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
|
59 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
|
60 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 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
|
62 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 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
|
64 document, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 ArtifactNamespaceContext.NAMESPACE_URI, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 ArtifactNamespaceContext.NAMESPACE_PREFIX |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 ); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 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
|
70 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 //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
|
79 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
|
80 action.appendChild(type); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 action.appendChild(artuser); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 document.appendChild(action); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 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
|
85 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 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
|
87 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 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
|
89 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 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
|
91 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
|
92 resp, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 XPATH_RESPONSE, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 XPathConstants.NODE, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 ArtifactNamespaceContext.INSTANCE); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
96 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
|
97 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
|
98 } |
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 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
|
101 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
|
102 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
103 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
|
104 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
105 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
|
106 |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
107 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
|
108 users, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
109 XPATH_USERS, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
110 XPathConstants.NODESET, |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
111 ArtifactNamespaceContext.INSTANCE); |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
112 } |
3507
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 public Element findUser(User user) throws ConnectionException { |
3696 | 115 if(user == null) { |
116 throw new IllegalArgumentException("user is null"); | |
117 } | |
3697
2e12518ff5b4
Removed trailing whitespace. Reverted functional change in parsing plain user file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3696
diff
changeset
|
118 |
3507
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
119 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
|
120 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
121 Document document = XMLUtils.newDocument(); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
122 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
123 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
|
124 document, |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
125 ArtifactNamespaceContext.NAMESPACE_URI, |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
126 ArtifactNamespaceContext.NAMESPACE_PREFIX |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
127 ); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
128 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
129 Element action = creator.create("action"); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
130 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
131 Element type = creator.create("type"); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
132 type.setAttribute("name", "find"); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
133 Element account = creator.create("account"); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
134 account.setAttribute("name", user.getAccount()); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
135 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
136 action.appendChild(type); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
137 action.appendChild(account); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
138 document.appendChild(action); |
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 boolean debug = logger.isDebugEnabled(); |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
141 |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
142 if (debug) { |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
143 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
|
144 XMLUtils.toString(document)); |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
145 } |
3507
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
146 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
147 Document resp = client.findUser(document); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
148 |
3695
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
149 if (debug) { |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
150 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
|
151 XMLUtils.toString(resp)); |
5e4d91304484
Be more defensive about fetchimg users from session.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3524
diff
changeset
|
152 } |
3507
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
153 |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
154 return resp.getDocumentElement(); |
59c77a9551c8
User new find-user REST service in UserClient
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3506
diff
changeset
|
155 } |
2984
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
156 } |
06d999e95615
Add UserClient class to handle REST communication for user related interfaces.
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
157 // 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
|
158 |