aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie2010-05-21 21:16:04 +0100
committerMelanie2010-05-21 21:16:04 +0100
commit297bcb5c3d462128c5c81f35aa7a574e567583d5 (patch)
treebe7744848c474a8241f1d1c0e1f0114cfb824e16 /OpenSim/Region/CoreModules
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-297bcb5c3d462128c5c81f35aa7a574e567583d5.zip
opensim-SC_OLD-297bcb5c3d462128c5c81f35aa7a574e567583d5.tar.gz
opensim-SC_OLD-297bcb5c3d462128c5c81f35aa7a574e567583d5.tar.bz2
opensim-SC_OLD-297bcb5c3d462128c5c81f35aa7a574e567583d5.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs64
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs69
5 files changed, 106 insertions, 42 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs
new file mode 100644
index 0000000..880bd7c
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework.Serialization;
30using OpenSim.Region.Framework.Scenes;
31
32namespace OpenSim.Region.CoreModules.World.Archiver
33{
34 /// <summary>
35 /// Helper methods for archive manipulation
36 /// </summary>
37 /// This is a separate class from ArchiveConstants because we need to bring in very OpenSim specific classes.
38 public static class ArchiveHelpers
39 {
40 /// <summary>
41 /// Create the filename used for objects in OpenSim Archives.
42 /// </summary>
43 /// <param name="objectName"></param>
44 /// <param name="uuid"></param>
45 /// <param name="pos"></param>
46 /// <returns></returns>
47 public static string CreateObjectFilename(SceneObjectGroup sog)
48 {
49 return ArchiveConstants.CreateOarObjectFilename(sog.Name, sog.UUID, sog.AbsolutePosition);
50 }
51
52 /// <summary>
53 /// Create the path used to store an object in an OpenSim Archive.
54 /// </summary>
55 /// <param name="objectName"></param>
56 /// <param name="uuid"></param>
57 /// <param name="pos"></param>
58 /// <returns></returns>
59 public static string CreateObjectPath(SceneObjectGroup sog)
60 {
61 return ArchiveConstants.CreateOarObjectPath(sog.Name, sog.UUID, sog.AbsolutePosition);
62 }
63 }
64} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index b37beab..9c8193a 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -38,7 +38,6 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Serialization; 39using OpenSim.Framework.Serialization;
40using OpenSim.Framework.Serialization.External; 40using OpenSim.Framework.Serialization.External;
41
42using OpenSim.Region.CoreModules.World.Terrain; 41using OpenSim.Region.CoreModules.World.Terrain;
43using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
@@ -244,7 +243,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
244 // to the same scene (when this is possible). 243 // to the same scene (when this is possible).
245 sceneObject.ResetIDs(); 244 sceneObject.ResetIDs();
246 245
247
248 foreach (SceneObjectPart part in sceneObject.Children.Values) 246 foreach (SceneObjectPart part in sceneObject.Children.Values)
249 { 247 {
250 if (!ResolveUserUuid(part.CreatorID)) 248 if (!ResolveUserUuid(part.CreatorID))
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index 9fc6ec4..586d98e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -145,17 +145,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
145 { 145 {
146 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); 146 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
147 147
148 Vector3 position = sceneObject.AbsolutePosition;
149
150 string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); 148 string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject);
151 string filename 149 m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject);
152 = string.Format(
153 "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml",
154 ArchiveConstants.OBJECTS_PATH, sceneObject.Name,
155 Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z),
156 sceneObject.UUID);
157
158 m_archiveWriter.WriteFile(filename, serializedObject);
159 } 150 }
160 151
161 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); 152 m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 4215f97..a1451ce 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
239 239
240 if (asset != null) 240 if (asset != null)
241 { 241 {
242// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as found", id); 242// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
243 m_foundAssetUuids.Add(asset.FullID); 243 m_foundAssetUuids.Add(asset.FullID);
244 m_assetsArchiver.WriteAsset(asset); 244 m_assetsArchiver.WriteAsset(asset);
245 } 245 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 624dc22..4d04af1 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Threading; 32using System.Threading;
@@ -33,8 +34,8 @@ using log4net.Config;
33using NUnit.Framework; 34using NUnit.Framework;
34using NUnit.Framework.SyntaxHelpers; 35using NUnit.Framework.SyntaxHelpers;
35using OpenMetaverse; 36using OpenMetaverse;
37using OpenMetaverse.Assets;
36using OpenSim.Framework; 38using OpenSim.Framework;
37
38using OpenSim.Framework.Serialization; 39using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 40using OpenSim.Framework.Serialization.External;
40using OpenSim.Region.CoreModules.World.Serialiser; 41using OpenSim.Region.CoreModules.World.Serialiser;
@@ -44,6 +45,9 @@ using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
46using OpenSim.Tests.Common.Setup; 47using OpenSim.Tests.Common.Setup;
48using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants;
49using TarArchiveReader = OpenSim.Framework.Serialization.TarArchiveReader;
50using TarArchiveWriter = OpenSim.Framework.Serialization.TarArchiveWriter;
47 51
48namespace OpenSim.Region.CoreModules.World.Archiver.Tests 52namespace OpenSim.Region.CoreModules.World.Archiver.Tests
49{ 53{
@@ -55,6 +59,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
55 59
56 protected TestScene m_scene; 60 protected TestScene m_scene;
57 protected ArchiverModule m_archiverModule; 61 protected ArchiverModule m_archiverModule;
62
63 protected TaskInventoryItem m_soundItem;
58 64
59 [SetUp] 65 [SetUp]
60 public void SetUp() 66 public void SetUp()
@@ -124,10 +130,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
124 //log4net.Config.XmlConfigurator.Configure(); 130 //log4net.Config.XmlConfigurator.Configure();
125 131
126 SceneObjectPart part1 = CreateSceneObjectPart1(); 132 SceneObjectPart part1 = CreateSceneObjectPart1();
127 m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); 133 SceneObjectGroup sog1 = new SceneObjectGroup(part1);
134 m_scene.AddNewSceneObject(sog1, false);
128 135
129 SceneObjectPart part2 = CreateSceneObjectPart2(); 136 SceneObjectPart part2 = CreateSceneObjectPart2();
130 m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); 137
138 AssetNotecard nc = new AssetNotecard("Hello World!");
139 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
140 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
141 AssetBase ncAsset
142 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
143 m_scene.AssetService.Store(ncAsset);
144 SceneObjectGroup sog2 = new SceneObjectGroup(part2);
145 TaskInventoryItem ncItem
146 = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
147 part2.Inventory.AddInventoryItem(ncItem, true);
148
149 m_scene.AddNewSceneObject(sog2, false);
131 150
132 MemoryStream archiveWriteStream = new MemoryStream(); 151 MemoryStream archiveWriteStream = new MemoryStream();
133 m_scene.EventManager.OnOarFileSaved += SaveCompleted; 152 m_scene.EventManager.OnOarFileSaved += SaveCompleted;
@@ -151,18 +170,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
151 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 170 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
152 171
153 bool gotControlFile = false; 172 bool gotControlFile = false;
154 bool gotObject1File = false; 173 bool gotNcAssetFile = false;
155 bool gotObject2File = false; 174
156 string expectedObject1FileName = string.Format( 175 string expectedNcAssetFileName = string.Format("{0}_{1}", ncAssetUuid, "notecard.txt");
157 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", 176
158 part1.Name, 177 List<string> foundPaths = new List<string>();
159 Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), 178 List<string> expectedPaths = new List<string>();
160 part1.UUID); 179 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog1));
161 string expectedObject2FileName = string.Format( 180 expectedPaths.Add(ArchiveHelpers.CreateObjectPath(sog2));
162 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
163 part2.Name,
164 Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
165 part2.UUID);
166 181
167 string filePath; 182 string filePath;
168 TarArchiveReader.TarEntryType tarEntryType; 183 TarArchiveReader.TarEntryType tarEntryType;
@@ -173,26 +188,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
173 { 188 {
174 gotControlFile = true; 189 gotControlFile = true;
175 } 190 }
191 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
192 {
193 string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
194
195 Assert.That(fileName, Is.EqualTo(expectedNcAssetFileName));
196 gotNcAssetFile = true;
197 }
176 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 198 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
177 { 199 {
178 string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length); 200 foundPaths.Add(filePath);
179
180 if (fileName.StartsWith(part1.Name))
181 {
182 Assert.That(fileName, Is.EqualTo(expectedObject1FileName));
183 gotObject1File = true;
184 }
185 else if (fileName.StartsWith(part2.Name))
186 {
187 Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
188 gotObject2File = true;
189 }
190 } 201 }
191 } 202 }
192 203
193 Assert.That(gotControlFile, Is.True, "No control file in archive"); 204 Assert.That(gotControlFile, Is.True, "No control file in archive");
194 Assert.That(gotObject1File, Is.True, "No object1 file in archive"); 205 Assert.That(gotNcAssetFile, Is.True, "No notecard asset file in archive");
195 Assert.That(gotObject2File, Is.True, "No object2 file in archive"); 206 Assert.That(foundPaths, Is.EquivalentTo(expectedPaths));
196 207
197 // TODO: Test presence of more files and contents of files. 208 // TODO: Test presence of more files and contents of files.
198 } 209 }