aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs100
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs76
-rw-r--r--OpenSim/Framework/Communications/InventoryServiceBase.cs12
-rw-r--r--OpenSim/Grid/InventoryServer/GridInventoryService.cs66
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs1
5 files changed, 124 insertions, 131 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 86c24bc..f55b492 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -28,11 +28,16 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
32
31using libsecondlife; 33using libsecondlife;
32using log4net; 34using log4net;
33 35
34namespace OpenSim.Framework.Communications.Cache 36namespace OpenSim.Framework.Communications.Cache
35{ 37{
38 internal delegate void CreateInventoryFolderDelegate(
39 string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
40
36 /// <summary> 41 /// <summary>
37 /// Stores user profile and inventory data received from backend services for a particular user. 42 /// Stores user profile and inventory data received from backend services for a particular user.
38 /// </summary> 43 /// </summary>
@@ -297,6 +302,99 @@ namespace OpenSim.Framework.Communications.Cache
297 } 302 }
298 } 303 }
299 } 304 }
305
306 /// <summary>
307 /// Create a folder in this agent's inventory
308 /// </summary>
309 /// <param name="parentID"></param>
310 /// <returns></returns>
311 public bool CreateFolder(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID)
312 {
313// m_log.DebugFormat(
314// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId);
315
316 if (HasInventory)
317 {
318 if (RootFolder.ID == parentID)
319 {
320 InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
321
322 if (createdFolder != null)
323 {
324 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
325 createdBaseFolder.Owner = createdFolder.Owner;
326 createdBaseFolder.ID = createdFolder.ID;
327 createdBaseFolder.Name = createdFolder.Name;
328 createdBaseFolder.ParentID = createdFolder.ParentID;
329 createdBaseFolder.Type = createdFolder.Type;
330 createdBaseFolder.Version = createdFolder.Version;
331
332 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
333
334 return true;
335 }
336 else
337 {
338 m_log.WarnFormat(
339 "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
340 folderName, folderID);
341
342 return false;
343 }
344 }
345 else
346 {
347 InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID);
348
349 if (folder != null)
350 {
351 InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType);
352
353 if (createdFolder != null)
354 {
355 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
356 createdBaseFolder.Owner = createdFolder.Owner;
357 createdBaseFolder.ID = createdFolder.ID;
358 createdBaseFolder.Name = createdFolder.Name;
359 createdBaseFolder.ParentID = createdFolder.ParentID;
360 createdBaseFolder.Type = createdFolder.Type;
361 createdBaseFolder.Version = createdFolder.Version;
362
363 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
364
365 return true;
366 }
367 else
368 {
369 m_log.WarnFormat(
370 "[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
371 folderName, folderID);
372
373 return false;
374 }
375 }
376 else
377 {
378 m_log.WarnFormat(
379 "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}",
380 parentID, folderName, folderID);
381
382 return false;
383 }
384 }
385 }
386 else
387 {
388 AddRequest(
389 new InventoryRequest(
390 Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"),
391 new object[] { folderName, folderID, folderType, parentID }));
392
393 return true;
394 }
395
396 return false;
397 }
300 398
301 /// <summary> 399 /// <summary>
302 /// Add an item to the user's inventory 400 /// Add an item to the user's inventory
@@ -360,7 +458,7 @@ namespace OpenSim.Framework.Communications.Cache
360 /// <summary> 458 /// <summary>
361 /// Generic inventory request 459 /// Generic inventory request
362 /// </summary> 460 /// </summary>
363 public class InventoryRequest : IInventoryRequest 461 class InventoryRequest : IInventoryRequest
364 { 462 {
365 private Delegate m_delegat; 463 private Delegate m_delegat;
366 private Object[] m_args; 464 private Object[] m_args;
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index befb6c7..f1929c8 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -34,8 +34,6 @@ using log4net;
34 34
35namespace OpenSim.Framework.Communications.Cache 35namespace OpenSim.Framework.Communications.Cache
36{ 36{
37 internal delegate void CreateInventoryFolderDelegate(
38 IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID);
39 internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); 37 internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID);
40 internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID); 38 internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID);
41 internal delegate void UpdateInventoryFolderDelegate( 39 internal delegate void UpdateInventoryFolderDelegate(
@@ -157,80 +155,16 @@ namespace OpenSim.Framework.Communications.Cache
157 /// <param name="parentID"></param> 155 /// <param name="parentID"></param>
158 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, 156 public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,
159 string folderName, LLUUID parentID) 157 string folderName, LLUUID parentID)
160 { 158 {
161// m_log.DebugFormat(
162// "[AGENT INVENTORY]: Creating inventory folder {0} {1} for {2} {3}", folderID, folderName, remoteClient.Name, remoteClient.AgentId);
163
164 CachedUserInfo userProfile; 159 CachedUserInfo userProfile;
165 160
166 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile)) 161 if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
167 { 162 {
168 if (userProfile.HasInventory) 163 if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
169 { 164 {
170 if (userProfile.RootFolder.ID == parentID) 165 m_log.WarnFormat(
171 { 166 "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
172 InventoryFolderImpl createdFolder = 167 remoteClient.Name, remoteClient.AgentId);
173 userProfile.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
174
175 if (createdFolder != null)
176 {
177 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
178 createdBaseFolder.Owner = createdFolder.Owner;
179 createdBaseFolder.ID = createdFolder.ID;
180 createdBaseFolder.Name = createdFolder.Name;
181 createdBaseFolder.ParentID = createdFolder.ParentID;
182 createdBaseFolder.Type = createdFolder.Type;
183 createdBaseFolder.Version = createdFolder.Version;
184
185 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
186 }
187 else
188 {
189 m_log.WarnFormat(
190 "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists",
191 folderName, folderID, remoteClient.Name, remoteClient.AgentId);
192 }
193 }
194 else
195 {
196 InventoryFolderImpl folder = userProfile.RootFolder.GetDescendentFolder(parentID);
197 if (folder != null)
198 {
199 InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType);
200
201 if (createdFolder != null)
202 {
203 InventoryFolderBase createdBaseFolder = new InventoryFolderBase();
204 createdBaseFolder.Owner = createdFolder.Owner;
205 createdBaseFolder.ID = createdFolder.ID;
206 createdBaseFolder.Name = createdFolder.Name;
207 createdBaseFolder.ParentID = createdFolder.ParentID;
208 createdBaseFolder.Type = createdFolder.Type;
209 createdBaseFolder.Version = createdFolder.Version;
210
211 m_commsManager.InventoryService.AddFolder(createdBaseFolder);
212 }
213 else
214 {
215 m_log.WarnFormat(
216 "[INVENTORY CACHE]: Tried to create folder {0} {1} for user {2} {3} but the folder already exists",
217 folderName, folderID, remoteClient.Name, remoteClient.AgentId);
218 }
219 }
220 else
221 {
222 m_log.WarnFormat(
223 "[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2} for user {3} {4}",
224 parentID, folderName, folderID, remoteClient.Name, remoteClient.AgentId);
225 }
226 }
227 }
228 else
229 {
230 userProfile.AddRequest(
231 new InventoryRequest(
232 Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "HandleCreateInventoryFolder"),
233 new object[] { remoteClient, folderID, folderType, folderName, parentID }));
234 } 168 }
235 } 169 }
236 } 170 }
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 1601963..e81d8c4 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -28,11 +28,16 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
32
31using libsecondlife; 33using libsecondlife;
32using log4net; 34using log4net;
33 35
34namespace OpenSim.Framework.Communications 36namespace OpenSim.Framework.Communications
35{ 37{
38 /// <summary>
39 /// Abstract base class used by local and grid implementations of an inventory service.
40 /// </summary>
36 public abstract class InventoryServiceBase : IInventoryServices 41 public abstract class InventoryServiceBase : IInventoryServices
37 { 42 {
38 private static readonly ILog m_log 43 private static readonly ILog m_log
@@ -178,10 +183,11 @@ namespace OpenSim.Framework.Communications
178 183
179 #endregion 184 #endregion
180 185
186 // See IInventoryServices
181 public bool AddFolder(InventoryFolderBase folder) 187 public bool AddFolder(InventoryFolderBase folder)
182 { 188 {
183 m_log.DebugFormat( 189 m_log.DebugFormat(
184 "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); 190 "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
185 191
186 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) 192 foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
187 { 193 {
@@ -192,6 +198,7 @@ namespace OpenSim.Framework.Communications
192 return true; 198 return true;
193 } 199 }
194 200
201 // See IInventoryServices
195 public bool MoveFolder(InventoryFolderBase folder) 202 public bool MoveFolder(InventoryFolderBase folder)
196 { 203 {
197 m_log.DebugFormat( 204 m_log.DebugFormat(
@@ -206,6 +213,7 @@ namespace OpenSim.Framework.Communications
206 return true; 213 return true;
207 } 214 }
208 215
216 // See IInventoryServices
209 public bool AddItem(InventoryItemBase item) 217 public bool AddItem(InventoryItemBase item)
210 { 218 {
211 m_log.DebugFormat( 219 m_log.DebugFormat(
@@ -220,6 +228,7 @@ namespace OpenSim.Framework.Communications
220 return true; 228 return true;
221 } 229 }
222 230
231 // See IInventoryServices
223 public bool UpdateItem(InventoryItemBase item) 232 public bool UpdateItem(InventoryItemBase item)
224 { 233 {
225 m_log.InfoFormat( 234 m_log.InfoFormat(
@@ -234,6 +243,7 @@ namespace OpenSim.Framework.Communications
234 return true; 243 return true;
235 } 244 }
236 245
246 // See IInventoryServices
237 public bool DeleteItem(InventoryItemBase item) 247 public bool DeleteItem(InventoryItemBase item)
238 { 248 {
239 m_log.InfoFormat( 249 m_log.InfoFormat(
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index d9510e9..f0eef31 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -28,8 +28,11 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
32
31using libsecondlife; 33using libsecondlife;
32using log4net; 34using log4net;
35
33using OpenSim.Framework; 36using OpenSim.Framework;
34using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
35 38
@@ -48,71 +51,18 @@ namespace OpenSim.Grid.InventoryServer
48 } 51 }
49 52
50 /// <summary> 53 /// <summary>
51 /// Get a user's inventory.
52 /// </summary>
53 /// <param name="userID"></param>
54 /// <param name="folderList"></param>
55 /// <param name="itemsList"></param>
56 /// <returns>true if the inventory was retrieved, false otherwise</returns>
57 private bool GetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList,
58 out List<InventoryItemBase> itemsList)
59 {
60 List<InventoryFolderBase> allFolders = GetInventorySkeleton(userID);
61 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
62
63 foreach (InventoryFolderBase folder in allFolders)
64 {
65 List<InventoryItemBase> items = RequestFolderItems(folder.ID);
66 if (items != null)
67 {
68 allItems.InsertRange(0, items);
69 }
70 }
71
72 folderList = allFolders;
73 itemsList = allItems;
74 if (folderList != null)
75 {
76 return true;
77 }
78 else
79 {
80 return false;
81 }
82 }
83
84 private List<InventoryFolderBase> GetAllFolders(LLUUID folder)
85 {
86 List<InventoryFolderBase> allFolders = new List<InventoryFolderBase>();
87 List<InventoryFolderBase> folders = RequestSubFolders(folder);
88 if (folders != null)
89 {
90 allFolders.InsertRange(0, folders);
91 foreach (InventoryFolderBase subfolder in folders)
92 {
93 List<InventoryFolderBase> subFolders = GetAllFolders(subfolder.ID);
94 if (subFolders != null)
95 {
96 allFolders.InsertRange(0, subFolders);
97 }
98 }
99 }
100 return allFolders;
101 }
102
103 /// <summary>
104 /// Return a user's entire inventory 54 /// Return a user's entire inventory
105 /// </summary> 55 /// </summary>
106 /// <param name="rawUserID"></param> 56 /// <param name="rawUserID"></param>
107 /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> 57 /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns>
108 public InventoryCollection GetUserInventory(Guid rawUserID) 58 public InventoryCollection GetUserInventory(Guid rawUserID)
109 { 59 {
110 // uncomment me to simulate an overloaded inventory server
111 //Thread.Sleep(20000);
112
113 LLUUID userID = new LLUUID(rawUserID); 60 LLUUID userID = new LLUUID(rawUserID);
114 61
115 m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID); 62 m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
63
64 // uncomment me to simulate an overloaded inventory server
65 //Thread.Sleep(20000);
116 66
117 InventoryCollection invCollection = new InventoryCollection(); 67 InventoryCollection invCollection = new InventoryCollection();
118 68
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 59c45fa..0715b64 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -645,6 +645,7 @@ namespace OpenSim.Region.Environment.Scenes
645 { 645 {
646 CachedUserInfo userInfo 646 CachedUserInfo userInfo
647 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 647 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
648
648 if (userInfo == null) 649 if (userInfo == null)
649 { 650 {
650 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); 651 m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());