From 31ca3a8d4d53fc82a3b4cb62ad4edaebc4111302 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 12 Feb 2009 17:07:44 +0000 Subject: * refactor: Move RequestInventoryForUser() from service to CachedUserInfo * This simplifies callers in most cases - CachedUserInfo is already handling the rest of the fetch inventory work anyway --- .../Communications/Cache/CachedUserInfo.cs | 19 ++++++++++++++ .../Cache/UserProfileCacheService.cs | 30 ---------------------- .../Tests/Cache/UserProfileCacheServiceTests.cs | 2 +- .../Tests/Cache/UserProfileTestUtils.cs | 5 ++-- 4 files changed, 23 insertions(+), 33 deletions(-) (limited to 'OpenSim/Framework/Communications') diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 15066cd..c5bbd6a 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -202,6 +202,25 @@ namespace OpenSim.Framework.Communications.Cache m_rootFolder = null; } } + + /// + /// Fetch inventory for this user. + /// + /// This has to be executed as a separate step once user information is retreived. + /// This will occur synchronously if the inventory service is in the same process as this class, and + /// asynchronously otherwise. + public void FetchInventory() + { + if (m_commsManager.SecureInventoryService != null) + { + m_commsManager.SecureInventoryService.RequestInventoryForUser( + UserProfile.ID, SessionID, InventoryReceive); + } + else + { + m_commsManager.InventoryService.RequestInventoryForUser(UserProfile.ID, InventoryReceive); + } + } /// /// Callback invoked when the inventory is received from an async request to the inventory service diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index ef190c8..b1ce3e7 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -105,36 +105,6 @@ namespace OpenSim.Framework.Communications.Cache } /// - /// Request the inventory data for the given user. This will occur asynchronously if running on a grid - /// - /// - /// - public void RequestInventoryForUser(UUID userID) - { - CachedUserInfo userInfo = GetUserDetails(userID); - if (userInfo != null) - { - if (m_commsManager.SecureInventoryService != null) - { - m_commsManager.SecureInventoryService.RequestInventoryForUser(userID, userInfo.SessionID, userInfo.InventoryReceive); - } - else - { - m_commsManager.InventoryService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - } - //IInventoryServices invService = userInfo.GetInventoryService(); - //if (invService != null) - //{ - // invService.RequestInventoryForUser(userID, userInfo.InventoryReceive); - //} - } - else - { - m_log.ErrorFormat("[USER CACHE]: RequestInventoryForUser() - user profile for user {0} not found", userID); - } - } - - /// /// Get cached details of the given user. If the user isn't in cache then the user is requested from the /// profile service. /// diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index cda9d5c..e2576ef 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Tests /// Test requesting inventory for a user /// [Test] - public void TestRequestInventoryForUser() + public void TestFetchInventory() { TestCommunicationsManager commsManager = new TestCommunicationsManager(); CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs index 85cc940..93ce916 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileTestUtils.cs @@ -59,9 +59,10 @@ namespace OpenSim.Framework.Communications.Tests lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + userInfo.FetchInventory(); - return commsManager.UserProfileCacheService.GetUserDetails(userId); + return userInfo; } } } -- cgit v1.1