From 89945f8829dcc1ee889aad1bafd1d6c2938a6cc7 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 31 Oct 2013 13:02:57 +0200 Subject: [PATCH] Refactored: ExternalRepresentationUtils should be the only place where the "CreatorData" field is calculated, to ensure uniformity Resolves http://opensimulator.org/mantis/view.php?id=6933 --- .../External/ExternalRepresentationUtils.cs | 16 +++++++++++++--- .../External/UserInventoryItemSerializer.cs | 3 ++- OpenSim/Framework/Util.cs | 9 +++++++-- .../Serialization/SceneObjectSerializer.cs | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index c56f21367f..db46ea8735 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -161,7 +161,7 @@ namespace OpenSim.Framework.Serialization.External if (!hasCreatorData && creator != null) { XmlElement creatorData = doc.CreateElement("CreatorData"); - creatorData.InnerText = homeURL + ";" + creator.FirstName + " " + creator.LastName; + creatorData.InnerText = CalcCreatorData(homeURL, creator.FirstName + " " + creator.LastName); sop.AppendChild(creatorData); } } @@ -172,5 +172,15 @@ namespace OpenSim.Framework.Serialization.External return wr.ToString(); } } + + public static string CalcCreatorData(string homeURL, string name) + { + return homeURL + ";" + name; + } + + internal static string CalcCreatorData(string homeURL, UUID uuid, string name) + { + return homeURL + "/" + uuid + ";" + name; + } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index f2a6b8b87a..135cefb616 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs @@ -286,7 +286,8 @@ namespace OpenSim.Framework.Serialization.External UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid); if (account != null) { - writer.WriteElementString("CreatorData", (string)options["home"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName); + string creatorData = ExternalRepresentationUtils.CalcCreatorData((string)options["home"], inventoryItem.CreatorIdAsUuid, account.FirstName + " " + account.LastName); + writer.WriteElementString("CreatorData", creatorData); } writer.WriteElementString("CreatorID", inventoryItem.CreatorId); } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5805dc8389..c2c96981bb 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2250,10 +2250,15 @@ namespace OpenSim.Framework { string[] parts = firstName.Split(new char[] { '.' }); if (parts.Length == 2) - return id.ToString() + ";" + agentsURI + ";" + parts[0] + " " + parts[1]; + return CalcUniversalIdentifier(id, agentsURI, parts[0] + " " + parts[1]); } - return id.ToString() + ";" + agentsURI + ";" + firstName + " " + lastName; + + return CalcUniversalIdentifier(id, agentsURI, firstName + " " + lastName); + } + private static string CalcUniversalIdentifier(UUID id, string agentsURI, string name) + { + return id.ToString() + ";" + agentsURI + ";" + name; } /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index f07dee959a..4deca006f2 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1230,7 +1230,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (m_UserManagement == null) m_UserManagement = sop.ParentGroup.Scene.RequestModuleInterface(); string name = m_UserManagement.GetUserName(sop.CreatorID); - writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name); + writer.WriteElementString("CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options["home"], name)); } WriteUUID(writer, "FolderID", sop.FolderID, options); @@ -1403,7 +1403,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (m_UserManagement == null) m_UserManagement = scene.RequestModuleInterface(); string name = m_UserManagement.GetUserName(item.CreatorID); - writer.WriteElementString("CreatorData", (string)options["home"] + ";" + name); + writer.WriteElementString("CreatorData", ExternalRepresentationUtils.CalcCreatorData((string)options["home"], name)); } writer.WriteElementString("Description", item.Description);