From 7aa54593e0b6672979feec97b8151ed134388723 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 12 Aug 2009 20:39:48 -0700 Subject: Redirected all calls to CachedUserProfile methods to the inventory service. Redirection of the RootFolder property is still todo. This compiles but probably inventory will be inconsistent. --- .../AssetTransaction/AgentAssetsTransactions.cs | 47 +++---- .../Agent/AssetTransaction/AssetXferUploader.cs | 51 ++++---- .../CoreModules/Avatar/Friends/FriendsModule.cs | 7 +- .../CoreModules/Avatar/Gestures/GesturesModule.cs | 39 +++--- .../Inventory/Transfer/InventoryTransferModule.cs | 141 +++++++++------------ .../Inventory/InventoryCache.cs | 1 + 6 files changed, 124 insertions(+), 162 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 8d586c4..c9ee54f 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -192,40 +192,29 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { - CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( - remoteClient.AgentId); + UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); - if (userInfo != null) - { - UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); - - AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); - - if (asset == null) - { - asset = GetTransactionAsset(transactionID); - } - - if (asset != null && asset.FullID == assetID) - { - // Assets never get updated, new ones get created - asset.FullID = UUID.Random(); - asset.Name = item.Name; - asset.Description = item.Description; - asset.Type = (sbyte)item.AssetType; - item.AssetID = asset.FullID; - - Manager.MyScene.AssetService.Store(asset); - } + AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); - userInfo.UpdateItem(item); + if (asset == null) + { + asset = GetTransactionAsset(transactionID); } - else + + if (asset != null && asset.FullID == assetID) { - m_log.ErrorFormat( - "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item update", - remoteClient.AgentId); + // Assets never get updated, new ones get created + asset.FullID = UUID.Random(); + asset.Name = item.Name; + asset.Description = item.Description; + asset.Type = (sbyte)item.AssetType; + item.AssetID = asset.FullID; + + Manager.MyScene.AssetService.Store(asset); } + + IInventoryService invService = Manager.MyScene.InventoryService; + invService.UpdateItem(item); } } } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index afd9f5a..e192b81 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -32,6 +32,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { @@ -214,39 +215,31 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private void DoCreateItem(uint callbackID) { m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); - CachedUserInfo userInfo = - m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( - ourClient.AgentId); - if (userInfo != null) - { - InventoryItemBase item = new InventoryItemBase(); - item.Owner = ourClient.AgentId; - item.CreatorId = ourClient.AgentId.ToString(); - item.ID = UUID.Random(); - item.AssetID = m_asset.FullID; - item.Description = m_description; - item.Name = m_name; - item.AssetType = type; - item.InvType = invType; - item.Folder = InventFolder; - item.BasePermissions = 0x7fffffff; - item.CurrentPermissions = 0x7fffffff; - item.GroupPermissions=0; - item.EveryOnePermissions=0; - item.NextPermissions = nextPerm; - item.Flags = (uint) wearableType; - item.CreationDate = Util.UnixTimeSinceEpoch(); + IInventoryService invService = m_userTransactions.Manager.MyScene.InventoryService; + + InventoryItemBase item = new InventoryItemBase(); + item.Owner = ourClient.AgentId; + item.CreatorId = ourClient.AgentId.ToString(); + item.ID = UUID.Random(); + item.AssetID = m_asset.FullID; + item.Description = m_description; + item.Name = m_name; + item.AssetType = type; + item.InvType = invType; + item.Folder = InventFolder; + item.BasePermissions = 0x7fffffff; + item.CurrentPermissions = 0x7fffffff; + item.GroupPermissions=0; + item.EveryOnePermissions=0; + item.NextPermissions = nextPerm; + item.Flags = (uint) wearableType; + item.CreationDate = Util.UnixTimeSinceEpoch(); - userInfo.AddItem(item); + if (invService.AddItem(item)) ourClient.SendInventoryItemCreateUpdate(item, callbackID); - } else - { - m_log.ErrorFormat( - "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", - ourClient.AgentId); - } + ourClient.SendAlertMessage("Unable to create inventory item"); } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index b6250a2..49b2b5c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -39,6 +39,7 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -654,8 +655,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID }); // find the folder for the friend... - InventoryFolderImpl folder = - initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); + //InventoryFolderImpl folder = + // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); + IInventoryService invService = initiator.Scene.InventoryService; + InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard); if (folder != null) { // ... and add the calling card diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs index 102feaf..e61648c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs @@ -33,6 +33,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Gestures { @@ -62,42 +63,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId) { - CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); + IInventoryService invService = m_scene.InventoryService; - if (userInfo != null) + InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId)); + if (item != null) { - InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); - if (item != null) - { - item.Flags = 1; - userInfo.UpdateItem(item); - } - else - m_log.ErrorFormat( - "[GESTURES]: Unable to find gesture to activate {0} for {1}", gestureId, client.Name); + item.Flags = 1; + invService.UpdateItem(item); } else - m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); + m_log.WarnFormat( + "[GESTURES]: Unable to find gesture {0} to activate for {1}", gestureId, client.Name); } public virtual void DeactivateGesture(IClientAPI client, UUID gestureId) { - CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); + IInventoryService invService = m_scene.InventoryService; - if (userInfo != null) + InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId)); + if (item != null) { - InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); - if (item != null) - { - item.Flags = 0; - userInfo.UpdateItem(item); - } - else - m_log.ErrorFormat( - "[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name); + item.Flags = 0; + invService.UpdateItem(item); } else - m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); + m_log.ErrorFormat( + "[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name); } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 811d4cc..b5650fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { @@ -154,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer "into agent {1}'s inventory", folderID, new UUID(im.toAgentID)); - InventoryFolderImpl folderCopy + InventoryFolderBase folderCopy = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero); if (folderCopy == null) @@ -247,52 +248,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer // It will have been pushed to the client, too // - CachedUserInfo userInfo = - scene.CommsManager.UserProfileCacheService. - GetUserDetails(client.AgentId); + //CachedUserInfo userInfo = + // scene.CommsManager.UserProfileCacheService. + // GetUserDetails(client.AgentId); + IInventoryService invService = scene.InventoryService; - if (userInfo != null) - { - InventoryFolderImpl trashFolder = - userInfo.FindFolderForType((int)AssetType.TrashFolder); - - UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip - - InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID); - InventoryFolderBase folder = null; + InventoryFolderBase trashFolder = + invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); + + UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip - if (item != null && trashFolder != null) - { - item.Folder = trashFolder.ID; - - userInfo.DeleteItem(inventoryEntityID); + InventoryItemBase item = invService.QueryItem(new InventoryItemBase(inventoryEntityID)); + InventoryFolderBase folder = null; + + if (item != null && trashFolder != null) + { + item.Folder = trashFolder.ID; - scene.AddInventoryItem(client, item); - } - else + // Diva comment: can't we just update this item??? + invService.DeleteItem(item); + scene.AddInventoryItem(client, item); + } + else + { + folder = invService.QueryFolder(new InventoryFolderBase(inventoryEntityID)); + + if (folder != null & trashFolder != null) { - folder = userInfo.RootFolder.FindFolder(inventoryEntityID); - - if (folder != null & trashFolder != null) - { - userInfo.MoveFolder(inventoryEntityID, trashFolder.ID); - } + folder.ParentID = trashFolder.ID; + invService.MoveFolder(folder); } + } + + if ((null == item && null == folder) | null == trashFolder) + { + string reason = String.Empty; - if ((null == item && null == folder) | null == trashFolder) - { - string reason = String.Empty; - - if (trashFolder == null) - reason += " Trash folder not found."; - if (item == null) - reason += " Item not found."; - if (folder == null) - reason += " Folder not found."; - - client.SendAgentAlertMessage("Unable to delete "+ - "received inventory" + reason, false); - } + if (trashFolder == null) + reason += " Trash folder not found."; + if (item == null) + reason += " Item not found."; + if (folder == null) + reason += " Folder not found."; + + client.SendAgentAlertMessage("Unable to delete "+ + "received inventory" + reason, false); } ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); @@ -405,17 +405,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer return; } - CachedUserInfo userInfo = - scene.CommsManager.UserProfileCacheService. - GetUserDetails(user.ControllingClient.AgentId); + //CachedUserInfo userInfo = + // scene.CommsManager.UserProfileCacheService. + // GetUserDetails(user.ControllingClient.AgentId); - if (userInfo == null) - { - m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient"); - return; - } + //if (userInfo == null) + //{ + // m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient"); + // return; + //} AssetType assetType = (AssetType)msg.binaryBucket[0]; + IInventoryService invService = scene.InventoryService; if (AssetType.Folder == assetType) { @@ -425,31 +426,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer folder.ID = folderID; folder.Owner = user.ControllingClient.AgentId; - // Fetch from database + // Fetch from service // - if (!userInfo.QueryFolder(folder)) + folder = invService.QueryFolder(folder); + if (folder == null) { m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give"); return; } - // Get folder info - // - InventoryFolderImpl folderInfo = userInfo.RootFolder.FindFolder(folder.ID); - if (folderInfo == null) - { - m_log.Debug("[INVENTORY TRANSFER] Can't retrieve folder to give"); - return; - } - - user.ControllingClient.SendBulkUpdateInventory(folderInfo); + user.ControllingClient.SendBulkUpdateInventory(folder); - // This unelegant, slow kludge is to reload the folders and - // items. Since a folder give can transfer subfolders and - // items, this is the easiest way to pull that stuff in - // - userInfo.DropInventory(); - userInfo.FetchInventory(); + //// This unelegant, slow kludge is to reload the folders and + //// items. Since a folder give can transfer subfolders and + //// items, this is the easiest way to pull that stuff in + //// + //userInfo.DropInventory(); + //userInfo.FetchInventory(); // Deliver message // @@ -463,20 +456,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer item.ID = itemID; item.Owner = user.ControllingClient.AgentId; - // Fetch from database - // - if (!userInfo.QueryItem(item)) - { - m_log.Debug("[INVENTORY TRANSFER] Can't find item to give"); - return; - } - - // Get item info + // Fetch from service // - item = userInfo.RootFolder.FindItem(item.ID); + item = invService.QueryItem(item); if (item == null) { - m_log.Debug("[INVENTORY TRANSFER] Can't retrieve item to give"); + m_log.Debug("[INVENTORY TRANSFER] Can't find item to give"); return; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 551a7eb..49c0083 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -64,6 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory Dictionary folders = m_Connector.GetSystemFolders(presence.UUID); m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}", presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count); + if (folders.Count > 0) lock (m_InventoryCache) m_InventoryCache.Add(presence.UUID, folders); -- cgit v1.1