From f8e0653e73932bae20f483e0ce669f1623c6ff1e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 5 May 2009 16:45:21 +0000 Subject: * If an item creator id contains an iar loaded name, create a temporary profile and hashed UUID to represent the user --- .../CreateCommsManager/CreateCommsManagerPlugin.cs | 40 +++------------------- .../Osp/OspInventoryWrapperPlugin.cs | 25 +++++++++----- .../Framework/Communications/Osp/OspResolver.cs | 19 +++++----- OpenSim/Framework/InventoryItemBase.cs | 32 +++++++---------- .../Hypergrid/HGCommunicationsStandalone.cs | 18 +++++++++- .../Communications/Local/CommunicationsLocal.cs | 23 ++++++++++--- .../Archiver/InventoryArchiveReadRequest.cs | 6 ++-- .../Archiver/Tests/InventoryArchiverTests.cs | 9 +++-- 8 files changed, 86 insertions(+), 86 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 3ad137e..1059338 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs @@ -166,26 +166,10 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager /// protected virtual void InitialiseStandaloneServices(LibraryRootFolder libraryRootFolder) { - LocalInventoryService inventoryService = new LocalInventoryService(); - List plugins - = DataPluginFactory.LoadDataPlugins( - m_openSim.ConfigurationSettings.StandaloneInventoryPlugin, - m_openSim.ConfigurationSettings.StandaloneInventorySource); - - foreach (IInventoryDataPlugin plugin in plugins) - { - // Using the OSP wrapper plugin for database plugins should be made configurable at some point - inventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin)); - } - - LocalBackEndServices backendService = new LocalBackEndServices(); - - //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); - m_commsManager = new CommunicationsLocal( m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, - inventoryService, backendService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); + libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); CreateGridInfoService(); } @@ -202,22 +186,7 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager } protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) - { - // Standalone mode - - HGInventoryServiceClient inventoryService - = new HGInventoryServiceClient(m_openSim.NetServersInfo.InventoryURL, null, false); - List plugins - = DataPluginFactory.LoadDataPlugins( - m_openSim.ConfigurationSettings.StandaloneInventoryPlugin, - m_openSim.ConfigurationSettings.StandaloneInventorySource); - - foreach (IInventoryDataPlugin plugin in plugins) - { - // Using the OSP wrapper plugin should be made configurable at some point - inventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin)); - } - + { HGGridServicesStandalone gridService = new HGGridServicesStandalone( m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, m_openSim.SceneManager); @@ -225,10 +194,9 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager m_commsManager = new HGCommunicationsStandalone( m_openSim.ConfigurationSettings, m_openSim.NetServersInfo, m_httpServer, m_openSim.AssetCache, - inventoryService, gridService, + gridService, libraryRootFolder, m_openSim.ConfigurationSettings.DumpAssetsToFile); - - inventoryService.UserProfileCache = m_commsManager.UserProfileCacheService; + HGServices = gridService; CreateGridInfoService(); diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs index 3a692ae..95ef484 100644 --- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs +++ b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs @@ -37,10 +37,12 @@ namespace OpenSim.Framework.Communications.Osp public class OspInventoryWrapperPlugin : IInventoryDataPlugin { protected IInventoryDataPlugin m_wrappedPlugin; + protected CommunicationsManager m_commsManager; - public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin) + public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, CommunicationsManager commsManager) { m_wrappedPlugin = wrappedPlugin; + m_commsManager = commsManager; } public string Name { get { return "OspInventoryWrapperPlugin"; } } @@ -51,24 +53,23 @@ namespace OpenSim.Framework.Communications.Osp public InventoryItemBase getInventoryItem(UUID item) { - return m_wrappedPlugin.getInventoryItem(item); - - // TODO: Need to post process here + return PostProcessItem(m_wrappedPlugin.getInventoryItem(item)); } // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem? public InventoryItemBase queryInventoryItem(UUID item) { - return m_wrappedPlugin.queryInventoryItem(item); - - // TODO: Need to post process here + return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item)); } public List getInventoryInFolder(UUID folderID) { - return m_wrappedPlugin.getInventoryInFolder(folderID); + List items = m_wrappedPlugin.getInventoryInFolder(folderID); - // TODO: Need to post process here + foreach (InventoryItemBase item in items) + PostProcessItem(item); + + return items; } public List fetchActiveGestures(UUID avatarID) @@ -77,6 +78,12 @@ namespace OpenSim.Framework.Communications.Osp // Presuming that no post processing is needed here as gestures don't refer to creator information (?) } + + protected InventoryItemBase PostProcessItem(InventoryItemBase item) + { + item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + return item; + } public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); } public List getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); } diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index a62e1c0..579b3df 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -85,16 +85,15 @@ namespace OpenSim.Framework.Communications.Osp /// /// /// - /// A suitable internal OpenSim identifier. If the input string wasn't ospi data, then we simply - /// return that same string. If the input string was ospi data but no valid profile information has been found, - /// then returns null. + /// A suitable UUID for use in Second Life client communication. If the string was not a valid ospa, then UUID.Zero + /// is returned. /// - public static string ResolveOspa(string ospa, CommunicationsManager commsManager) + public static UUID ResolveOspa(string ospa, CommunicationsManager commsManager) { m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); if (!ospa.StartsWith(OSPA_PREFIX)) - return ospa; + return UUID.Zero; string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); @@ -116,7 +115,7 @@ namespace OpenSim.Framework.Communications.Osp return ResolveOspaName(value, commsManager); } - return null; + return UUID.Zero; } /// @@ -138,14 +137,14 @@ namespace OpenSim.Framework.Communications.Osp /// /// An OpenSim internal identifier for the name given. Returns null if the name was not valid /// - protected static string ResolveOspaName(string name, CommunicationsManager commsManager) + protected static UUID ResolveOspaName(string name, CommunicationsManager commsManager) { int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR); if (nameSeparatorIndex < 0) { m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name); - return null; + return UUID.Zero; } string firstName = name.Remove(nameSeparatorIndex).TrimEnd(); @@ -153,7 +152,7 @@ namespace OpenSim.Framework.Communications.Osp CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (userInfo != null) - return userInfo.UserProfile.ID.ToString(); + return userInfo.UserProfile.ID; UserProfileData tempUserProfile = new UserProfileData(); tempUserProfile.FirstName = firstName; @@ -164,7 +163,7 @@ namespace OpenSim.Framework.Communications.Osp "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID); commsManager.UserService.AddTemporaryUserProfile(tempUserProfile); - return tempUserProfile.ID.ToString(); + return tempUserProfile.ID; } } } diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 61771ab..f874de1 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -48,38 +48,30 @@ namespace OpenSim.Framework /// /// The creator of this item /// - public string CreatorId - { - get { return m_creatorId; } - set - { - m_creatorId = value; - UUID creatorIdAsUuid; - - // For now, all IDs are UUIDs - UUID.TryParse(m_creatorId, out creatorIdAsUuid); - CreatorIdAsUuid = creatorIdAsUuid; - } - } - - private string m_creatorId = String.Empty; + public string CreatorId { get; set; } /// - /// The creator of this item expressed as a UUID + /// The creator of this item expressed as a UUID. Database plugins don't need to set this, it will be set by + /// upstream code (or set by the get accessor if left unset). /// - public UUID CreatorIdAsUuid + public UUID CreatorIdAsUuid { get { + if (UUID.Zero == m_creatorIdAsUuid) + { + UUID.TryParse(CreatorId, out m_creatorIdAsUuid); + } + return m_creatorIdAsUuid; } + set { m_creatorIdAsUuid = value; } - } - - private UUID m_creatorIdAsUuid = UUID.Zero; + } + protected UUID m_creatorIdAsUuid = UUID.Zero; /// /// The description of the inventory item (must be less than 64 characters) diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index f5789b7..5c2fe33 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -25,9 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Communications.Local; @@ -42,7 +45,6 @@ namespace OpenSim.Region.Communications.Hypergrid NetworkServersInfo serversInfo, BaseHttpServer httpServer, IAssetCache assetCache, - LocalInventoryService inventoryService, HGGridServices gridService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) @@ -52,10 +54,24 @@ namespace OpenSim.Region.Communications.Hypergrid new LocalUserServices( serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this); localUserService.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource); + + HGInventoryServiceClient inventoryService + = new HGInventoryServiceClient(serversInfo.InventoryURL, null, false); + List plugins + = DataPluginFactory.LoadDataPlugins( + configSettings.StandaloneInventoryPlugin, + configSettings.StandaloneInventorySource); + + foreach (IInventoryDataPlugin plugin in plugins) + { + // Using the OSP wrapper plugin should be made configurable at some point + inventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); + } AddInventoryService(inventoryService); m_defaultInventoryHost = inventoryService.Host; m_interServiceInventoryService = inventoryService; + inventoryService.UserProfileCache = UserProfileCacheService; m_assetCache = assetCache; // Let's swap to always be secure access to inventory diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index acb7496..60feee1 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -25,9 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using OpenSim.Data; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Region.Communications.Local @@ -39,12 +42,22 @@ namespace OpenSim.Region.Communications.Local NetworkServersInfo serversInfo, BaseHttpServer httpServer, IAssetCache assetCache, - LocalInventoryService inventoryService, - IGridServices gridService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) : base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder) { + LocalInventoryService inventoryService = new LocalInventoryService(); + List plugins + = DataPluginFactory.LoadDataPlugins( + configSettings.StandaloneInventoryPlugin, + configSettings.StandaloneInventorySource); + + foreach (IInventoryDataPlugin plugin in plugins) + { + // Using the OSP wrapper plugin for database plugins should be made configurable at some point + inventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); + } + AddInventoryService(inventoryService); m_defaultInventoryHost = inventoryService.Host; m_interServiceInventoryService = inventoryService; @@ -58,8 +71,10 @@ namespace OpenSim.Region.Communications.Local m_userAdminService = lus; m_avatarService = lus; m_messageService = lus; - - m_gridService = gridService; + + m_gridService = new LocalBackEndServices(); + + //LocalLoginService loginService = CreateLoginService(libraryRootFolder, inventoryService, userService, backendService); } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index bf3097a..b0c1d0b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -157,9 +157,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't use the item ID that's in the file item.ID = UUID.Random(); - string ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); - if (null != ospResolvedId) - item.CreatorId = ospResolvedId; + UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); + if (UUID.Zero != ospResolvedId) + item.CreatorIdAsUuid = ospResolvedId; item.Owner = m_userInfo.UserProfile.ID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 274e329..4c6045a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -253,7 +253,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); - Assert.That(foundItem.CreatorId, Is.EqualTo(user2Uuid.ToString())); + Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); + Assert.That(foundItem.CreatorIdAsUuid, Is.EqualTo(user2Uuid)); Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); @@ -321,8 +322,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); - Assert.That(foundItem.CreatorId, Is.EqualTo(user2Profile.ID.ToString())); - Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); + Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); + Assert.That( + foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); + Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); } -- cgit v1.1