aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs43
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs51
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs15
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs72
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs47
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs6
6 files changed, 201 insertions, 33 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 4be3804..cf6d2f7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -297,14 +297,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
297 return m_LocalGridInventoryService.CreateUserInventory(userID); 297 return m_LocalGridInventoryService.CreateUserInventory(userID);
298 } 298 }
299 299
300 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) 300 public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
301 { 301 {
302 return m_LocalGridInventoryService.GetInventorySkeleton(userId); 302 string invURL = GetInventoryServiceURL(userID);
303
304 if (invURL == null) // not there, forward to local inventory connector to resolve
305 return m_LocalGridInventoryService.GetInventorySkeleton(userID);
306
307 IInventoryService connector = GetConnector(invURL);
308
309 return connector.GetInventorySkeleton(userID);
303 } 310 }
304 311
305 public InventoryCollection GetUserInventory(UUID userID) 312 public InventoryCollection GetUserInventory(UUID userID)
306 { 313 {
307 return null; 314 string invURL = GetInventoryServiceURL(userID);
315 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL);
316
317 if (invURL == null) // not there, forward to local inventory connector to resolve
318 return m_LocalGridInventoryService.GetUserInventory(userID);
319
320 InventoryCollection c = m_Cache.GetUserInventory(userID);
321 if (c != null)
322 return c;
323
324 IInventoryService connector = GetConnector(invURL);
325 c = connector.GetUserInventory(userID);
326
327 m_Cache.Cache(userID, c);
328 return c;
308 } 329 }
309 330
310 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) 331 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
@@ -362,8 +383,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
362 if (invURL == null) // not there, forward to local inventory connector to resolve 383 if (invURL == null) // not there, forward to local inventory connector to resolve
363 return m_LocalGridInventoryService.GetFolderContent(userID, folderID); 384 return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
364 385
365 IInventoryService connector = GetConnector(invURL); 386 InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
387 if (c != null)
388 {
389 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent found content in cache " + folderID);
390 return c;
391 }
366 392
393 IInventoryService connector = GetConnector(invURL);
367 return connector.GetFolderContent(userID, folderID); 394 return connector.GetFolderContent(userID, folderID);
368 395
369 } 396 }
@@ -377,8 +404,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
377 if (invURL == null) // not there, forward to local inventory connector to resolve 404 if (invURL == null) // not there, forward to local inventory connector to resolve
378 return m_LocalGridInventoryService.GetFolderItems(userID, folderID); 405 return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
379 406
380 IInventoryService connector = GetConnector(invURL); 407 List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
408 if (items != null)
409 {
410 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems found items in cache " + folderID);
411 return items;
412 }
381 413
414 IInventoryService connector = GetConnector(invURL);
382 return connector.GetFolderItems(userID, folderID); 415 return connector.GetFolderItems(userID, folderID);
383 416
384 } 417 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index 0fe778d..1e434b9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -12,6 +12,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
12 12
13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); 13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); 14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
15 private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>();
15 16
16 public void Cache(UUID userID, InventoryFolderBase root) 17 public void Cache(UUID userID, InventoryFolderBase root)
17 { 18 {
@@ -55,5 +56,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
55 56
56 return null; 57 return null;
57 } 58 }
59
60 public void Cache(UUID userID, InventoryCollection inv)
61 {
62 lock (m_Inventories)
63 m_Inventories.AddOrUpdate(userID, inv, 120);
64 }
65
66 public InventoryCollection GetUserInventory(UUID userID)
67 {
68 InventoryCollection inv = null;
69 if (m_Inventories.TryGetValue(userID, out inv))
70 return inv;
71 return null;
72 }
73
74 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
75 {
76 InventoryCollection inv = null;
77 InventoryCollection c;
78 if (m_Inventories.TryGetValue(userID, out inv))
79 {
80 c = new InventoryCollection();
81 c.UserID = userID;
82
83 c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
84 {
85 return f.ParentID == folderID;
86 });
87 c.Items = inv.Items.FindAll(delegate(InventoryItemBase i)
88 {
89 return i.Folder == folderID;
90 });
91 return c;
92 }
93 return null;
94 }
95
96 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
97 {
98 InventoryCollection inv = null;
99 if (m_Inventories.TryGetValue(userID, out inv))
100 {
101 List<InventoryItemBase> items = inv.Items.FindAll(delegate(InventoryItemBase i)
102 {
103 return i.Folder == folderID;
104 });
105 return items;
106 }
107 return null;
108 }
58 } 109 }
59} 110}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 77573c3..990dffb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
172 172
173 public InventoryCollection GetUserInventory(UUID userID) 173 public InventoryCollection GetUserInventory(UUID userID)
174 { 174 {
175 return null; 175 return m_RemoteConnector.GetUserInventory(userID);
176 } 176 }
177 177
178 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) 178 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
@@ -193,16 +193,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
193 { 193 {
194 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); 194 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
195 195
196 if (UserManager != null) 196 if (invCol != null && UserManager != null)
197 { 197 {
198 // Protect ourselves against the caller subsequently modifying the items list 198 // Protect ourselves against the caller subsequently modifying the items list
199 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); 199 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
200 200
201 Util.FireAndForget(delegate 201 if (items != null && items.Count > 0)
202 { 202 Util.FireAndForget(delegate
203 foreach (InventoryItemBase item in items) 203 {
204 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); 204 foreach (InventoryItemBase item in items)
205 }); 205 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
206 });
206 } 207 }
207 208
208 return invCol; 209 return invCol;
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 040c840..cb9b65d 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -114,6 +114,8 @@ namespace OpenSim.Server.Handlers.Asset
114 return HandleCreateUserInventory(request); 114 return HandleCreateUserInventory(request);
115 case "GETINVENTORYSKELETON": 115 case "GETINVENTORYSKELETON":
116 return HandleGetInventorySkeleton(request); 116 return HandleGetInventorySkeleton(request);
117 case "GETUSERINVENTORY":
118 return HandleGetUserInventory(request);
117 case "GETROOTFOLDER": 119 case "GETROOTFOLDER":
118 return HandleGetRootFolder(request); 120 return HandleGetRootFolder(request);
119 case "GETFOLDERFORTYPE": 121 case "GETFOLDERFORTYPE":
@@ -153,7 +155,7 @@ namespace OpenSim.Server.Handlers.Asset
153 } 155 }
154 catch (Exception e) 156 catch (Exception e)
155 { 157 {
156 m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e); 158 m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace);
157 } 159 }
158 160
159 return FailureResult(); 161 return FailureResult();
@@ -248,6 +250,45 @@ namespace OpenSim.Server.Handlers.Asset
248 return encoding.GetBytes(xmlString); 250 return encoding.GetBytes(xmlString);
249 } 251 }
250 252
253 byte[] HandleGetUserInventory(Dictionary<string, object> request)
254 {
255 Dictionary<string, object> result = new Dictionary<string, object>();
256 UUID principal = UUID.Zero;
257 UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
258
259 InventoryCollection icoll = m_InventoryService.GetUserInventory(principal);
260 if (icoll != null)
261 {
262 Dictionary<string, object> folders = new Dictionary<string, object>();
263 int i = 0;
264 if (icoll.Folders != null)
265 {
266 foreach (InventoryFolderBase f in icoll.Folders)
267 {
268 folders["folder_" + i.ToString()] = EncodeFolder(f);
269 i++;
270 }
271 result["FOLDERS"] = folders;
272 }
273 if (icoll.Items != null)
274 {
275 i = 0;
276 Dictionary<string, object> items = new Dictionary<string, object>();
277 foreach (InventoryItemBase it in icoll.Items)
278 {
279 items["item_" + i.ToString()] = EncodeItem(it);
280 i++;
281 }
282 result["ITEMS"] = items;
283 }
284 }
285
286 string xmlString = ServerUtils.BuildXmlResponse(result);
287 //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
288 UTF8Encoding encoding = new UTF8Encoding();
289 return encoding.GetBytes(xmlString);
290 }
291
251 byte[] HandleGetRootFolder(Dictionary<string,object> request) 292 byte[] HandleGetRootFolder(Dictionary<string,object> request)
252 { 293 {
253 Dictionary<string,object> result = new Dictionary<string,object>(); 294 Dictionary<string,object> result = new Dictionary<string,object>();
@@ -293,22 +334,27 @@ namespace OpenSim.Server.Handlers.Asset
293 if (icoll != null) 334 if (icoll != null)
294 { 335 {
295 Dictionary<string, object> folders = new Dictionary<string, object>(); 336 Dictionary<string, object> folders = new Dictionary<string, object>();
296 int i = 0; 337 int i = 0;
297 foreach (InventoryFolderBase f in icoll.Folders) 338 if (icoll.Folders != null)
298 { 339 {
299 folders["folder_" + i.ToString()] = EncodeFolder(f); 340 foreach (InventoryFolderBase f in icoll.Folders)
300 i++; 341 {
342 folders["folder_" + i.ToString()] = EncodeFolder(f);
343 i++;
344 }
345 result["FOLDERS"] = folders;
301 } 346 }
302 result["FOLDERS"] = folders; 347 if (icoll.Items != null)
303
304 i = 0;
305 Dictionary<string, object> items = new Dictionary<string, object>();
306 foreach (InventoryItemBase it in icoll.Items)
307 { 348 {
308 items["item_" + i.ToString()] = EncodeItem(it); 349 i = 0;
309 i++; 350 Dictionary<string, object> items = new Dictionary<string, object>();
351 foreach (InventoryItemBase it in icoll.Items)
352 {
353 items["item_" + i.ToString()] = EncodeItem(it);
354 i++;
355 }
356 result["ITEMS"] = items;
310 } 357 }
311 result["ITEMS"] = items;
312 } 358 }
313 359
314 string xmlString = ServerUtils.BuildXmlResponse(result); 360 string xmlString = ServerUtils.BuildXmlResponse(result);
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
index 39e983b..9d96703 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -111,19 +111,21 @@ namespace OpenSim.Services.Connectors
111 if (ret.Count == 0) 111 if (ret.Count == 0)
112 return null; 112 return null;
113 113
114 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 114 Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"];
115
116 List<InventoryFolderBase> fldrs = new List<InventoryFolderBase>();
115 117
116 try 118 try
117 { 119 {
118 foreach (Object o in ret.Values) 120 foreach (Object o in folders.Values)
119 folders.Add(BuildFolder((Dictionary<string, object>)o)); 121 fldrs.Add(BuildFolder((Dictionary<string, object>)o));
120 } 122 }
121 catch (Exception e) 123 catch (Exception e)
122 { 124 {
123 m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message); 125 m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message);
124 } 126 }
125 127
126 return folders; 128 return fldrs;
127 } 129 }
128 130
129 public InventoryFolderBase GetRootFolder(UUID principalID) 131 public InventoryFolderBase GetRootFolder(UUID principalID)
@@ -492,12 +494,41 @@ namespace OpenSim.Services.Connectors
492 return int.Parse(ret["RESULT"].ToString()); 494 return int.Parse(ret["RESULT"].ToString());
493 } 495 }
494 496
495
496 // These are either obsolete or unused
497 //
498 public InventoryCollection GetUserInventory(UUID principalID) 497 public InventoryCollection GetUserInventory(UUID principalID)
499 { 498 {
500 return null; 499 InventoryCollection inventory = new InventoryCollection();
500 inventory.Folders = new List<InventoryFolderBase>();
501 inventory.Items = new List<InventoryItemBase>();
502 inventory.UserID = principalID;
503
504 try
505 {
506 Dictionary<string, object> ret = MakeRequest("GETUSERINVENTORY",
507 new Dictionary<string, object> {
508 { "PRINCIPAL", principalID.ToString() }
509 });
510
511 if (ret == null)
512 return null;
513 if (ret.Count == 0)
514 return null;
515
516 Dictionary<string, object> folders =
517 (Dictionary<string, object>)ret["FOLDERS"];
518 Dictionary<string, object> items =
519 (Dictionary<string, object>)ret["ITEMS"];
520
521 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
522 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
523 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
524 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
525 }
526 catch (Exception e)
527 {
528 m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception in GetUserInventory: {0}", e.Message);
529 }
530
531 return inventory;
501 } 532 }
502 533
503 public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback) 534 public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index b29d803..2e9bd40 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -105,6 +105,12 @@ namespace OpenSim.Services.HypergridService
105 return new List<InventoryFolderBase>(); 105 return new List<InventoryFolderBase>();
106 } 106 }
107 107
108 public override InventoryCollection GetUserInventory(UUID userID)
109 {
110 // NOGO for this inventory service
111 return null;
112 }
113
108 public override InventoryFolderBase GetRootFolder(UUID principalID) 114 public override InventoryFolderBase GetRootFolder(UUID principalID)
109 { 115 {
110 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 116 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);