diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 7849d88320..d0510d3da1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization;
using OpenSim.Framework.Serialization.External;
using OpenSim.Region.CoreModules.World.Archiver;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
@@ -75,6 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// The stream from which the inventory archive will be loaded.
///
private Stream m_loadStream;
+
+ ///
+ /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
+ /// after OSP resolution (since OSP creators are only stored in the item
+ ///
+ protected Dictionary m_creatorIdForAssetId = new Dictionary();
public InventoryArchiveReadRequest(
Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -420,6 +427,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// Reset folder ID to the one in which we want to load it
item.Folder = loadFolder.ID;
+ // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
+ // is loaded.
+ // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
+ // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
+ // relying on native tar tools.
+ m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
+
m_scene.AddInventoryItem(item);
return item;
@@ -448,18 +462,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
string extension = filename.Substring(i);
- string uuid = filename.Remove(filename.Length - extension.Length);
+ string rawUuid = filename.Remove(filename.Length - extension.Length);
+ UUID assetId = new UUID(rawUuid);
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
{
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
if (assetType == (sbyte)AssetType.Unknown)
- m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid);
+ {
+ m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
+ }
+ else if (assetType == (sbyte)AssetType.Object)
+ {
+ if (m_creatorIdForAssetId.ContainsKey(assetId))
+ {
+ string xmlData = Utils.BytesToString(data);
+ SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
+ foreach (SceneObjectPart sop in sog.Parts)
+ {
+ if (sop.CreatorData == null || sop.CreatorData == "")
+ {
+ sop.CreatorID = m_creatorIdForAssetId[assetId];
+ }
+ }
+
+ data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
+ }
+ }
//m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
- AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString());
+ AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
asset.Data = data;
m_scene.AssetService.Store(asset);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 3eb4104e73..5065227967 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -207,11 +207,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID),
"Loaded item owner doesn't match inventory reciever");
-// AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString());
-// string xmlData = Utils.BytesToString(asset1.Data);
-// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
-//
-// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID.ToString()));
+ AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString());
+ string xmlData = Utils.BytesToString(asset1.Data);
+ SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
+
+ Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID));
}
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 67e59c6564..fa404c01bd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1089,9 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes
public Dictionary GetScriptStates()
{
+ Dictionary ret = new Dictionary();
+
+ if (m_part.ParentGroup.Scene == null) // Group not in a scene
+ return ret;
+
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces();
-
- Dictionary ret = new Dictionary();
+
if (engines == null) // No engine at all
return ret;