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 --- .../Osp/OspInventoryWrapperPlugin.cs | 25 ++++++++++++++-------- .../Framework/Communications/Osp/OspResolver.cs | 19 ++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework/Communications/Osp') 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; } } } -- cgit v1.1