aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-06-13 00:31:32 +0100
committerJustin Clark-Casey (justincc)2013-06-13 00:31:32 +0100
commit7759b05dcb39298c0b47da827eda7250db5c2c83 (patch)
treecbd17c40625a77c0c9f4d49970de3ade8dda6c99 /OpenSim
parentAfter calls to GetSuitcaseXFolder() in HGSuitcaseInventoryService, consistent... (diff)
downloadopensim-SC_OLD-7759b05dcb39298c0b47da827eda7250db5c2c83.zip
opensim-SC_OLD-7759b05dcb39298c0b47da827eda7250db5c2c83.tar.gz
opensim-SC_OLD-7759b05dcb39298c0b47da827eda7250db5c2c83.tar.bz2
opensim-SC_OLD-7759b05dcb39298c0b47da827eda7250db5c2c83.tar.xz
Make XInventoryServicesConnector properly handle a RESULT = false return for methods where this contains failure rather than throwing an exception.
Result = False is generated for methods such as GetFolderForType() when the other end wants to signal a failure of the operation in methods such as GetFolderForType()
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs124
1 files changed, 56 insertions, 68 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 =