diff options
author | Justin Clark-Casey (justincc) | 2011-04-15 00:42:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-04-15 00:42:06 +0100 |
commit | a0d80140f2d0ad6dd63970a3a3d5c0da8320ae75 (patch) | |
tree | 4c1f6780b2f8c766f7af29e827d77269790a94e9 /OpenSim/Region | |
parent | implement stub TestLoadCoalesecedItem(). Doesn't do what it's meant to do yet. (diff) | |
download | opensim-SC-a0d80140f2d0ad6dd63970a3a3d5c0da8320ae75.zip opensim-SC-a0d80140f2d0ad6dd63970a3a3d5c0da8320ae75.tar.gz opensim-SC-a0d80140f2d0ad6dd63970a3a3d5c0da8320ae75.tar.bz2 opensim-SC-a0d80140f2d0ad6dd63970a3a3d5c0da8320ae75.tar.xz |
Make all the objects in a coalescence reappears after being loaded from an IAR. This still doesn't work proprerly since some required textures/contained item assets might be missing.
From pure code inspection, it looks like the uuid gatherer may get most asset uuids because the scene object serializer naively pulls non-root parts from all contained scene objects into one mega-object. However, root part uuids may well still be missing, and there may be other odd artifacts from this bug.
It appears that storing the size of the coalescence and the offsets is redundant, since one can work out this information from the position data already in the scene object groups.
Diffstat (limited to 'OpenSim/Region')
5 files changed, 90 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 01170aa..f3d2f26 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -471,16 +471,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
471 | if (m_creatorIdForAssetId.ContainsKey(assetId)) | 471 | if (m_creatorIdForAssetId.ContainsKey(assetId)) |
472 | { | 472 | { |
473 | string xmlData = Utils.BytesToString(data); | 473 | string xmlData = Utils.BytesToString(data); |
474 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 474 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
475 | foreach (SceneObjectPart sop in sog.Parts) | 475 | |
476 | CoalescedSceneObjects coa = null; | ||
477 | if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) | ||
478 | { | ||
479 | // m_log.DebugFormat( | ||
480 | // "[INVENTORY ARCHIVER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); | ||
481 | |||
482 | sceneObjects.AddRange(coa.Objects); | ||
483 | } | ||
484 | else | ||
476 | { | 485 | { |
477 | if (sop.CreatorData == null || sop.CreatorData == "") | 486 | sceneObjects.Add(SceneObjectSerializer.FromOriginalXmlFormat(xmlData)); |
478 | { | ||
479 | sop.CreatorID = m_creatorIdForAssetId[assetId]; | ||
480 | } | ||
481 | } | 487 | } |
482 | 488 | ||
483 | data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); | 489 | foreach (SceneObjectGroup sog in sceneObjects) |
490 | foreach (SceneObjectPart sop in sog.Parts) | ||
491 | if (sop.CreatorData == null || sop.CreatorData == "") | ||
492 | sop.CreatorID = m_creatorIdForAssetId[assetId]; | ||
493 | |||
494 | if (coa != null) | ||
495 | data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa)); | ||
496 | else | ||
497 | data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sceneObjects[0])); | ||
484 | } | 498 | } |
485 | } | 499 | } |
486 | 500 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index f2d050c..e2316f0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
143 | InventoryItemBase coaItem = new InventoryItemBase(); | 143 | InventoryItemBase coaItem = new InventoryItemBase(); |
144 | coaItem.Name = m_coaItemName; | 144 | coaItem.Name = m_coaItemName; |
145 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); | 145 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); |
146 | coaItem.AssetID = asset1.FullID; | 146 | coaItem.AssetID = coaAsset.FullID; |
147 | coaItem.GroupID = UUID.Random(); | 147 | coaItem.GroupID = UUID.Random(); |
148 | coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID; | 148 | coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID; |
149 | coaItem.Owner = m_uaLL1.PrincipalID; | 149 | coaItem.Owner = m_uaLL1.PrincipalID; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 0c4e364..f747c89 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -62,9 +62,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
62 | SerialiserModule serialiserModule = new SerialiserModule(); | 62 | SerialiserModule serialiserModule = new SerialiserModule(); |
63 | m_archiverModule = new InventoryArchiverModule(); | 63 | m_archiverModule = new InventoryArchiverModule(); |
64 | 64 | ||
65 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); | 65 | m_scene = SceneSetupHelpers.SetupScene("asset inventory"); |
66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | 66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
67 | } | 67 | } |
68 | |||
69 | [Test] | ||
70 | public void TestLoadCoalesecedItem() | ||
71 | { | ||
72 | TestHelper.InMethod(); | ||
73 | // log4net.Config.XmlConfigurator.Configure(); | ||
74 | |||
75 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password"); | ||
76 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); | ||
77 | |||
78 | InventoryItemBase coaItem | ||
79 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); | ||
80 | |||
81 | Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1"); | ||
82 | |||
83 | string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID); | ||
84 | |||
85 | CoalescedSceneObjects coa; | ||
86 | bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa); | ||
87 | |||
88 | Assert.That(readResult, Is.True); | ||
89 | |||
90 | // TODO: Check that the loaded coalesence is valid and that the required scene object assets are around | ||
91 | } | ||
68 | 92 | ||
69 | /// <summary> | 93 | /// <summary> |
70 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive | 94 | /// Test saving a single inventory item to a V0.1 OpenSim Inventory Archive |
@@ -257,22 +281,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
257 | 281 | ||
258 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); | 282 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); |
259 | } | 283 | } |
260 | |||
261 | [Test] | ||
262 | public void TestLoadCoalesecedItem() | ||
263 | { | ||
264 | TestHelper.InMethod(); | ||
265 | // log4net.Config.XmlConfigurator.Configure(); | ||
266 | |||
267 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "password"); | ||
268 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); | ||
269 | |||
270 | InventoryItemBase coaItem | ||
271 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName); | ||
272 | |||
273 | Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1"); | ||
274 | |||
275 | // TODO: Check that the loaded coalesence is valid and that the required scene object assets are around | ||
276 | } | ||
277 | } | 284 | } |
278 | } \ No newline at end of file | 285 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 1b3419d..51d1d59 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -195,6 +195,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
195 | 195 | ||
196 | public byte[] GetData(string id) | 196 | public byte[] GetData(string id) |
197 | { | 197 | { |
198 | // m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Requesting data for asset {0}", id); | ||
199 | |||
198 | AssetBase asset = m_Cache.Get(id); | 200 | AssetBase asset = m_Cache.Get(id); |
199 | 201 | ||
200 | if (asset != null) | 202 | if (asset != null) |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs index a0e120a..babcb54 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs | |||
@@ -55,11 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
55 | /// <param name="coa"></param> | 55 | /// <param name="coa"></param> |
56 | /// <returns></returns> | 56 | /// <returns></returns> |
57 | public static string ToXml(CoalescedSceneObjects coa) | 57 | public static string ToXml(CoalescedSceneObjects coa) |
58 | { | 58 | { |
59 | // TODO: Should probably return an empty xml serialization rather than a blank string | ||
60 | if (!coa.HasObjects) | ||
61 | return ""; | ||
62 | |||
63 | using (StringWriter sw = new StringWriter()) | 59 | using (StringWriter sw = new StringWriter()) |
64 | { | 60 | { |
65 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | 61 | using (XmlTextWriter writer = new XmlTextWriter(sw)) |
@@ -105,10 +101,49 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
105 | 101 | ||
106 | string output = sw.ToString(); | 102 | string output = sw.ToString(); |
107 | 103 | ||
108 | // m_log.Debug(output); | 104 | // Console.WriteLine(output); |
109 | 105 | ||
110 | return output; | 106 | return output; |
111 | } | 107 | } |
112 | } | 108 | } |
109 | |||
110 | public static bool TryFromXml(string xml, out CoalescedSceneObjects coa) | ||
111 | { | ||
112 | // m_log.DebugFormat("[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() deserializing {0}", xml); | ||
113 | |||
114 | coa = null; | ||
115 | |||
116 | using (StringReader sr = new StringReader(xml)) | ||
117 | { | ||
118 | using (XmlTextReader reader = new XmlTextReader(sr)) | ||
119 | { | ||
120 | reader.Read(); | ||
121 | if (reader.Name != "CoalescedObject") | ||
122 | { | ||
123 | // m_log.DebugFormat( | ||
124 | // "[COALESCED SCENE OBJECTS SERIALIZER]: TryFromXml() root element was {0} so returning false", | ||
125 | // reader.Name); | ||
126 | |||
127 | return false; | ||
128 | } | ||
129 | |||
130 | coa = new CoalescedSceneObjects(UUID.Zero); | ||
131 | reader.Read(); | ||
132 | |||
133 | while (reader.NodeType != XmlNodeType.EndElement && reader.Name != "CoalescedObject") | ||
134 | { | ||
135 | if (reader.Name == "SceneObjectGroup") | ||
136 | { | ||
137 | string soXml = reader.ReadOuterXml(); | ||
138 | coa.Add(SceneObjectSerializer.FromOriginalXmlFormat(soXml)); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | reader.ReadEndElement(); // CoalescedObject | ||
143 | } | ||
144 | } | ||
145 | |||
146 | return true; | ||
147 | } | ||
113 | } | 148 | } |
114 | } \ No newline at end of file | 149 | } \ No newline at end of file |