diff options
author | Diva Canto | 2009-12-29 15:58:40 -0800 |
---|---|---|
committer | Diva Canto | 2009-12-29 15:58:40 -0800 |
commit | b4483df2701483aabd43fc7d03ebd74770d70170 (patch) | |
tree | d36e88b1409e438be222e0a994b6ca563fe26850 /OpenSim/Services/Connectors | |
parent | Tighten up the IUserService interface again. No need for auth tokens at this ... (diff) | |
download | opensim-SC-b4483df2701483aabd43fc7d03ebd74770d70170.zip opensim-SC-b4483df2701483aabd43fc7d03ebd74770d70170.tar.gz opensim-SC-b4483df2701483aabd43fc7d03ebd74770d70170.tar.bz2 opensim-SC-b4483df2701483aabd43fc7d03ebd74770d70170.tar.xz |
* All modules and connectors for user account service are in place. Untested.
* Cleaned up a few things on presence connectors
Diffstat (limited to 'OpenSim/Services/Connectors')
3 files changed, 300 insertions, 129 deletions
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs index 482862d..29cfd6e 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs | |||
@@ -109,9 +109,9 @@ namespace OpenSim.Services.Connectors | |||
109 | { | 109 | { |
110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
111 | 111 | ||
112 | if (replyData.ContainsKey("Result")) | 112 | if (replyData.ContainsKey("result")) |
113 | { | 113 | { |
114 | if (replyData["Result"].ToString().ToLower() == "success") | 114 | if (replyData["result"].ToString().ToLower() == "success") |
115 | return true; | 115 | return true; |
116 | else | 116 | else |
117 | return false; | 117 | return false; |
@@ -153,9 +153,9 @@ namespace OpenSim.Services.Connectors | |||
153 | { | 153 | { |
154 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 154 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
155 | 155 | ||
156 | if (replyData.ContainsKey("Result")) | 156 | if (replyData.ContainsKey("result")) |
157 | { | 157 | { |
158 | if (replyData["Result"].ToString().ToLower() == "success") | 158 | if (replyData["result"].ToString().ToLower() == "success") |
159 | return true; | 159 | return true; |
160 | else | 160 | else |
161 | return false; | 161 | return false; |
@@ -196,9 +196,9 @@ namespace OpenSim.Services.Connectors | |||
196 | { | 196 | { |
197 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 197 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
198 | 198 | ||
199 | if (replyData.ContainsKey("Result")) | 199 | if (replyData.ContainsKey("result")) |
200 | { | 200 | { |
201 | if (replyData["Result"].ToString().ToLower() == "success") | 201 | if (replyData["result"].ToString().ToLower() == "success") |
202 | return true; | 202 | return true; |
203 | else | 203 | else |
204 | return false; | 204 | return false; |
@@ -242,9 +242,9 @@ namespace OpenSim.Services.Connectors | |||
242 | { | 242 | { |
243 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 243 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
244 | 244 | ||
245 | if (replyData.ContainsKey("Result")) | 245 | if (replyData.ContainsKey("result")) |
246 | { | 246 | { |
247 | if (replyData["Result"].ToString().ToLower() == "success") | 247 | if (replyData["result"].ToString().ToLower() == "success") |
248 | return true; | 248 | return true; |
249 | else | 249 | else |
250 | return false; | 250 | return false; |
@@ -296,11 +296,8 @@ namespace OpenSim.Services.Connectors | |||
296 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 296 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
297 | PresenceInfo pinfo = null; | 297 | PresenceInfo pinfo = null; |
298 | 298 | ||
299 | if ((replyData != null) && (replyData["result"] != null)) | 299 | if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) |
300 | { | 300 | { |
301 | if (replyData["result"].ToString() == "null") | ||
302 | return null; | ||
303 | |||
304 | if (replyData["result"] is Dictionary<string, object>) | 301 | if (replyData["result"] is Dictionary<string, object>) |
305 | { | 302 | { |
306 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); | 303 | pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); |
@@ -345,7 +342,8 @@ namespace OpenSim.Services.Connectors | |||
345 | 342 | ||
346 | if (replyData != null) | 343 | if (replyData != null) |
347 | { | 344 | { |
348 | if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null") | 345 | if (replyData.ContainsKey("result") && |
346 | (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure")) | ||
349 | { | 347 | { |
350 | return new PresenceInfo[0]; | 348 | return new PresenceInfo[0]; |
351 | } | 349 | } |
@@ -395,9 +393,9 @@ namespace OpenSim.Services.Connectors | |||
395 | { | 393 | { |
396 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 394 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
397 | 395 | ||
398 | if (replyData.ContainsKey("Result")) | 396 | if (replyData.ContainsKey("result")) |
399 | { | 397 | { |
400 | if (replyData["Result"].ToString().ToLower() == "success") | 398 | if (replyData["result"].ToString().ToLower() == "success") |
401 | return true; | 399 | return true; |
402 | else | 400 | else |
403 | return false; | 401 | return false; |
diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Services/Connectors/User/UserServiceConnector.cs deleted file mode 100644 index 0de8c1d..0000000 --- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Services.Connectors | ||
41 | { | ||
42 | public class UserServicesConnector : IUserAccountService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | // private string m_ServerURI = String.Empty; | ||
49 | |||
50 | public UserServicesConnector() | ||
51 | { | ||
52 | } | ||
53 | |||
54 | public UserServicesConnector(string serverURI) | ||
55 | { | ||
56 | // m_ServerURI = serverURI.TrimEnd('/'); | ||
57 | } | ||
58 | |||
59 | public UserServicesConnector(IConfigSource source) | ||
60 | { | ||
61 | Initialise(source); | ||
62 | } | ||
63 | |||
64 | public virtual void Initialise(IConfigSource source) | ||
65 | { | ||
66 | IConfig assetConfig = source.Configs["UserService"]; | ||
67 | if (assetConfig == null) | ||
68 | { | ||
69 | m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); | ||
70 | throw new Exception("User connector init error"); | ||
71 | } | ||
72 | |||
73 | string serviceURI = assetConfig.GetString("UserServerURI", | ||
74 | String.Empty); | ||
75 | |||
76 | if (serviceURI == String.Empty) | ||
77 | { | ||
78 | m_log.Error("[USER CONNECTOR]: No Server URI named in section UserService"); | ||
79 | throw new Exception("User connector init error"); | ||
80 | } | ||
81 | //m_ServerURI = serviceURI; | ||
82 | } | ||
83 | |||
84 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | ||
85 | { | ||
86 | return null; | ||
87 | } | ||
88 | |||
89 | public UserAccount GetUserAccount(UUID scopeID, string email) | ||
90 | { | ||
91 | return null; | ||
92 | } | ||
93 | |||
94 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
95 | { | ||
96 | return null; | ||
97 | } | ||
98 | |||
99 | public bool SetUserAccount(UserAccount data) | ||
100 | { | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | public bool CreateUserAccount(UserAccount data) | ||
105 | { | ||
106 | return false; | ||
107 | } | ||
108 | |||
109 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
110 | { | ||
111 | return null; | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs new file mode 100644 index 0000000..d4b906a --- /dev/null +++ b/OpenSim/Services/Connectors/UserAccounts/UserServiceConnector.cs | |||
@@ -0,0 +1,287 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Services.Connectors | ||
42 | { | ||
43 | public class UserAccountServicesConnector : IUserAccountService | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger( | ||
47 | MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private string m_ServerURI = String.Empty; | ||
50 | |||
51 | public UserAccountServicesConnector() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public UserAccountServicesConnector(string serverURI) | ||
56 | { | ||
57 | m_ServerURI = serverURI.TrimEnd('/'); | ||
58 | } | ||
59 | |||
60 | public UserAccountServicesConnector(IConfigSource source) | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | public virtual void Initialise(IConfigSource source) | ||
66 | { | ||
67 | IConfig assetConfig = source.Configs["UserAccountService"]; | ||
68 | if (assetConfig == null) | ||
69 | { | ||
70 | m_log.Error("[ACCOUNT CONNECTOR]: UserAccountService missing from OpenSim.ini"); | ||
71 | throw new Exception("User account connector init error"); | ||
72 | } | ||
73 | |||
74 | string serviceURI = assetConfig.GetString("UserAccountServerURI", | ||
75 | String.Empty); | ||
76 | |||
77 | if (serviceURI == String.Empty) | ||
78 | { | ||
79 | m_log.Error("[ACCOUNT CONNECTOR]: No Server URI named in section UserAccountService"); | ||
80 | throw new Exception("User account connector init error"); | ||
81 | } | ||
82 | m_ServerURI = serviceURI; | ||
83 | } | ||
84 | |||
85 | public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | ||
86 | { | ||
87 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
88 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
89 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
90 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
91 | sendData["METHOD"] = "getaccount"; | ||
92 | |||
93 | sendData["ScopeID"] = scopeID; | ||
94 | sendData["FirstName"] = firstName.ToString(); | ||
95 | sendData["LastName"] = lastName.ToString(); | ||
96 | |||
97 | return SendAndGetReply(sendData); | ||
98 | } | ||
99 | |||
100 | public UserAccount GetUserAccount(UUID scopeID, string email) | ||
101 | { | ||
102 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
103 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
104 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
105 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
106 | sendData["METHOD"] = "getaccount"; | ||
107 | |||
108 | sendData["ScopeID"] = scopeID; | ||
109 | sendData["Email"] = email; | ||
110 | |||
111 | return SendAndGetReply(sendData); | ||
112 | } | ||
113 | |||
114 | public UserAccount GetUserAccount(UUID scopeID, UUID userID) | ||
115 | { | ||
116 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
117 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
118 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
119 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
120 | sendData["METHOD"] = "getaccount"; | ||
121 | |||
122 | sendData["ScopeID"] = scopeID; | ||
123 | sendData["UserID"] = userID.ToString(); | ||
124 | |||
125 | return SendAndGetReply(sendData); | ||
126 | } | ||
127 | |||
128 | public List<UserAccount> GetUserAccounts(UUID scopeID, string query) | ||
129 | { | ||
130 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
131 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
132 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
133 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
134 | sendData["METHOD"] = "getagents"; | ||
135 | |||
136 | sendData["ScopeID"] = scopeID.ToString(); | ||
137 | sendData["query"] = query; | ||
138 | |||
139 | string reply = string.Empty; | ||
140 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
141 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
142 | try | ||
143 | { | ||
144 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
145 | m_ServerURI + "/accounts", | ||
146 | reqString); | ||
147 | if (reply == null || (reply != null && reply == string.Empty)) | ||
148 | { | ||
149 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply"); | ||
150 | return null; | ||
151 | } | ||
152 | } | ||
153 | catch (Exception e) | ||
154 | { | ||
155 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting accounts server: {0}", e.Message); | ||
156 | } | ||
157 | |||
158 | List<UserAccount> accounts = new List<UserAccount>(); | ||
159 | |||
160 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
161 | |||
162 | if (replyData != null) | ||
163 | { | ||
164 | if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null") | ||
165 | { | ||
166 | return accounts; | ||
167 | } | ||
168 | |||
169 | Dictionary<string, object>.ValueCollection accountList = replyData.Values; | ||
170 | //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count); | ||
171 | foreach (object acc in accountList) | ||
172 | { | ||
173 | if (acc is Dictionary<string, object>) | ||
174 | { | ||
175 | UserAccount pinfo = new UserAccount((Dictionary<string, object>)acc); | ||
176 | accounts.Add(pinfo); | ||
177 | } | ||
178 | else | ||
179 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received invalid response type {0}", | ||
180 | acc.GetType()); | ||
181 | } | ||
182 | } | ||
183 | else | ||
184 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccounts received null response"); | ||
185 | |||
186 | return accounts; | ||
187 | } | ||
188 | |||
189 | public bool SetUserAccount(UserAccount data) | ||
190 | { | ||
191 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
192 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
193 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
194 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
195 | sendData["METHOD"] = "setaccount"; | ||
196 | |||
197 | sendData["account"] = data.ToKeyValuePairs(); | ||
198 | |||
199 | return SendAndGetBoolReply(sendData); | ||
200 | } | ||
201 | |||
202 | public bool CreateUserAccount(UserAccount data) | ||
203 | { | ||
204 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
205 | //sendData["SCOPEID"] = scopeID.ToString(); | ||
206 | sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); | ||
207 | sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); | ||
208 | sendData["METHOD"] = "createaccount"; | ||
209 | |||
210 | sendData["account"] = data.ToKeyValuePairs(); | ||
211 | |||
212 | return SendAndGetBoolReply(sendData); | ||
213 | } | ||
214 | |||
215 | private UserAccount SendAndGetReply(Dictionary<string, object> sendData) | ||
216 | { | ||
217 | string reply = string.Empty; | ||
218 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
219 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
220 | try | ||
221 | { | ||
222 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
223 | m_ServerURI + "/accounts", | ||
224 | reqString); | ||
225 | if (reply == null || (reply != null && reply == string.Empty)) | ||
226 | { | ||
227 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); | ||
228 | return null; | ||
229 | } | ||
230 | } | ||
231 | catch (Exception e) | ||
232 | { | ||
233 | m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user account server: {0}", e.Message); | ||
234 | } | ||
235 | |||
236 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
237 | UserAccount account = null; | ||
238 | |||
239 | if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) | ||
240 | { | ||
241 | if (replyData["result"] is Dictionary<string, object>) | ||
242 | { | ||
243 | account = new UserAccount((Dictionary<string, object>)replyData["result"]); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | return account; | ||
248 | |||
249 | } | ||
250 | |||
251 | private bool SendAndGetBoolReply(Dictionary<string, object> sendData) | ||
252 | { | ||
253 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
254 | // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); | ||
255 | try | ||
256 | { | ||
257 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
258 | m_ServerURI + "/accounts", | ||
259 | reqString); | ||
260 | if (reply != string.Empty) | ||
261 | { | ||
262 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
263 | |||
264 | if (replyData.ContainsKey("result")) | ||
265 | { | ||
266 | if (replyData["result"].ToString().ToLower() == "success") | ||
267 | return true; | ||
268 | else | ||
269 | return false; | ||
270 | } | ||
271 | else | ||
272 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field"); | ||
273 | |||
274 | } | ||
275 | else | ||
276 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply"); | ||
277 | } | ||
278 | catch (Exception e) | ||
279 | { | ||
280 | m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message); | ||
281 | } | ||
282 | |||
283 | return false; | ||
284 | } | ||
285 | |||
286 | } | ||
287 | } | ||