aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs2
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs129
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs80
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs108
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs47
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs41
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs42
-rw-r--r--OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs17
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs44
-rw-r--r--OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs12
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs30
-rw-r--r--OpenSim/Services/InventoryService/InventoryService.cs67
13 files changed, 593 insertions, 28 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index a1cd116..aec06be 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -265,7 +265,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
265 265
266 if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid)) 266 if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
267 { 267 {
268 rdata.root = Rest.InventoryServices.RequestRootFolder(rdata.uuid); 268 rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
269 269
270 Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}", 270 Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
271 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 271 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
index 9e181f3..b1b7809 100644
--- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
@@ -447,4 +447,133 @@ namespace OpenSim.Framework.Communications.Tests
447 #endregion 447 #endregion
448 } 448 }
449 } 449 }
450
451 class TestInventoryService : IInventoryService
452 {
453 public TestInventoryService()
454 {
455 }
456
457 /// <summary>
458 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
459 /// </summary>
460 /// <param name="userId"></param>
461 /// <returns></returns>
462 public bool CreateUserInventory(UUID userId)
463 {
464 return false;
465 }
466
467 /// <summary>
468 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
469 /// </summary>
470 /// <param name="userId"></param>
471 /// <returns></returns>
472 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
473 {
474 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
475 InventoryFolderBase folder = new InventoryFolderBase();
476 folder.ID = UUID.Random();
477 folder.Owner = userId;
478 folders.Add(folder);
479 return folders;
480 }
481
482 /// <summary>
483 /// Returns a list of all the active gestures in a user's inventory.
484 /// </summary>
485 /// <param name="userId">
486 /// The <see cref="UUID"/> of the user
487 /// </param>
488 /// <returns>
489 /// A flat list of the gesture items.
490 /// </returns>
491 public List<InventoryItemBase> GetActiveGestures(UUID userId)
492 {
493 return null;
494 }
495
496 public InventoryCollection GetUserInventory(UUID userID)
497 {
498 return null;
499 }
500
501 public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
502 {
503 }
504
505 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
506 {
507 return null;
508 }
509
510 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
511 {
512 return null;
513 }
514
515 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
516 {
517 return null;
518 }
519
520 public bool AddFolder(InventoryFolderBase folder)
521 {
522 return false;
523 }
524
525 public bool UpdateFolder(InventoryFolderBase folder)
526 {
527 return false;
528 }
529
530 public bool MoveFolder(InventoryFolderBase folder)
531 {
532 return false;
533 }
534
535 public bool PurgeFolder(InventoryFolderBase folder)
536 {
537 return false;
538 }
539
540 public bool AddItem(InventoryItemBase item)
541 {
542 return false;
543 }
544
545 public bool UpdateItem(InventoryItemBase item)
546 {
547 return false;
548 }
549
550 public bool DeleteItem(InventoryItemBase item)
551 {
552 return false;
553 }
554
555 public InventoryItemBase QueryItem(InventoryItemBase item)
556 {
557 return null;
558 }
559
560 public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
561 {
562 return null;
563 }
564
565 public bool HasInventoryForUser(UUID userID)
566 {
567 return false;
568 }
569
570 public InventoryFolderBase GetRootFolder(UUID userID)
571 {
572 InventoryFolderBase root = new InventoryFolderBase();
573 root.ID = UUID.Random();
574 root.Owner = userID;
575 root.ParentID = UUID.Zero;
576 return root;
577 }
578 }
450} 579}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index b9044eb..7ad6bbf 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -694,7 +694,7 @@ namespace OpenSim.Framework.Communications
694 // local service (standalone) 694 // local service (standalone)
695 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); 695 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory");
696 m_InventoryService.CreateUserInventory(userProf.ID); 696 m_InventoryService.CreateUserInventory(userProf.ID);
697 InventoryFolderBase rootfolder = m_InventoryService.RequestRootFolder(userProf.ID); 697 InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID);
698 if (rootfolder != null) 698 if (rootfolder != null)
699 userProf.RootInventoryFolderID = rootfolder.ID; 699 userProf.RootInventoryFolderID = rootfolder.ID;
700 } 700 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1a422fd..d4168fe 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -41,7 +41,7 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{ 43{
44 public class HGInventoryBroker : ISharedRegionModule, IInventoryService 44 public class HGInventoryBroker : InventoryCache, ISharedRegionModule, IInventoryService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -122,6 +122,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
122 122
123 m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty); 123 m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty);
124 124
125 Init(source);
126
125 m_Enabled = true; 127 m_Enabled = true;
126 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); 128 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
127 } 129 }
@@ -136,7 +138,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
136 { 138 {
137 } 139 }
138 140
139 public void AddRegion(Scene scene) 141 public override void AddRegion(Scene scene)
140 { 142 {
141 if (!m_Enabled) 143 if (!m_Enabled)
142 return; 144 return;
@@ -154,10 +156,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
154 } 156 }
155 157
156 scene.RegisterModuleInterface<IInventoryService>(this); 158 scene.RegisterModuleInterface<IInventoryService>(this);
159 base.AddRegion(scene);
157 } 160 }
158 161
159 public void RemoveRegion(Scene scene) 162 public override void RemoveRegion(Scene scene)
160 { 163 {
164 base.RemoveRegion(scene);
161 } 165 }
162 166
163 public void RegionLoaded(Scene scene) 167 public void RegionLoaded(Scene scene)
@@ -165,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
165 if (!m_Enabled) 169 if (!m_Enabled)
166 return; 170 return;
167 171
168 m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName); 172 m_log.InfoFormat("[HG INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
169 173
170 } 174 }
171 175
@@ -201,6 +205,72 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
201 } 205 }
202 } 206 }
203 207
208 // Inherited. See base
209 //public override InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
210 //{
211 // if (IsLocalGridUser(userID))
212 // return m_GridService.GetFolderForType(userID, type);
213 // else
214 // {
215 // UUID sessionID = GetSessionID(userID);
216 // string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
217 // // !!!!!!
218 // return null;
219 // //return m_HGService.GetFolderForType(uri, sessionID, type);
220 // }
221 //}
222
223 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
224 {
225 if (IsLocalGridUser(userID))
226 return m_GridService.GetFolderContent(userID, folderID);
227 else
228 {
229 UUID sessionID = GetSessionID(userID);
230 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
231 return m_HGService.GetFolderContent(uri, folderID, sessionID);
232 }
233 }
234
235 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
236 {
237 if (IsLocalGridUser(userID))
238 return GetSystemFoldersLocal(userID);
239 else
240 {
241 UUID sessionID = GetSessionID(userID);
242 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
243 return m_HGService.GetSystemFolders(uri, sessionID);
244 }
245 }
246
247 private Dictionary<AssetType, InventoryFolderBase> GetSystemFoldersLocal(UUID userID)
248 {
249 InventoryFolderBase root = m_GridService.GetRootFolder(userID);
250 if (root != null)
251 {
252 InventoryCollection content = m_GridService.GetFolderContent(userID, root.ID);
253 if (content != null)
254 {
255 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
256 foreach (InventoryFolderBase folder in content.Folders)
257 {
258 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scanning folder type {0}", (AssetType)folder.Type);
259 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
260 folders[(AssetType)folder.Type] = folder;
261 }
262 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
263 return folders;
264 }
265 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
266
267 }
268
269 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder not found for {0}", userID);
270
271 return new Dictionary<AssetType, InventoryFolderBase>();
272 }
273
204 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 274 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
205 { 275 {
206 return new List<InventoryItemBase>(); 276 return new List<InventoryItemBase>();
@@ -346,7 +416,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
346 return false; 416 return false;
347 } 417 }
348 418
349 public InventoryFolderBase RequestRootFolder(UUID userID) 419 public InventoryFolderBase GetRootFolder(UUID userID)
350 { 420 {
351 return null; 421 return null;
352 } 422 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
new file mode 100644
index 0000000..57c2091
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -0,0 +1,108 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Framework;
6using OpenSim.Framework.Client;
7using OpenSim.Region.Framework.Scenes;
8
9using OpenMetaverse;
10using Nini.Config;
11using log4net;
12
13namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
14{
15 public abstract class InventoryCache
16 {
17 private static readonly ILog m_log =
18 LogManager.GetLogger(
19 MethodBase.GetCurrentMethod().DeclaringType);
20
21 protected List<Scene> m_Scenes;
22
23 // The cache proper
24 protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache;
25
26 protected virtual void Init(IConfigSource source)
27 {
28 m_Scenes = new List<Scene>();
29 m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>();
30 }
31
32 public virtual void AddRegion(Scene scene)
33 {
34 m_Scenes.Add(scene);
35 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
36 scene.EventManager.OnClientClosed += OnClientClosed;
37 }
38
39 public virtual void RemoveRegion(Scene scene)
40 {
41 if ((m_Scenes != null) && m_Scenes.Contains(scene))
42 {
43 m_Scenes.Remove(scene);
44 }
45 }
46
47 void OnMakeRootAgent(ScenePresence presence)
48 {
49 // Get system folders
50
51 // First check if they're here already
52 lock (m_InventoryCache)
53 {
54 if (m_InventoryCache.ContainsKey(presence.UUID))
55 {
56 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, system folders for {0} {1} already in cache", presence.Firstname, presence.Lastname);
57 return;
58 }
59 }
60
61 // If not, go get them and place them in the cache
62 Dictionary<AssetType, InventoryFolderBase> folders = GetSystemFolders(presence.UUID);
63 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, fetched system folders for {0} {1}: count {2}",
64 presence.Firstname, presence.Lastname, folders.Count);
65 if (folders.Count > 0)
66 lock (m_InventoryCache)
67 m_InventoryCache.Add(presence.UUID, folders);
68 }
69
70 void OnClientClosed(UUID clientID, Scene scene)
71 {
72 ScenePresence sp = null;
73 foreach (Scene s in m_Scenes)
74 {
75 s.TryGetAvatar(clientID, out sp);
76 if (sp != null)
77 {
78 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed, but user {0} still in sim. Keeping system folders in cache", clientID);
79 return;
80 }
81 }
82
83 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed, user {0} out of sim. Dropping system folders", clientID);
84 // Drop system folders
85 lock (m_InventoryCache)
86 if (m_InventoryCache.ContainsKey(clientID))
87 m_InventoryCache.Remove(clientID);
88
89 }
90
91 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
92
93 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
94 {
95 Dictionary<AssetType, InventoryFolderBase> folders = null;
96 lock (m_InventoryCache)
97 {
98 m_InventoryCache.TryGetValue(userID, out folders);
99 }
100 if ((folders != null) && folders.ContainsKey(type))
101 {
102 return folders[type];
103 }
104
105 return null;
106 }
107 }
108}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index f595b02..98e30ce 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -41,7 +41,7 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{ 43{
44 public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService 44 public class LocalInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -108,6 +108,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
108 // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); 108 // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this));
109 //} 109 //}
110 110
111 Init(source);
112
111 m_Enabled = true; 113 m_Enabled = true;
112 m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled"); 114 m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled");
113 } 115 }
@@ -122,7 +124,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
122 { 124 {
123 } 125 }
124 126
125 public void AddRegion(Scene scene) 127 public override void AddRegion(Scene scene)
126 { 128 {
127 if (!m_Enabled) 129 if (!m_Enabled)
128 return; 130 return;
@@ -139,10 +141,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
139// "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName); 141// "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName);
140 142
141 scene.RegisterModuleInterface<IInventoryService>(this); 143 scene.RegisterModuleInterface<IInventoryService>(this);
144 base.AddRegion(scene);
142 } 145 }
143 146
144 public void RemoveRegion(Scene scene) 147 public override void RemoveRegion(Scene scene)
145 { 148 {
149 base.RemoveRegion(scene);
146 } 150 }
147 151
148 public void RegionLoaded(Scene scene) 152 public void RegionLoaded(Scene scene)
@@ -176,6 +180,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
176 m_InventoryService.GetUserInventory(userID, callback); 180 m_InventoryService.GetUserInventory(userID, callback);
177 } 181 }
178 182
183 // Inherited. See base
184 //public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
185 //{
186 // return m_InventoryService.GetFolderForType(userID, type);
187 //}
188
189 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
190 {
191 InventoryFolderBase root = GetRootFolder(userID);
192 if (root != null)
193 {
194 InventoryCollection content = GetFolderContent(userID, root.ID);
195 if (content != null)
196 {
197 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
198 foreach (InventoryFolderBase folder in content.Folders)
199 {
200 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
201 folders[(AssetType)folder.Type] = folder;
202 }
203 return folders;
204 }
205 }
206 m_log.WarnFormat("[INVENTORY CONNECTOR]: System folders for {0} not found", userID);
207 return new Dictionary<AssetType, InventoryFolderBase>();
208 }
209
210 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
211 {
212 return m_InventoryService.GetFolderContent(userID, folderID);
213 }
214
215
179 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 216 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
180 { 217 {
181 return m_InventoryService.GetFolderItems(userID, folderID); 218 return m_InventoryService.GetFolderItems(userID, folderID);
@@ -276,9 +313,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
276 /// </summary> 313 /// </summary>
277 /// <param name="userID"></param> 314 /// <param name="userID"></param>
278 /// <returns>null if no root folder was found</returns> 315 /// <returns>null if no root folder was found</returns>
279 public InventoryFolderBase RequestRootFolder(UUID userID) 316 public InventoryFolderBase GetRootFolder(UUID userID)
280 { 317 {
281 return m_InventoryService.RequestRootFolder(userID); 318 return m_InventoryService.GetRootFolder(userID);
282 } 319 }
283 320
284 public List<InventoryItemBase> GetActiveGestures(UUID userId) 321 public List<InventoryItemBase> GetActiveGestures(UUID userId)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index 107b588..dceda38 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -40,7 +40,7 @@ using OpenMetaverse;
40 40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
42{ 42{
43 public class RemoteInventoryServicesConnector : ISharedRegionModule, IInventoryService 43 public class RemoteInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
44 { 44 {
45 private static readonly ILog m_log = 45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -69,9 +69,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
69 Init(source); 69 Init(source);
70 } 70 }
71 71
72 private void Init(IConfigSource source) 72 protected override void Init(IConfigSource source)
73 { 73 {
74 m_RemoteConnector = new InventoryServicesConnector(source); 74 m_RemoteConnector = new InventoryServicesConnector(source);
75 base.Init(source);
75 } 76 }
76 77
77 78
@@ -101,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
101 { 102 {
102 } 103 }
103 104
104 public void AddRegion(Scene scene) 105 public override void AddRegion(Scene scene)
105 { 106 {
106 if (!m_Enabled) 107 if (!m_Enabled)
107 return; 108 return;
@@ -116,10 +117,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
116 } 117 }
117 118
118 scene.RegisterModuleInterface<IInventoryService>(this); 119 scene.RegisterModuleInterface<IInventoryService>(this);
120 base.AddRegion(scene);
119 } 121 }
120 122
121 public void RemoveRegion(Scene scene) 123 public override void RemoveRegion(Scene scene)
122 { 124 {
125 base.RemoveRegion(scene);
123 } 126 }
124 127
125 public void RegionLoaded(Scene scene) 128 public void RegionLoaded(Scene scene)
@@ -168,6 +171,34 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
168 171
169 } 172 }
170 173
174 // inherited. See base class
175 // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
176
177 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
178 {
179 UUID sessionID = GetSessionID(userID);
180 return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID);
181 }
182
183 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
184 {
185 UUID sessionID = GetSessionID(userID);
186 try
187 {
188 return m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
189 }
190 catch (Exception e)
191 {
192 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
193 e.Source, e.Message);
194 }
195 InventoryCollection nullCollection = new InventoryCollection();
196 nullCollection.Folders = new List<InventoryFolderBase>();
197 nullCollection.Items = new List<InventoryItemBase>();
198 nullCollection.UserID = userID;
199 return nullCollection;
200 }
201
171 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 202 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
172 { 203 {
173 return new List<InventoryItemBase>(); 204 return new List<InventoryItemBase>();
@@ -259,7 +290,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
259 return false; 290 return false;
260 } 291 }
261 292
262 public InventoryFolderBase RequestRootFolder(UUID userID) 293 public InventoryFolderBase GetRootFolder(UUID userID)
263 { 294 {
264 return null; 295 return null;
265 } 296 }
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index 01e517c..f6d1500 100644
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -120,6 +120,48 @@ namespace OpenSim.Services.Connectors.Inventory
120 120
121 } 121 }
122 122
123 /// <summary>
124 /// Gets the user folder for the given folder-type
125 /// </summary>
126 /// <param name="userID"></param>
127 /// <param name="type"></param>
128 /// <returns></returns>
129 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string id, UUID sessionID)
130 {
131 m_log.Debug("[HGInventory]: GetSystemFolders " + id);
132 string url = string.Empty;
133 string userID = string.Empty;
134
135 if (StringToUrlAndUserID(id, out url, out userID))
136 {
137 ISessionAuthInventoryService connector = GetConnector(url);
138 return connector.GetSystemFolders(userID, sessionID);
139 }
140
141 return new Dictionary<AssetType, InventoryFolderBase>();
142 }
143
144 /// <summary>
145 /// Gets everything (folders and items) inside a folder
146 /// </summary>
147 /// <param name="userId"></param>
148 /// <param name="folderID"></param>
149 /// <returns></returns>
150 public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
151 {
152 m_log.Debug("[HGInventory]: GetSystemFolders " + id);
153 string url = string.Empty;
154 string userID = string.Empty;
155
156 if (StringToUrlAndUserID(id, out url, out userID))
157 {
158 ISessionAuthInventoryService connector = GetConnector(url);
159 return connector.GetFolderContent(userID, folderID, sessionID);
160 }
161
162 return null;
163 }
164
123 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) 165 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID)
124 { 166 {
125 string url = string.Empty; 167 string url = string.Empty;
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
index 4fc4363..973cb0a 100644
--- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
+++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenSim.Framework; 29using OpenSim.Framework;
29using OpenSim.Services.Interfaces; 30using OpenSim.Services.Interfaces;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -51,6 +52,22 @@ namespace OpenSim.Services.Connectors
51 void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback); 52 void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback);
52 53
53 /// <summary> 54 /// <summary>
55 /// Gets the user folder for the given folder-type
56 /// </summary>
57 /// <param name="userID"></param>
58 /// <param name="type"></param>
59 /// <returns></returns>
60 Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID session_id);
61
62 /// <summary>
63 /// Gets everything (folders and items) inside a folder
64 /// </summary>
65 /// <param name="userId"></param>
66 /// <param name="folderID"></param>
67 /// <returns></returns>
68 InventoryCollection GetFolderContent(string userID, UUID folderID, UUID session_id);
69
70 /// <summary>
54 /// Add a new folder to the user's inventory 71 /// Add a new folder to the user's inventory
55 /// </summary> 72 /// </summary>
56 /// <param name="folder"></param> 73 /// <param name="folder"></param>
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index ae15cfb..3b15831 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -155,6 +155,50 @@ namespace OpenSim.Services.Connectors
155 } 155 }
156 } 156 }
157 157
158 /// <summary>
159 /// Gets the user folder for the given folder-type
160 /// </summary>
161 /// <param name="userID"></param>
162 /// <param name="type"></param>
163 /// <returns></returns>
164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
165 {
166 try
167 {
168 return SynchronousRestSessionObjectPoster<string, Dictionary<AssetType, InventoryFolderBase>>.BeginPostObject(
169 "GET", m_ServerURI + "/SystemFolders/", userID, sessionID.ToString(), userID.ToString());
170 }
171 catch (Exception e)
172 {
173 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}",
174 e.Source, e.Message);
175 }
176
177 return new Dictionary<AssetType, InventoryFolderBase>();
178 }
179
180 /// <summary>
181 /// Gets everything (folders and items) inside a folder
182 /// </summary>
183 /// <param name="userId"></param>
184 /// <param name="folderID"></param>
185 /// <returns></returns>
186 public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID)
187 {
188 try
189 {
190 return SynchronousRestSessionObjectPoster<UUID, InventoryCollection>.BeginPostObject(
191 "GET", m_ServerURI + "/GetFolderContents/", folderID, sessionID.ToString(), userID.ToString());
192 }
193 catch (Exception e)
194 {
195 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}",
196 e.Source, e.Message);
197 }
198
199 return null;
200 }
201
158 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID) 202 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
159 { 203 {
160 try 204 try
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
index 6a93c04..22289aa 100644
--- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
@@ -106,6 +106,16 @@ namespace OpenSim.Services.Connectors
106 { 106 {
107 } 107 }
108 108
109 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
110 {
111 return null;
112 }
113
114 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
115 {
116 return null;
117 }
118
109 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 119 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
110 { 120 {
111 return null; 121 return null;
@@ -161,7 +171,7 @@ namespace OpenSim.Services.Connectors
161 return false; 171 return false;
162 } 172 }
163 173
164 public InventoryFolderBase RequestRootFolder(UUID userID) 174 public InventoryFolderBase GetRootFolder(UUID userID)
165 { 175 {
166 return null; 176 return null;
167 } 177 }
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index 15da3cb..8058aa7 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -70,6 +70,29 @@ namespace OpenSim.Services.Interfaces
70 void GetUserInventory(UUID userID, InventoryReceiptCallback callback); 70 void GetUserInventory(UUID userID, InventoryReceiptCallback callback);
71 71
72 /// <summary> 72 /// <summary>
73 /// Retrieve the root inventory folder for the given user.
74 /// </summary>
75 /// <param name="userID"></param>
76 /// <returns>null if no root folder was found</returns>
77 InventoryFolderBase GetRootFolder(UUID userID);
78
79 /// <summary>
80 /// Gets the user folder for the given folder-type
81 /// </summary>
82 /// <param name="userID"></param>
83 /// <param name="type"></param>
84 /// <returns></returns>
85 InventoryFolderBase GetFolderForType(UUID userID, AssetType type);
86
87 /// <summary>
88 /// Gets everything (folders and items) inside a folder
89 /// </summary>
90 /// <param name="userId"></param>
91 /// <param name="folderID"></param>
92 /// <returns></returns>
93 InventoryCollection GetFolderContent(UUID userID, UUID folderID);
94
95 /// <summary>
73 /// Gets the items inside a folder 96 /// Gets the items inside a folder
74 /// </summary> 97 /// </summary>
75 /// <param name="userID"></param> 98 /// <param name="userID"></param>
@@ -138,13 +161,6 @@ namespace OpenSim.Services.Interfaces
138 bool HasInventoryForUser(UUID userID); 161 bool HasInventoryForUser(UUID userID);
139 162
140 /// <summary> 163 /// <summary>
141 /// Retrieve the root inventory folder for the given user.
142 /// </summary>
143 /// <param name="userID"></param>
144 /// <returns>null if no root folder was found</returns>
145 InventoryFolderBase RequestRootFolder(UUID userID);
146
147 /// <summary>
148 /// Get the active gestures of the agent. 164 /// Get the active gestures of the agent.
149 /// </summary> 165 /// </summary>
150 /// <param name="userId"></param> 166 /// <param name="userId"></param>
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs
index ea34195..a9ecda4 100644
--- a/OpenSim/Services/InventoryService/InventoryService.cs
+++ b/OpenSim/Services/InventoryService/InventoryService.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Services.InventoryService
60 { 60 {
61 m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId); 61 m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId);
62 62
63 InventoryFolderBase rootFolder = RequestRootFolder(userId); 63 InventoryFolderBase rootFolder = GetRootFolder(userId);
64 64
65 // Agent has no inventory structure yet. 65 // Agent has no inventory structure yet.
66 if (null == rootFolder) 66 if (null == rootFolder)
@@ -86,7 +86,7 @@ namespace OpenSim.Services.InventoryService
86 } 86 }
87 87
88 // See IInventoryServices 88 // See IInventoryServices
89 public virtual InventoryFolderBase RequestRootFolder(UUID userID) 89 public virtual InventoryFolderBase GetRootFolder(UUID userID)
90 { 90 {
91 // Retrieve the first root folder we get from the DB. 91 // Retrieve the first root folder we get from the DB.
92 InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID); 92 InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID);
@@ -100,7 +100,7 @@ namespace OpenSim.Services.InventoryService
100 // See IInventoryServices 100 // See IInventoryServices
101 public bool CreateUserInventory(UUID user) 101 public bool CreateUserInventory(UUID user)
102 { 102 {
103 InventoryFolderBase existingRootFolder = RequestRootFolder(user); 103 InventoryFolderBase existingRootFolder = GetRootFolder(user);
104 104
105 if (null != existingRootFolder) 105 if (null != existingRootFolder)
106 { 106 {
@@ -233,6 +233,67 @@ namespace OpenSim.Services.InventoryService
233 callback.BeginInvoke(folders, items, null, null); 233 callback.BeginInvoke(folders, items, null, null);
234 } 234 }
235 235
236 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
237 {
238 m_log.Info("[INVENTORY SERVICE]: Processing request for folder " + folderID);
239
240 // Uncomment me to simulate a slow responding inventory server
241 //Thread.Sleep(16000);
242
243 InventoryCollection invCollection = new InventoryCollection();
244
245 List<InventoryItemBase> items = GetFolderItems(userID, folderID);
246 List<InventoryFolderBase> folders = RequestSubFolders(folderID);
247
248 invCollection.UserID = userID;
249 invCollection.Folders = folders;
250 invCollection.Items = items;
251
252 m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders", items.Count, folders.Count);
253
254 return invCollection;
255 }
256
257 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
258 {
259 InventoryFolderBase root = m_Database.getUserRootFolder(userID);
260 if (root != null)
261 {
262 List<InventoryFolderBase> folders = RequestSubFolders(root.ID);
263
264 foreach (InventoryFolderBase folder in folders)
265 {
266 if (folder.Type == (short)type)
267 return folder;
268 }
269 }
270
271 // we didn't find any folder of that type. Return the root folder
272 // hopefully the root folder is not null. If it is, too bad
273 return root;
274 }
275
276 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
277 {
278 InventoryFolderBase root = GetRootFolder(userID);
279 if (root != null)
280 {
281 InventoryCollection content = GetFolderContent(userID, root.ID);
282 if (content != null)
283 {
284 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
285 foreach (InventoryFolderBase folder in content.Folders)
286 {
287 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
288 folders[(AssetType)folder.Type] = folder;
289 }
290 return folders;
291 }
292 }
293 m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
294 return new Dictionary<AssetType, InventoryFolderBase>();
295 }
296
236 public List<InventoryItemBase> GetActiveGestures(UUID userId) 297 public List<InventoryItemBase> GetActiveGestures(UUID userId)
237 { 298 {
238 List<InventoryItemBase> activeGestures = new List<InventoryItemBase>(); 299 List<InventoryItemBase> activeGestures = new List<InventoryItemBase>();