From a61cbab799886e43749bc4d0803e579fec000f4c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 4 May 2009 16:15:30 +0000 Subject: * Insert profile references for creators for items saved into iars --- OpenSim/Framework/Communications/OspResolver.cs | 21 +++++- OpenSim/Framework/InventoryItemBase.cs | 75 +++++++++------------- .../Archiver/InventoryArchiveReadRequest.cs | 2 +- .../Archiver/InventoryArchiveWriteRequest.cs | 13 ++-- 4 files changed, 59 insertions(+), 52 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index 924a4a9..073abf8 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -50,7 +50,22 @@ namespace OpenSim.Framework.Communications public const string OSPA_PAIR_SEPARATOR = "="; /// - /// Make an OSPA given an avatar name + /// Make an OSPA given a user UUID + /// + /// + /// + /// The OSPA. Null if a user with the given UUID could not be found. + public static string MakeOspa(UUID userId, CommunicationsManager commsManager) + { + CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + if (userInfo != null) + return MakeOspa(userInfo.UserProfile.FirstName, userInfo.UserProfile.SurName); + + return null; + } + + /// + /// Make an OSPA given a user name /// /// /// @@ -58,7 +73,7 @@ namespace OpenSim.Framework.Communications { return OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - } + } /// /// Resolve an osp string into the most suitable internal OpenSim identifier. @@ -74,7 +89,7 @@ namespace OpenSim.Framework.Communications /// return that same string. If the input string was ospi data but no valid profile information has been found, /// then returns null. /// - public static string Resolve(string ospa, CommunicationsManager commsManager) + public static string ResolveOspa(string ospa, CommunicationsManager commsManager) { m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index b14ce7f..29142af 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -35,14 +35,14 @@ namespace OpenSim.Framework /// public class InventoryItemBase : InventoryNodeBase, ICloneable { - /// + /// /// The inventory type of the item. This is slightly different from the asset type in some situations. - /// + /// public int InvType; - /// + /// /// The folder this item is contained in - /// + /// public UUID Folder; /// @@ -69,9 +69,9 @@ namespace OpenSim.Framework /// public UUID CreatorIdAsUuid { get; private set; } - /// + /// /// The description of the inventory item (must be less than 64 characters) - /// + /// public string Description = String.Empty; /// @@ -79,80 +79,69 @@ namespace OpenSim.Framework /// public uint NextPermissions; - /// + /// /// A mask containing permissions for the current owner (cannot be enforced) - /// + /// public uint CurrentPermissions; - /// + /// /// - /// + /// public uint BasePermissions; - /// + /// /// - /// + /// public uint EveryOnePermissions; - /// + /// /// - /// + /// public uint GroupPermissions; - /// + /// /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc) - /// + /// public int AssetType; - /// + /// /// The UUID of the associated asset on the asset server - /// + /// public UUID AssetID; - /// + /// /// - /// + /// public UUID GroupID; - /// + /// /// - /// + /// public bool GroupOwned; - /// + /// /// - /// + /// public int SalePrice; - /// + /// /// - /// + /// public byte SaleType; - /// + /// /// - /// + /// public uint Flags; - /// + /// /// - /// - public int CreationDate; - - public InventoryItemBase() - { - CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - } + /// + public int CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; public object Clone() { - InventoryItemBase clone = new InventoryItemBase(); - clone.AssetID = AssetID; - clone.AssetType = AssetType; - clone.BasePermissions = BasePermissions; - clone.CreationDate = CreationDate; - clone.CreatorId = CreatorId; - + return MemberwiseClone(); } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 75e39d1..d9c154a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -156,7 +156,7 @@ 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.Resolve(item.CreatorId, m_commsManager); + string ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); if (null != ospResolvedId) item.CreatorId = ospResolvedId; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 0144136..4747f1f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -125,13 +125,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); - string serialization = UserInventoryItemSerializer.Serialize(inventoryItem); - m_archive.WriteFile(filename, serialization); - // Record the creator of this item for user record purposes (which might go away soon) m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; - - m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); + + InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); + saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_module.CommsManager); + + string serialization = UserInventoryItemSerializer.Serialize(saveItem); + m_archive.WriteFile(filename, serialization); + + m_assetGatherer.GatherAssetUuids(saveItem.AssetID, (AssetType)saveItem.AssetType, m_assetUuids); } /// -- cgit v1.1