aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-05-03 18:57:02 +0000
committerJustin Clarke Casey2008-05-03 18:57:02 +0000
commit10875427058e68784ca6f5538a00a0cafd46a72b (patch)
tree51d7be53b9bc64eb86bf1720513661933ea0a5ba /OpenSim/Framework/Communications/Cache
parent* Refactor: remove redundant userId parameter from UpdateItem() and DeleteItem() (diff)
downloadopensim-SC_OLD-10875427058e68784ca6f5538a00a0cafd46a72b.zip
opensim-SC_OLD-10875427058e68784ca6f5538a00a0cafd46a72b.tar.gz
opensim-SC_OLD-10875427058e68784ca6f5538a00a0cafd46a72b.tar.bz2
opensim-SC_OLD-10875427058e68784ca6f5538a00a0cafd46a72b.tar.xz
* Refactor: Move bulk of CreateFolder from UserProfileCacheService into CachedUserInfo
* Remove unused/superseded methods from GridInventoryService
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs100
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs76
2 files changed, 104 insertions, 72 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 }