diff options
author | Diva Canto | 2013-06-12 17:48:48 -0700 |
---|---|---|
committer | Diva Canto | 2013-06-12 17:48:48 -0700 |
commit | b27121708490f0a6107a3e717e0cbe7792dfaaaf (patch) | |
tree | 0d1c3d204dc08b08c586d2a9567fbcf834944c51 /OpenSim/Services | |
parent | DataSnapshot: changed those annoying messages to Debug instead of Info. (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-b27121708490f0a6107a3e717e0cbe7792dfaaaf.zip opensim-SC_OLD-b27121708490f0a6107a3e717e0cbe7792dfaaaf.tar.gz opensim-SC_OLD-b27121708490f0a6107a3e717e0cbe7792dfaaaf.tar.bz2 opensim-SC_OLD-b27121708490f0a6107a3e717e0cbe7792dfaaaf.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | 124 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | 24 |
2 files changed, 79 insertions, 69 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 44f5e01..36d4ae2 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | |||
@@ -84,6 +84,30 @@ namespace OpenSim.Services.Connectors | |||
84 | m_ServerURI = serviceURI; | 84 | m_ServerURI = serviceURI; |
85 | } | 85 | } |
86 | 86 | ||
87 | private bool CheckReturn(Dictionary<string, object> ret) | ||
88 | { | ||
89 | if (ret == null) | ||
90 | return false; | ||
91 | |||
92 | if (ret.Count == 0) | ||
93 | return false; | ||
94 | |||
95 | if (ret.ContainsKey("RESULT")) | ||
96 | { | ||
97 | if (ret["RESULT"] is string) | ||
98 | { | ||
99 | bool result; | ||
100 | |||
101 | if (bool.TryParse((string)ret["RESULT"], out result)) | ||
102 | return result; | ||
103 | |||
104 | return false; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return true; | ||
109 | } | ||
110 | |||
87 | public bool CreateUserInventory(UUID principalID) | 111 | public bool CreateUserInventory(UUID principalID) |
88 | { | 112 | { |
89 | Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY", | 113 | Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY", |
@@ -91,12 +115,7 @@ namespace OpenSim.Services.Connectors | |||
91 | { "PRINCIPAL", principalID.ToString() } | 115 | { "PRINCIPAL", principalID.ToString() } |
92 | }); | 116 | }); |
93 | 117 | ||
94 | if (ret == null) | 118 | return CheckReturn(ret); |
95 | return false; | ||
96 | if (ret.Count == 0) | ||
97 | return false; | ||
98 | |||
99 | return bool.Parse(ret["RESULT"].ToString()); | ||
100 | } | 119 | } |
101 | 120 | ||
102 | public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) | 121 | public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) |
@@ -106,9 +125,7 @@ namespace OpenSim.Services.Connectors | |||
106 | { "PRINCIPAL", principalID.ToString() } | 125 | { "PRINCIPAL", principalID.ToString() } |
107 | }); | 126 | }); |
108 | 127 | ||
109 | if (ret == null) | 128 | if (!CheckReturn(ret)) |
110 | return null; | ||
111 | if (ret.Count == 0) | ||
112 | return null; | 129 | return null; |
113 | 130 | ||
114 | Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; | 131 | Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; |
@@ -135,9 +152,7 @@ namespace OpenSim.Services.Connectors | |||
135 | { "PRINCIPAL", principalID.ToString() } | 152 | { "PRINCIPAL", principalID.ToString() } |
136 | }); | 153 | }); |
137 | 154 | ||
138 | if (ret == null) | 155 | if (!CheckReturn(ret)) |
139 | return null; | ||
140 | if (ret.Count == 0) | ||
141 | return null; | 156 | return null; |
142 | 157 | ||
143 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 158 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -151,9 +166,7 @@ namespace OpenSim.Services.Connectors | |||
151 | { "TYPE", ((int)type).ToString() } | 166 | { "TYPE", ((int)type).ToString() } |
152 | }); | 167 | }); |
153 | 168 | ||
154 | if (ret == null) | 169 | if (!CheckReturn(ret)) |
155 | return null; | ||
156 | if (ret.Count == 0) | ||
157 | return null; | 170 | return null; |
158 | 171 | ||
159 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 172 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -174,9 +187,7 @@ namespace OpenSim.Services.Connectors | |||
174 | { "FOLDER", folderID.ToString() } | 187 | { "FOLDER", folderID.ToString() } |
175 | }); | 188 | }); |
176 | 189 | ||
177 | if (ret == null) | 190 | if (!CheckReturn(ret)) |
178 | return null; | ||
179 | if (ret.Count == 0) | ||
180 | return null; | 191 | return null; |
181 | 192 | ||
182 | Dictionary<string,object> folders = | 193 | Dictionary<string,object> folders = |
@@ -205,9 +216,7 @@ namespace OpenSim.Services.Connectors | |||
205 | { "FOLDER", folderID.ToString() } | 216 | { "FOLDER", folderID.ToString() } |
206 | }); | 217 | }); |
207 | 218 | ||
208 | if (ret == null) | 219 | if (!CheckReturn(ret)) |
209 | return null; | ||
210 | if (ret.Count == 0) | ||
211 | return null; | 220 | return null; |
212 | 221 | ||
213 | Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; | 222 | Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; |
@@ -230,10 +239,7 @@ namespace OpenSim.Services.Connectors | |||
230 | { "ID", folder.ID.ToString() } | 239 | { "ID", folder.ID.ToString() } |
231 | }); | 240 | }); |
232 | 241 | ||
233 | if (ret == null) | 242 | return CheckReturn(ret); |
234 | return false; | ||
235 | |||
236 | return bool.Parse(ret["RESULT"].ToString()); | ||
237 | } | 243 | } |
238 | 244 | ||
239 | public bool UpdateFolder(InventoryFolderBase folder) | 245 | public bool UpdateFolder(InventoryFolderBase folder) |
@@ -248,10 +254,7 @@ namespace OpenSim.Services.Connectors | |||
248 | { "ID", folder.ID.ToString() } | 254 | { "ID", folder.ID.ToString() } |
249 | }); | 255 | }); |
250 | 256 | ||
251 | if (ret == null) | 257 | return CheckReturn(ret); |
252 | return false; | ||
253 | |||
254 | return bool.Parse(ret["RESULT"].ToString()); | ||
255 | } | 258 | } |
256 | 259 | ||
257 | public bool MoveFolder(InventoryFolderBase folder) | 260 | public bool MoveFolder(InventoryFolderBase folder) |
@@ -263,10 +266,7 @@ namespace OpenSim.Services.Connectors | |||
263 | { "PRINCIPAL", folder.Owner.ToString() } | 266 | { "PRINCIPAL", folder.Owner.ToString() } |
264 | }); | 267 | }); |
265 | 268 | ||
266 | if (ret == null) | 269 | return CheckReturn(ret); |
267 | return false; | ||
268 | |||
269 | return bool.Parse(ret["RESULT"].ToString()); | ||
270 | } | 270 | } |
271 | 271 | ||
272 | public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) | 272 | public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) |
@@ -282,10 +282,7 @@ namespace OpenSim.Services.Connectors | |||
282 | { "FOLDERS", slist } | 282 | { "FOLDERS", slist } |
283 | }); | 283 | }); |
284 | 284 | ||
285 | if (ret == null) | 285 | return CheckReturn(ret); |
286 | return false; | ||
287 | |||
288 | return bool.Parse(ret["RESULT"].ToString()); | ||
289 | } | 286 | } |
290 | 287 | ||
291 | public bool PurgeFolder(InventoryFolderBase folder) | 288 | public bool PurgeFolder(InventoryFolderBase folder) |
@@ -295,10 +292,7 @@ namespace OpenSim.Services.Connectors | |||
295 | { "ID", folder.ID.ToString() } | 292 | { "ID", folder.ID.ToString() } |
296 | }); | 293 | }); |
297 | 294 | ||
298 | if (ret == null) | 295 | return CheckReturn(ret); |
299 | return false; | ||
300 | |||
301 | return bool.Parse(ret["RESULT"].ToString()); | ||
302 | } | 296 | } |
303 | 297 | ||
304 | public bool AddItem(InventoryItemBase item) | 298 | public bool AddItem(InventoryItemBase item) |
@@ -330,10 +324,7 @@ namespace OpenSim.Services.Connectors | |||
330 | { "CreationDate", item.CreationDate.ToString() } | 324 | { "CreationDate", item.CreationDate.ToString() } |
331 | }); | 325 | }); |
332 | 326 | ||
333 | if (ret == null) | 327 | return CheckReturn(ret); |
334 | return false; | ||
335 | |||
336 | return bool.Parse(ret["RESULT"].ToString()); | ||
337 | } | 328 | } |
338 | 329 | ||
339 | public bool UpdateItem(InventoryItemBase item) | 330 | public bool UpdateItem(InventoryItemBase item) |
@@ -365,10 +356,7 @@ namespace OpenSim.Services.Connectors | |||
365 | { "CreationDate", item.CreationDate.ToString() } | 356 | { "CreationDate", item.CreationDate.ToString() } |
366 | }); | 357 | }); |
367 | 358 | ||
368 | if (ret == null) | 359 | return CheckReturn(ret); |
369 | return false; | ||
370 | |||
371 | return bool.Parse(ret["RESULT"].ToString()); | ||
372 | } | 360 | } |
373 | 361 | ||
374 | public bool MoveItems(UUID principalID, List<InventoryItemBase> items) | 362 | public bool MoveItems(UUID principalID, List<InventoryItemBase> items) |
@@ -389,10 +377,7 @@ namespace OpenSim.Services.Connectors | |||
389 | { "DESTLIST", destlist } | 377 | { "DESTLIST", destlist } |
390 | }); | 378 | }); |
391 | 379 | ||
392 | if (ret == null) | 380 | return CheckReturn(ret); |
393 | return false; | ||
394 | |||
395 | return bool.Parse(ret["RESULT"].ToString()); | ||
396 | } | 381 | } |
397 | 382 | ||
398 | public bool DeleteItems(UUID principalID, List<UUID> itemIDs) | 383 | public bool DeleteItems(UUID principalID, List<UUID> itemIDs) |
@@ -408,10 +393,7 @@ namespace OpenSim.Services.Connectors | |||
408 | { "ITEMS", slist } | 393 | { "ITEMS", slist } |
409 | }); | 394 | }); |
410 | 395 | ||
411 | if (ret == null) | 396 | return CheckReturn(ret); |
412 | return false; | ||
413 | |||
414 | return bool.Parse(ret["RESULT"].ToString()); | ||
415 | } | 397 | } |
416 | 398 | ||
417 | public InventoryItemBase GetItem(InventoryItemBase item) | 399 | public InventoryItemBase GetItem(InventoryItemBase item) |
@@ -423,9 +405,7 @@ namespace OpenSim.Services.Connectors | |||
423 | { "ID", item.ID.ToString() } | 405 | { "ID", item.ID.ToString() } |
424 | }); | 406 | }); |
425 | 407 | ||
426 | if (ret == null) | 408 | if (!CheckReturn(ret)) |
427 | return null; | ||
428 | if (ret.Count == 0) | ||
429 | return null; | 409 | return null; |
430 | 410 | ||
431 | return BuildItem((Dictionary<string, object>)ret["item"]); | 411 | return BuildItem((Dictionary<string, object>)ret["item"]); |
@@ -447,9 +427,7 @@ namespace OpenSim.Services.Connectors | |||
447 | { "ID", folder.ID.ToString() } | 427 | { "ID", folder.ID.ToString() } |
448 | }); | 428 | }); |
449 | 429 | ||
450 | if (ret == null) | 430 | if (!CheckReturn(ret)) |
451 | return null; | ||
452 | if (ret.Count == 0) | ||
453 | return null; | 431 | return null; |
454 | 432 | ||
455 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 433 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -469,7 +447,7 @@ namespace OpenSim.Services.Connectors | |||
469 | { "PRINCIPAL", principalID.ToString() } | 447 | { "PRINCIPAL", principalID.ToString() } |
470 | }); | 448 | }); |
471 | 449 | ||
472 | if (ret == null) | 450 | if (!CheckReturn(ret)) |
473 | return null; | 451 | return null; |
474 | 452 | ||
475 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 453 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
@@ -488,10 +466,22 @@ namespace OpenSim.Services.Connectors | |||
488 | { "ASSET", assetID.ToString() } | 466 | { "ASSET", assetID.ToString() } |
489 | }); | 467 | }); |
490 | 468 | ||
469 | // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int | ||
491 | if (ret == null) | 470 | if (ret == null) |
492 | return 0; | 471 | return 0; |
493 | 472 | ||
494 | return int.Parse(ret["RESULT"].ToString()); | 473 | if (ret.ContainsKey("RESULT")) |
474 | { | ||
475 | if (ret["RESULT"] is string) | ||
476 | { | ||
477 | int intResult; | ||
478 | |||
479 | if (int.TryParse ((string)ret["RESULT"], out intResult)) | ||
480 | return intResult; | ||
481 | } | ||
482 | } | ||
483 | |||
484 | return 0; | ||
495 | } | 485 | } |
496 | 486 | ||
497 | public InventoryCollection GetUserInventory(UUID principalID) | 487 | public InventoryCollection GetUserInventory(UUID principalID) |
@@ -508,9 +498,7 @@ namespace OpenSim.Services.Connectors | |||
508 | { "PRINCIPAL", principalID.ToString() } | 498 | { "PRINCIPAL", principalID.ToString() } |
509 | }); | 499 | }); |
510 | 500 | ||
511 | if (ret == null) | 501 | if (!CheckReturn(ret)) |
512 | return null; | ||
513 | if (ret.Count == 0) | ||
514 | return null; | 502 | return null; |
515 | 503 | ||
516 | Dictionary<string, object> folders = | 504 | Dictionary<string, object> folders = |
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index eecf757..410916f 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | |||
@@ -115,6 +115,12 @@ namespace OpenSim.Services.HypergridService | |||
115 | { | 115 | { |
116 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 116 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
117 | 117 | ||
118 | if (suitcase == null) | ||
119 | { | ||
120 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID); | ||
121 | return null; | ||
122 | } | ||
123 | |||
118 | List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); | 124 | List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); |
119 | if (tree == null || (tree != null && tree.Count == 0)) | 125 | if (tree == null || (tree != null && tree.Count == 0)) |
120 | return null; | 126 | return null; |
@@ -134,6 +140,7 @@ namespace OpenSim.Services.HypergridService | |||
134 | public override InventoryCollection GetUserInventory(UUID userID) | 140 | public override InventoryCollection GetUserInventory(UUID userID) |
135 | { | 141 | { |
136 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); | 142 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); |
143 | |||
137 | InventoryCollection userInventory = new InventoryCollection(); | 144 | InventoryCollection userInventory = new InventoryCollection(); |
138 | userInventory.UserID = userID; | 145 | userInventory.UserID = userID; |
139 | userInventory.Folders = new List<InventoryFolderBase>(); | 146 | userInventory.Folders = new List<InventoryFolderBase>(); |
@@ -141,6 +148,12 @@ namespace OpenSim.Services.HypergridService | |||
141 | 148 | ||
142 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); | 149 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); |
143 | 150 | ||
151 | if (suitcase == null) | ||
152 | { | ||
153 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for user inventory", userID); | ||
154 | return null; | ||
155 | } | ||
156 | |||
144 | List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); | 157 | List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); |
145 | if (tree == null || (tree != null && tree.Count == 0)) | 158 | if (tree == null || (tree != null && tree.Count == 0)) |
146 | { | 159 | { |
@@ -182,7 +195,8 @@ namespace OpenSim.Services.HypergridService | |||
182 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); | 195 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); |
183 | 196 | ||
184 | // Let's find out the local root folder | 197 | // Let's find out the local root folder |
185 | XInventoryFolder root = GetRootXFolder(principalID); ; | 198 | XInventoryFolder root = GetRootXFolder(principalID); |
199 | |||
186 | if (root == null) | 200 | if (root == null) |
187 | { | 201 | { |
188 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); | 202 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); |
@@ -255,6 +269,13 @@ namespace OpenSim.Services.HypergridService | |||
255 | { | 269 | { |
256 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); | 270 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); |
257 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 271 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
272 | |||
273 | if (suitcase == null) | ||
274 | { | ||
275 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type); | ||
276 | return null; | ||
277 | } | ||
278 | |||
258 | XInventoryFolder[] folders = m_Database.GetFolders( | 279 | XInventoryFolder[] folders = m_Database.GetFolders( |
259 | new string[] { "agentID", "type", "parentFolderID" }, | 280 | new string[] { "agentID", "type", "parentFolderID" }, |
260 | new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); | 281 | new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); |
@@ -546,6 +567,7 @@ namespace OpenSim.Services.HypergridService | |||
546 | private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) | 567 | private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) |
547 | { | 568 | { |
548 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 569 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
570 | |||
549 | if (suitcase == null) | 571 | if (suitcase == null) |
550 | { | 572 | { |
551 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); | 573 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); |