From f86c438653fc3c8356a8f0c43a055b1928183f02 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Mon, 29 Nov 2010 08:43:33 -0800
Subject: Preservation of creator information now also working in IARs. Cleaned
up usage help. Moved Osp around, deleted unnecessary
OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in
a generic ExternalRepresentationUtils function.
---
.../Osp/OspInventoryWrapperPlugin.cs | 104 ------------
.../Framework/Communications/Osp/OspResolver.cs | 177 ---------------------
.../External/ExternalRepresentationUtils.cs | 87 ++++++++++
.../Serialization/External/OspResolver.cs | 177 +++++++++++++++++++++
.../External/UserInventoryItemSerializer.cs | 39 ++++-
OpenSim/Framework/Util.cs | 20 +++
OpenSim/Region/Application/OpenSim.cs | 6 +-
.../Archiver/InventoryArchiveReadRequest.cs | 11 +-
.../Archiver/InventoryArchiveWriteRequest.cs | 28 ++--
.../Inventory/Archiver/InventoryArchiverModule.cs | 54 +++++--
.../Archiver/Tests/InventoryArchiverTests.cs | 5 +-
.../InventoryAccess/InventoryAccessModule.cs | 10 +-
.../Archiver/ArchiveWriteRequestPreparation.cs | 11 +-
.../CoreModules/World/Archiver/AssetsRequest.cs | 26 ++-
.../Scenes/Serialization/SceneObjectSerializer.cs | 42 ++---
.../Services/HypergridService/HGAssetService.cs | 44 +----
.../Services/HypergridService/UserAccountCache.cs | 105 ++++++++++++
prebuild.xml | 59 +++----
18 files changed, 566 insertions(+), 439 deletions(-)
delete mode 100644 OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
delete mode 100644 OpenSim/Framework/Communications/Osp/OspResolver.cs
create mode 100644 OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
create mode 100644 OpenSim/Framework/Serialization/External/OspResolver.cs
create mode 100644 OpenSim/Services/HypergridService/UserAccountCache.cs
diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
deleted file mode 100644
index bcd1eee..0000000
--- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.Collections.Generic;
-using OpenSim.Data;
-using OpenMetaverse;
-using OpenSim.Services.Interfaces;
-
-namespace OpenSim.Framework.Communications.Osp
-{
- ///
- /// Wrap other inventory data plugins so that we can perform OSP related post processing for items
- ///
- public class OspInventoryWrapperPlugin : IInventoryDataPlugin
- {
- protected IInventoryDataPlugin m_wrappedPlugin;
- //protected CommunicationsManager m_commsManager;
- protected IUserAccountService m_userAccountService;
-
- public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService)
- {
- m_wrappedPlugin = wrappedPlugin;
- m_userAccountService = userService;
- }
-
- public string Name { get { return "OspInventoryWrapperPlugin"; } }
- public string Version { get { return "0.1"; } }
- public void Initialise() {}
- public void Initialise(string connect) {}
- public void Dispose() {}
-
- public InventoryItemBase getInventoryItem(UUID item)
- {
- 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 PostProcessItem(m_wrappedPlugin.queryInventoryItem(item));
- }
-
- public List getInventoryInFolder(UUID folderID)
- {
- List items = m_wrappedPlugin.getInventoryInFolder(folderID);
-
- foreach (InventoryItemBase item in items)
- PostProcessItem(item);
-
- return items;
- }
-
- public List fetchActiveGestures(UUID avatarID)
- {
- return m_wrappedPlugin.fetchActiveGestures(avatarID);
-
- // 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_userAccountService);
- return item;
- }
-
- public List getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); }
- public List getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); }
- public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); }
- public List getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); }
- public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); }
- public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); }
- public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); }
- public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); }
- public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); }
- public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); }
- public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); }
- public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); }
- public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); }
- }
-}
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs
deleted file mode 100644
index 24ea64d..0000000
--- a/OpenSim/Framework/Communications/Osp/OspResolver.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.Reflection;
-using System.Text;
-using log4net;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Services.Interfaces;
-
-namespace OpenSim.Framework.Communications.Osp
-{
- ///
- /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for
- /// identifying user profiles or supplying a simple name if no profile is available.
- ///
- public class OspResolver
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- public const string OSPA_PREFIX = "ospa:";
- public const string OSPA_NAME_KEY = "n";
- public const string OSPA_NAME_VALUE_SEPARATOR = " ";
- public const string OSPA_TUPLE_SEPARATOR = "|";
- public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray();
- public const string OSPA_PAIR_SEPARATOR = "=";
-
- ///
- /// 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, IUserAccountService userService)
- {
- UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
- if (account != null)
- return MakeOspa(account.FirstName, account.LastName);
-
- return null;
- }
-
- ///
- /// Make an OSPA given a user name
- ///
- ///
- ///
- public static string MakeOspa(string firstName, string lastName)
- {
- 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.
- ///
- ///
- /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may
- /// just return the same identifier after creating a temporary profile.
- ///
- ///
- ///
- ///
- /// 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 UUID ResolveOspa(string ospa, IUserAccountService userService)
- {
- if (!ospa.StartsWith(OSPA_PREFIX))
- return UUID.Zero;
-
-// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa);
-
- string ospaMeat = ospa.Substring(OSPA_PREFIX.Length);
- string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY);
-
- foreach (string tuple in ospaTuples)
- {
- int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR);
-
- if (tupleSeparatorIndex < 0)
- {
- m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa);
- continue;
- }
-
- string key = tuple.Remove(tupleSeparatorIndex).Trim();
- string value = tuple.Substring(tupleSeparatorIndex + 1).Trim();
-
- if (OSPA_NAME_KEY == key)
- return ResolveOspaName(value, userService);
- }
-
- return UUID.Zero;
- }
-
- ///
- /// Hash a profile name into a UUID
- ///
- ///
- ///
- public static UUID HashName(string name)
- {
- return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0);
- }
-
- ///
- /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile
- /// then a temporary user profile is inserted in the cache.
- ///
- ///
- ///
- ///
- /// An OpenSim internal identifier for the name given. Returns null if the name was not valid
- ///
- protected static UUID ResolveOspaName(string name, IUserAccountService userService)
- {
- if (userService == null)
- return UUID.Zero;
-
- int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR);
-
- if (nameSeparatorIndex < 0)
- {
- m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name);
- return UUID.Zero;
- }
-
- string firstName = name.Remove(nameSeparatorIndex).TrimEnd();
- string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart();
-
- UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
- if (account != null)
- return account.PrincipalID;
-
- // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
- /*
- UserProfileData tempUserProfile = new UserProfileData();
- tempUserProfile.FirstName = firstName;
- tempUserProfile.SurName = lastName;
- tempUserProfile.ID = HashName(tempUserProfile.Name);
-
- m_log.DebugFormat(
- "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID);
- commsManager.UserService.AddTemporaryUserProfile(tempUserProfile);
-
- return tempUserProfile.ID;
- */
-
- return UUID.Zero;
- }
- }
-}
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
new file mode 100644
index 0000000..5c0630c
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml;
+
+using OpenMetaverse;
+using OpenSim.Services.Interfaces;
+
+namespace OpenSim.Framework.Serialization.External
+{
+ public class ExternalRepresentationUtils
+ {
+ public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID)
+ {
+ if (xml == string.Empty || profileURL == string.Empty || userService == null)
+ return xml;
+
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(xml);
+ XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
+
+ foreach (XmlNode sop in sops)
+ {
+ UserAccount creator = null;
+ bool hasCreatorData = false;
+ XmlNodeList nodes = sop.ChildNodes;
+ foreach (XmlNode node in nodes)
+ {
+ if (node.Name == "CreatorID")
+ {
+ UUID uuid = UUID.Zero;
+ UUID.TryParse(node.InnerText, out uuid);
+ creator = userService.GetUserAccount(scopeID, uuid);
+ }
+ if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
+ hasCreatorData = true;
+
+ //if (node.Name == "OwnerID")
+ //{
+ // UserAccount owner = GetUser(node.InnerText);
+ // if (owner != null)
+ // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
+ //}
+ }
+ if (!hasCreatorData && creator != null)
+ {
+ XmlElement creatorData = doc.CreateElement("CreatorData");
+ creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
+ sop.AppendChild(creatorData);
+ }
+ }
+
+ using (StringWriter wr = new StringWriter())
+ {
+ doc.Save(wr);
+ return wr.ToString();
+ }
+
+ }
+ }
+}
diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
new file mode 100644
index 0000000..53c35ff
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.Reflection;
+using System.Text;
+using log4net;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Services.Interfaces;
+
+namespace OpenSim.Framework.Serialization
+{
+ ///
+ /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for
+ /// identifying user profiles or supplying a simple name if no profile is available.
+ ///
+ public class OspResolver
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public const string OSPA_PREFIX = "ospa:";
+ public const string OSPA_NAME_KEY = "n";
+ public const string OSPA_NAME_VALUE_SEPARATOR = " ";
+ public const string OSPA_TUPLE_SEPARATOR = "|";
+ public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray();
+ public const string OSPA_PAIR_SEPARATOR = "=";
+
+ ///
+ /// 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, IUserAccountService userService)
+ {
+ UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
+ if (account != null)
+ return MakeOspa(account.FirstName, account.LastName);
+
+ return null;
+ }
+
+ ///
+ /// Make an OSPA given a user name
+ ///
+ ///
+ ///
+ public static string MakeOspa(string firstName, string lastName)
+ {
+ 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.
+ ///
+ ///
+ /// In some cases this will be a UUID if a suitable profile exists on the system. In other cases, this may
+ /// just return the same identifier after creating a temporary profile.
+ ///
+ ///
+ ///
+ ///
+ /// 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 UUID ResolveOspa(string ospa, IUserAccountService userService)
+ {
+ if (!ospa.StartsWith(OSPA_PREFIX))
+ return UUID.Zero;
+
+// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa);
+
+ string ospaMeat = ospa.Substring(OSPA_PREFIX.Length);
+ string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY);
+
+ foreach (string tuple in ospaTuples)
+ {
+ int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR);
+
+ if (tupleSeparatorIndex < 0)
+ {
+ m_log.WarnFormat("[OSP RESOLVER]: Ignoring non-tuple component {0} in OSPA {1}", tuple, ospa);
+ continue;
+ }
+
+ string key = tuple.Remove(tupleSeparatorIndex).Trim();
+ string value = tuple.Substring(tupleSeparatorIndex + 1).Trim();
+
+ if (OSPA_NAME_KEY == key)
+ return ResolveOspaName(value, userService);
+ }
+
+ return UUID.Zero;
+ }
+
+ ///
+ /// Hash a profile name into a UUID
+ ///
+ ///
+ ///
+ public static UUID HashName(string name)
+ {
+ return new UUID(Utils.MD5(Encoding.Unicode.GetBytes(name)), 0);
+ }
+
+ ///
+ /// Resolve an OSPI name by querying existing persistent user profiles. If there is no persistent user profile
+ /// then a temporary user profile is inserted in the cache.
+ ///
+ ///
+ ///
+ ///
+ /// An OpenSim internal identifier for the name given. Returns null if the name was not valid
+ ///
+ protected static UUID ResolveOspaName(string name, IUserAccountService userService)
+ {
+ if (userService == null)
+ return UUID.Zero;
+
+ int nameSeparatorIndex = name.IndexOf(OSPA_NAME_VALUE_SEPARATOR);
+
+ if (nameSeparatorIndex < 0)
+ {
+ m_log.WarnFormat("[OSP RESOLVER]: Ignoring unseparated name {0}", name);
+ return UUID.Zero;
+ }
+
+ string firstName = name.Remove(nameSeparatorIndex).TrimEnd();
+ string lastName = name.Substring(nameSeparatorIndex + 1).TrimStart();
+
+ UserAccount account = userService.GetUserAccount(UUID.Zero, firstName, lastName);
+ if (account != null)
+ return account.PrincipalID;
+
+ // XXX: Disable temporary user profile creation for now as implementation is incomplete - justincc
+ /*
+ UserProfileData tempUserProfile = new UserProfileData();
+ tempUserProfile.FirstName = firstName;
+ tempUserProfile.SurName = lastName;
+ tempUserProfile.ID = HashName(tempUserProfile.Name);
+
+ m_log.DebugFormat(
+ "[OSP RESOLVER]: Adding temporary user profile for {0} {1}", tempUserProfile.Name, tempUserProfile.ID);
+ commsManager.UserService.AddTemporaryUserProfile(tempUserProfile);
+
+ return tempUserProfile.ID;
+ */
+
+ return UUID.Zero;
+ }
+ }
+}
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index df9af32..d5e84c7 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -35,6 +35,7 @@ using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Services.Interfaces;
namespace OpenSim.Framework.Serialization.External
{
@@ -56,6 +57,8 @@ namespace OpenSim.Framework.Serialization.External
m_InventoryItemXmlProcessors.Add("ID", ProcessID);
m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType);
m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID);
+ m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID);
+ m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData);
m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate);
m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner);
m_InventoryItemXmlProcessors.Add("Description", ProcessDescription);
@@ -94,6 +97,12 @@ namespace OpenSim.Framework.Serialization.External
item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty);
}
+ private static void ProcessCreatorID(InventoryItemBase item, XmlTextReader reader)
+ {
+ // when it exists, this overrides the previous
+ item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty);
+ }
+
private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader)
{
item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
@@ -161,12 +170,12 @@ namespace OpenSim.Framework.Serialization.External
private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader)
{
- //item.GroupOwned = reader.ReadElementContentAsBoolean("GroupOwned", String.Empty);
- // We don't do that, because ReadElementContentAsBoolean assumes lower case strings,
- // and they may not be lower case
- reader.ReadStartElement(); // GroupOwned
- item.GroupOwned = Boolean.Parse(reader.ReadContentAsString().ToLower());
- reader.ReadEndElement();
+ item.GroupOwned = Util.ReadBoolean(reader);
+ }
+
+ private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader)
+ {
+ item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty);
}
#endregion
@@ -231,7 +240,7 @@ namespace OpenSim.Framework.Serialization.External
}
- public static string Serialize(InventoryItemBase inventoryItem)
+ public static string Serialize(InventoryItemBase inventoryItem, Dictionary options, IUserAccountService userAccountService)
{
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
@@ -250,7 +259,7 @@ namespace OpenSim.Framework.Serialization.External
writer.WriteString(inventoryItem.InvType.ToString());
writer.WriteEndElement();
writer.WriteStartElement("CreatorUUID");
- writer.WriteString(inventoryItem.CreatorId);
+ writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService));
writer.WriteEndElement();
writer.WriteStartElement("CreationDate");
writer.WriteString(inventoryItem.CreationDate.ToString());
@@ -294,6 +303,20 @@ namespace OpenSim.Framework.Serialization.External
writer.WriteStartElement("GroupOwned");
writer.WriteString(inventoryItem.GroupOwned.ToString());
writer.WriteEndElement();
+ if (inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty)
+ writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
+ else if (options.ContainsKey("profile"))
+ {
+ if (userAccountService != null)
+ {
+ UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid);
+ if (account != null)
+ {
+ writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName);
+ }
+ writer.WriteElementString("CreatorID", inventoryItem.CreatorId);
+ }
+ }
writer.WriteEndElement();
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 101ece4..8d1671a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1558,6 +1558,16 @@ namespace OpenSim.Framework
return string.Empty;
}
+ #region Xml Serialization Utilities
+ public static bool ReadBoolean(XmlTextReader reader)
+ {
+ reader.ReadStartElement();
+ bool result = Boolean.Parse(reader.ReadContentAsString().ToLower());
+ reader.ReadEndElement();
+
+ return result;
+ }
+
public static UUID ReadUUID(XmlTextReader reader, string name)
{
UUID id;
@@ -1619,5 +1629,15 @@ namespace OpenSim.Framework
return quat;
}
+ public static T ReadEnum(XmlTextReader reader, string name)
+ {
+ string value = reader.ReadElementContentAsString(name, String.Empty);
+ // !!!!! to deal with flags without commas
+ if (value.Contains(" ") && !value.Contains(","))
+ value = value.Replace(" ", ", ");
+
+ return (T)Enum.Parse(typeof(T), value); ;
+ }
+ #endregion
}
}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6127c2d..ae2d836 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -265,10 +265,10 @@ namespace OpenSim
LoadOar);
m_console.Commands.AddCommand("region", false, "save oar",
- "save oar [-v|--version=N] [-p|--profile=url] []",
+ "save oar [-v|--version=] [-p|--profile=] []",
"Save a region's data to an OAR archive.",
- "-v|--version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
- + "-p|--profile=url adds the url of the profile service to the saved user information" + Environment.NewLine
+ "-v|--version= generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
+ + "-p|--profile= adds the url of the profile service to the saved user information" + Environment.NewLine
+ "The OAR path must be a filesystem path."
+ " If this is not given then the oar is saved to region.oar in the current directory.",
SaveOar);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 046b05f..870ead2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -37,12 +37,11 @@ using System.Xml.Linq;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Communications.Osp;
using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
using OpenSim.Region.CoreModules.World.Archiver;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
@@ -398,16 +397,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// Don't use the item ID that's in the file
item.ID = UUID.Random();
- UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
- if (UUID.Zero != ospResolvedId)
+ UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
+ if (UUID.Zero != ospResolvedId) // The user exists in this grid
{
item.CreatorIdAsUuid = ospResolvedId;
// XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
// database). Instead, replace with the UUID that we found.
item.CreatorId = ospResolvedId.ToString();
+
+ item.CreatorData = string.Empty;
}
- else
+ else if (item.CreatorData == null || item.CreatorData == String.Empty)
{
item.CreatorIdAsUuid = m_userInfo.PrincipalID;
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index d81703a..cab341d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -36,8 +36,6 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.World.Archiver;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
@@ -139,20 +137,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
}
- protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
+ protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary options, IUserAccountService userAccountService)
{
string filename = path + CreateArchiveItemName(inventoryItem);
// Record the creator of this item for user record purposes (which might go away soon)
m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
- InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone();
- saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
-
- string serialization = UserInventoryItemSerializer.Serialize(saveItem);
+ string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService);
m_archiveWriter.WriteFile(filename, serialization);
- m_assetGatherer.GatherAssetUuids(saveItem.AssetID, (AssetType)saveItem.AssetType, m_assetUuids);
+ m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids);
}
///
@@ -161,7 +156,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// The inventory folder to save
/// The path to which the folder should be saved
/// If true, save this folder itself. If false, only saves contents
- protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself)
+ protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, Dictionary options, IUserAccountService userAccountService)
{
if (saveThisFolderItself)
{
@@ -176,19 +171,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
foreach (InventoryFolderBase childFolder in contents.Folders)
{
- SaveInvFolder(childFolder, path, true);
+ SaveInvFolder(childFolder, path, true, options, userAccountService);
}
foreach (InventoryItemBase item in contents.Items)
{
- SaveInvItem(item, path);
+ SaveInvItem(item, path, options, userAccountService);
}
}
///
/// Execute the inventory write request
///
- public void Execute()
+ public void Execute(Dictionary options, IUserAccountService userAccountService)
{
try
{
@@ -266,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
//recurse through all dirs getting dirs and files
- SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly);
+ SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService);
}
else if (inventoryItem != null)
{
@@ -274,14 +269,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
inventoryItem.Name, inventoryItem.ID, m_invPath);
- SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
+ SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService);
}
// Don't put all this profile information into the archive right now.
//SaveUsers();
new AssetsRequest(
- new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute();
+ new AssetsArchiver(m_archiveWriter),
+ m_assetUuids, m_scene.AssetService,
+ m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
+ options, ReceivedAllAssets).Execute();
}
catch (Exception)
{
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 2eaca49..421ea30 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -75,6 +75,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
private Dictionary m_scenes = new Dictionary();
private Scene m_aScene;
+ private IUserAccountService m_UserAccountService;
+ protected IUserAccountService UserAccountService
+ {
+ get
+ {
+ if (m_UserAccountService == null)
+ // What a strange thing to do...
+ foreach (Scene s in m_scenes.Values)
+ {
+ m_UserAccountService = s.RequestModuleInterface();
+ break;
+ }
+
+ return m_UserAccountService;
+ }
+ }
+
+
public InventoryArchiverModule() {}
public InventoryArchiverModule(bool disablePresenceChecks)
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
scene.AddCommand(
this, "save iar",
- "save iar []",
+ "save iar [--p|-profile=] []",
"Save user inventory archive (IAR).",
" is the user's first name." + Environment.NewLine
+ " is the user's last name." + Environment.NewLine
+ " is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
+ + "-p|--profile= adds the url of the profile service to the saved user information." + Environment.NewLine
+ " is the filesystem path at which to save the IAR."
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
HandleSaveInvConsoleCommand);
@@ -157,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
try
{
- new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
+ new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService);
}
catch (EntryPointNotFoundException e)
{
@@ -197,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
try
{
- new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
+ new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService);
}
catch (EntryPointNotFoundException e)
{
@@ -368,10 +387,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
{
Guid id = Guid.NewGuid();
-
+
+ Dictionary options = new Dictionary();
+
+ OptionSet ops = new OptionSet();
+ //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
+ ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
+
+ List mainParams = ops.Parse(cmdparams);
+
try
{
- if (cmdparams.Length < 6)
+ if (mainParams.Count < 6)
{
m_log.Error(
"[INVENTORY ARCHIVER]: usage is save iar []");
@@ -379,18 +406,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
-
- string firstName = cmdparams[2];
- string lastName = cmdparams[3];
- string invPath = cmdparams[4];
- string pass = cmdparams[5];
- string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
+ if (options.ContainsKey("profile"))
+ m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -profile option if you want to produce a compatible IAR");
+
+ string firstName = mainParams[2];
+ string lastName = mainParams[3];
+ string invPath = mainParams[4];
+ string pass = mainParams[5];
+ string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
savePath, invPath, firstName, lastName);
- ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary());
+ ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
}
catch (InventoryArchiverException e)
{
@@ -518,5 +547,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return false;
}
+
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 938886b2..1e39c39 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -38,7 +38,6 @@ using OpenSim.Framework;
using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.Framework.Scenes;
@@ -103,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
- tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
+ tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary(), null));
tar.Close();
m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
}
@@ -551,7 +550,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
string item1FileName
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
- tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1));
+ tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary(), null));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 1ff1a47..1ebccd1 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -799,9 +799,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
{
IInventoryService invService = m_Scene.RequestModuleInterface();
- InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID);
- assetRequestItem = invService.GetItem(assetRequestItem);
- return assetRequestItem;
+ InventoryItemBase item = new InventoryItemBase(itemID, agentID);
+ item = invService.GetItem(item);
+
+ if (item.CreatorData != null && item.CreatorData != string.Empty)
+ UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData);
+
+ return item;
}
#endregion
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index b987b5a..0699407 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -190,7 +190,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
new AssetsRequest(
new AssetsArchiver(archiveWriter), assetUuids,
- m_scene.AssetService, awre.ReceivedAllAssets).Execute();
+ m_scene.AssetService, m_scene.UserAccountService,
+ m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
}
catch (Exception)
{
@@ -238,10 +239,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
- if (majorVersion == 1)
- {
- m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
- }
+ //if (majorVersion == 1)
+ //{
+ // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
+ //}
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index d4a09b4..5da1656 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -34,6 +34,7 @@ using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Serialization;
+using OpenSim.Framework.Serialization.External;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.World.Archiver
@@ -100,17 +101,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// Asset service used to request the assets
///
protected IAssetService m_assetService;
+ protected IUserAccountService m_userAccountService;
+ protected UUID m_scopeID; // the grid ID
protected AssetsArchiver m_assetsArchiver;
+ protected Dictionary m_options;
+
protected internal AssetsRequest(
AssetsArchiver assetsArchiver, IDictionary uuids,
- IAssetService assetService, AssetsRequestCallback assetsRequestCallback)
+ IAssetService assetService, IUserAccountService userService,
+ UUID scope, Dictionary options,
+ AssetsRequestCallback assetsRequestCallback)
{
m_assetsArchiver = assetsArchiver;
m_uuids = uuids;
m_assetsRequestCallback = assetsRequestCallback;
m_assetService = assetService;
+ m_userAccountService = userService;
+ m_scopeID = scope;
+ m_options = options;
m_repliesRequired = uuids.Count;
m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT);
@@ -241,7 +251,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
m_foundAssetUuids.Add(asset.FullID);
- m_assetsArchiver.WriteAsset(asset);
+
+ m_assetsArchiver.WriteAsset(PostProcess(asset));
}
else
{
@@ -288,5 +299,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
"[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
}
}
+
+ protected AssetBase PostProcess(AssetBase asset)
+ {
+ if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("profile"))
+ {
+ //m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID);
+ string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), m_options["profile"].ToString(), m_userAccountService, m_scopeID);
+ asset.Data = Utils.StringToBytes(xml);
+ }
+ return asset;
+ }
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index da25e80..6c9826f 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -409,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
#region SOPXmlProcessors
private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader)
{
- obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty);
+ obj.AllowedDrop = Util.ReadBoolean(reader);
}
private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
@@ -459,7 +459,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
{
- obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
+ obj.PassTouches = Util.ReadBoolean(reader);
}
private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader)
@@ -654,11 +654,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader)
{
- string value = reader.ReadElementContentAsString("Flags", String.Empty);
- // !!!!! to deal with flags without commas
- if (value.Contains(" ") && !value.Contains(","))
- value = value.Replace(" ", ", ");
- obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value);
+ obj.Flags = Util.ReadEnum(reader, "Flags");
}
private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
@@ -808,7 +804,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader)
{
- item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty);
+ item.OwnerChanged = Util.ReadBoolean(reader);
}
#endregion
@@ -932,20 +928,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader)
{
- string value = reader.ReadElementContentAsString("ProfileShape", String.Empty);
- // !!!!! to deal with flags without commas
- if (value.Contains(" ") && !value.Contains(","))
- value = value.Replace(" ", ", ");
- shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value);
+ shp.ProfileShape = Util.ReadEnum(reader, "ProfileShape");
}
private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader)
{
- string value = reader.ReadElementContentAsString("HollowShape", String.Empty);
- // !!!!! to deal with flags without commas
- if (value.Contains(" ") && !value.Contains(","))
- value = value.Replace(" ", ", ");
- shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value);
+ shp.HollowShape = Util.ReadEnum(reader, "HollowShape");
}
private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1045,17 +1033,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader)
{
- shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
+ shp.FlexiEntry = Util.ReadBoolean(reader);
}
private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader)
{
- shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
+ shp.LightEntry = Util.ReadBoolean(reader);
}
private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
{
- shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
+ shp.SculptEntry = Util.ReadBoolean(reader);
}
private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1220,16 +1208,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary options)
{
- // Older versions of serialization can't cope with commas
- if (options.ContainsKey("version"))
- {
- float version = 0.5F;
- float.TryParse(options["version"].ToString(), out version);
- if (version < 0.5)
- flagsStr = flagsStr.Replace(",", "");
- }
-
- writer.WriteElementString(name, flagsStr);
+ // Older versions of serialization can't cope with commas, so we eliminate the commas
+ writer.WriteElementString(name, flagsStr.Replace(",", ""));
}
static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary options, Scene scene)
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index 9b098a0..584ab6f 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -35,6 +35,7 @@ using log4net;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Framework.Serialization.External;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Services.AssetService;
@@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService
protected byte[] AdjustIdentifiers(byte[] data)
{
string xml = Utils.BytesToString(data);
- return Utils.StringToBytes(RewriteSOP(xml));
- }
-
- protected string RewriteSOP(string xml)
- {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(xml);
- XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
-
- foreach (XmlNode sop in sops)
- {
- UserAccount creator = null;
- bool hasCreatorData = false;
- XmlNodeList nodes = sop.ChildNodes;
- foreach (XmlNode node in nodes)
- {
- if (node.Name == "CreatorID")
- creator = m_Cache.GetUser(node.InnerText);
- if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
- hasCreatorData = true;
-
- //if (node.Name == "OwnerID")
- //{
- // UserAccount owner = GetUser(node.InnerText);
- // if (owner != null)
- // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
- //}
- }
- if (!hasCreatorData && creator != null)
- {
- XmlElement creatorData = doc.CreateElement("CreatorData");
- creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
- sop.AppendChild(creatorData);
- }
- }
-
- using (StringWriter wr = new StringWriter())
- {
- doc.Save(wr);
- return wr.ToString();
- }
-
+ return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
}
}
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
new file mode 100644
index 0000000..3e9aea1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+using log4net;
+using OpenMetaverse;
+
+using OpenSim.Services.Interfaces;
+
+namespace OpenSim.Services.HypergridService
+{
+ public class UserAccountCache : IUserAccountService
+ {
+ private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
+
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+ private ExpiringCache m_UUIDCache;
+
+ private IUserAccountService m_UserAccountService;
+
+ private static UserAccountCache m_Singleton;
+
+ public static UserAccountCache CreateUserAccountCache(IUserAccountService u)
+ {
+ if (m_Singleton == null)
+ m_Singleton = new UserAccountCache(u);
+
+ return m_Singleton;
+ }
+
+ private UserAccountCache(IUserAccountService u)
+ {
+ m_UUIDCache = new ExpiringCache();
+ m_UserAccountService = u;
+ }
+
+ public void Cache(UUID userID, UserAccount account)
+ {
+ // Cache even null accounts
+ m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
+
+ //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
+ }
+
+ public UserAccount Get(UUID userID, out bool inCache)
+ {
+ UserAccount account = null;
+ inCache = false;
+ if (m_UUIDCache.TryGetValue(userID, out account))
+ {
+ //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
+ inCache = true;
+ return account;
+ }
+
+ return null;
+ }
+
+ public UserAccount GetUser(string id)
+ {
+ UUID uuid = UUID.Zero;
+ UUID.TryParse(id, out uuid);
+ bool inCache = false;
+ UserAccount account = Get(uuid, out inCache);
+ if (!inCache)
+ {
+ account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid);
+ Cache(uuid, account);
+ }
+
+ return account;
+ }
+
+ #region IUserAccountService
+ public UserAccount GetUserAccount(UUID scopeID, UUID userID)
+ {
+ return GetUser(userID.ToString());
+ }
+
+ public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
+ {
+ return null;
+ }
+
+ public UserAccount GetUserAccount(UUID scopeID, string Email)
+ {
+ return null;
+ }
+
+ public List GetUserAccounts(UUID scopeID, string query)
+ {
+ return null;
+ }
+
+ public bool StoreUserAccount(UserAccount data)
+ {
+ return false;
+ }
+ #endregion
+
+ }
+
+}
diff --git a/prebuild.xml b/prebuild.xml
index 6f24bfc..9f2ef43 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -175,6 +175,34 @@
+
+
+
+ ../../../bin/
+
+
+
+
+ ../../../bin/
+
+
+
+ ../../../bin/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -194,6 +222,7 @@
+
@@ -631,35 +660,6 @@
-
-
-
- ../../../bin/
-
-
-
-
- ../../../bin/
-
-
-
- ../../../bin/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1253,6 +1253,7 @@
+
--
cgit v1.1