aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs28
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs43
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs47
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs10
-rw-r--r--OpenSim/Services/Interfaces/IAssetService.cs5
-rw-r--r--OpenSim/Tests/Common/Mock/MockAssetService.cs22
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs7
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs7
10 files changed, 134 insertions, 39 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
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index a81af43..e1f90b6 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -89,6 +89,8 @@ namespace OpenSim.Services.AssetService
89 89
90 public virtual AssetBase Get(string id) 90 public virtual AssetBase Get(string id)
91 { 91 {
92// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id);
93
92 UUID assetID; 94 UUID assetID;
93 95
94 if (!UUID.TryParse(id, out assetID)) 96 if (!UUID.TryParse(id, out assetID))
@@ -107,6 +109,8 @@ namespace OpenSim.Services.AssetService
107 109
108 public virtual AssetMetadata GetMetadata(string id) 110 public virtual AssetMetadata GetMetadata(string id)
109 { 111 {
112// m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id);
113
110 UUID assetID; 114 UUID assetID;
111 115
112 if (!UUID.TryParse(id, out assetID)) 116 if (!UUID.TryParse(id, out assetID))
@@ -121,6 +125,8 @@ namespace OpenSim.Services.AssetService
121 125
122 public virtual byte[] GetData(string id) 126 public virtual byte[] GetData(string id)
123 { 127 {
128// m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id);
129
124 UUID assetID; 130 UUID assetID;
125 131
126 if (!UUID.TryParse(id, out assetID)) 132 if (!UUID.TryParse(id, out assetID))
@@ -150,7 +156,9 @@ namespace OpenSim.Services.AssetService
150 156
151 public virtual string Store(AssetBase asset) 157 public virtual string Store(AssetBase asset)
152 { 158 {
153 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); 159// m_log.DebugFormat(
160// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
161
154 m_Database.StoreAsset(asset); 162 m_Database.StoreAsset(asset);
155 163
156 return asset.ID; 164 return asset.ID;
diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs
index 3be6815..1ac1cec 100644
--- a/OpenSim/Services/Interfaces/IAssetService.cs
+++ b/OpenSim/Services/Interfaces/IAssetService.cs
@@ -48,6 +48,11 @@ namespace OpenSim.Services.Interfaces
48 /// <returns></returns> 48 /// <returns></returns>
49 AssetMetadata GetMetadata(string id); 49 AssetMetadata GetMetadata(string id);
50 50
51 /// <summary>
52 /// Get an asset's data, ignoring the metadata.
53 /// </summary>
54 /// <param name="id"></param>
55 /// <returns>null if there is no such asset</returns>
51 byte[] GetData(string id); 56 byte[] GetData(string id);
52 57
53 /// <summary> 58 /// <summary>
diff --git a/OpenSim/Tests/Common/Mock/MockAssetService.cs b/OpenSim/Tests/Common/Mock/MockAssetService.cs
index 4118308..9d7c5e2 100644
--- a/OpenSim/Tests/Common/Mock/MockAssetService.cs
+++ b/OpenSim/Tests/Common/Mock/MockAssetService.cs
@@ -54,13 +54,19 @@ namespace OpenSim.Tests.Common.Mock
54 54
55 public AssetBase Get(string id) 55 public AssetBase Get(string id)
56 { 56 {
57 m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); 57// m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id);
58 58
59 AssetBase asset; 59 AssetBase asset;
60 if (Assets.ContainsKey(id)) 60 if (Assets.ContainsKey(id))
61 {
61 asset = Assets[id]; 62 asset = Assets[id];
63// m_log.DebugFormat(
64// "[MOCK ASSET SERVICE]: Got asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
65 }
62 else 66 else
63 asset = null; 67 {
68 asset = null;
69 }
64 70
65 return asset; 71 return asset;
66 } 72 }
@@ -77,7 +83,14 @@ namespace OpenSim.Tests.Common.Mock
77 83
78 public byte[] GetData(string id) 84 public byte[] GetData(string id)
79 { 85 {
80 throw new System.NotImplementedException(); 86// m_log.DebugFormat("[MOCK ASSET SERVICE]: Requesting data for asset {0}", id);
87
88 AssetBase asset = Get(id);
89
90 if (asset == null)
91 return null;
92 else
93 return asset.Data;
81 } 94 }
82 95
83 public bool Get(string id, object sender, AssetRetrieved handler) 96 public bool Get(string id, object sender, AssetRetrieved handler)
@@ -89,7 +102,8 @@ namespace OpenSim.Tests.Common.Mock
89 102
90 public string Store(AssetBase asset) 103 public string Store(AssetBase asset)
91 { 104 {
92 m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); 105// m_log.DebugFormat(
106// "[MOCK ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.ID, asset.Data.Length);
93 107
94 Assets[asset.ID] = asset; 108 Assets[asset.ID] = asset;
95 109
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 971c6bc..d572249 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -30,6 +30,7 @@ using OpenMetaverse;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Scenes.Serialization; 32using OpenSim.Region.Framework.Scenes.Serialization;
33using OpenSim.Services.Interfaces;
33 34
34namespace OpenSim.Tests.Common 35namespace OpenSim.Tests.Common
35{ 36{
@@ -118,5 +119,11 @@ namespace OpenSim.Tests.Common
118 asset.Data = data; 119 asset.Data = data;
119 return asset; 120 return asset;
120 } 121 }
122
123 public static string ReadAssetAsString(IAssetService assetService, UUID uuid)
124 {
125 byte[] assetData = assetService.GetData(uuid.ToString());
126 return Encoding.ASCII.GetString(assetData);
127 }
121 } 128 }
122} 129}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index eb08b62..837f4e2 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -168,14 +168,17 @@ namespace OpenSim.Tests.Common.Setup
168 { 168 {
169 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); 169 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
170 IConfigSource config = new IniConfigSource(); 170 IConfigSource config = new IniConfigSource();
171 config.AddConfig("Modules"); 171 config.AddConfig("Modules");
172 config.AddConfig("AssetService");
173 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 172 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
173
174 config.AddConfig("AssetService");
174 if (real) 175 if (real)
175 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 176 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
176 else 177 else
177 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService"); 178 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService");
179
178 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 180 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
181
179 assetService.Initialise(config); 182 assetService.Initialise(config);
180 assetService.AddRegion(testScene); 183 assetService.AddRegion(testScene);
181 assetService.RegionLoaded(testScene); 184 assetService.RegionLoaded(testScene);