aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2011-10-25 03:19:10 +0100
committerMelanie2011-10-25 03:19:10 +0100
commit02f0aa592d665c7bd7526a077e97cf2637a259f6 (patch)
tree966d5bb4535a76bd422b5841d3b2c0fccc8495cb
parentMerge commit '30320505fa54640baf4ecaff8bb743f62ef01f86' into bigmerge (diff)
parentGet UUIDGatherer to scan notecards in the graph for asset uuids. (diff)
downloadopensim-SC-02f0aa592d665c7bd7526a077e97cf2637a259f6.zip
opensim-SC-02f0aa592d665c7bd7526a077e97cf2637a259f6.tar.gz
opensim-SC-02f0aa592d665c7bd7526a077e97cf2637a259f6.tar.bz2
opensim-SC-02f0aa592d665c7bd7526a077e97cf2637a259f6.tar.xz
Merge commit 'ffdf59a57c936189e3b161b79b4a76a3a9b260bb' into bigmerge
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs4
-rw-r--r--OpenSim/Framework/Util.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs38
-rw-r--r--OpenSim/Tests/Common/Helpers/AssetHelpers.cs17
5 files changed, 68 insertions, 24 deletions
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index c5a20e7..1ca35df 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -146,9 +146,9 @@ namespace OpenSim.Framework.Tests
146 Assert.IsFalse(Util.isUUID("FOOBAR67-89ab-Cdef-0123-456789AbCdEf"), 146 Assert.IsFalse(Util.isUUID("FOOBAR67-89ab-Cdef-0123-456789AbCdEf"),
147 "UUIDs with non-hex characters are recognized as correct UUIDs."); 147 "UUIDs with non-hex characters are recognized as correct UUIDs.");
148 Assert.IsFalse(Util.isUUID("01234567"), 148 Assert.IsFalse(Util.isUUID("01234567"),
149 "Too short UUIDs are regognized as correct UUIDs."); 149 "Too short UUIDs are recognized as correct UUIDs.");
150 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf0"), 150 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf0"),
151 "Too long UUIDs are regognized as correct UUIDs."); 151 "Too long UUIDs are recognized as correct UUIDs.");
152 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123+456789AbCdEf"), 152 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123+456789AbCdEf"),
153 "UUIDs with wrong format are recognized as correct UUIDs."); 153 "UUIDs with wrong format are recognized as correct UUIDs.");
154 } 154 }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 1cbb53f..0b2fbb9 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -46,7 +46,6 @@ using System.Threading;
46using log4net; 46using log4net;
47using Nini.Config; 47using Nini.Config;
48using Nwc.XmlRpc; 48using Nwc.XmlRpc;
49// using BclExtras;
50using OpenMetaverse; 49using OpenMetaverse;
51using OpenMetaverse.StructuredData; 50using OpenMetaverse.StructuredData;
52using Amib.Threading; 51using Amib.Threading;
@@ -91,8 +90,10 @@ namespace OpenSim.Framework
91 private static readonly DateTime unixEpoch = 90 private static readonly DateTime unixEpoch =
92 DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); 91 DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
93 92
94 public static readonly Regex UUIDPattern 93 private static readonly string rawUUIDPattern
95 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); 94 = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
95 public static readonly Regex PermissiveUUIDPattern = new Regex(rawUUIDPattern);
96 public static readonly Regex UUIDPattern = new Regex(string.Format("^{0}$", rawUUIDPattern));
96 97
97 public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; 98 public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
98 public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; 99 public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 24de56e..d9fe87c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -85,5 +85,31 @@ namespace OpenSim.Region.Framework.Scenes.Tests
85 // We count the uuid as gathered even if the asset itself is missing. 85 // We count the uuid as gathered even if the asset itself is missing.
86 Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); 86 Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
87 } 87 }
88
89 [Test]
90 public void TestNotecardAsset()
91 {
92 TestHelpers.InMethod();
93// log4net.Config.XmlConfigurator.Configure();
94
95 UUID ownerId = TestHelpers.ParseTail(0x10);
96 UUID soAssetId = TestHelpers.ParseTail(0x20);
97 UUID ncAssetId = TestHelpers.ParseTail(0x30);
98
99 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
100 AssetBase soAsset = AssetHelpers.CreateAsset(soAssetId, so);
101 m_assetService.Store(soAsset);
102
103 AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString());
104 m_assetService.Store(ncAsset);
105
106 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
107 m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids);
108
109 // We count the uuid as gathered even if the asset itself is corrupt.
110 Assert.That(foundAssetUuids.Count, Is.EqualTo(2));
111 Assert.That(foundAssetUuids.ContainsKey(ncAssetId));
112 Assert.That(foundAssetUuids.ContainsKey(soAssetId));
113 }
88 } 114 }
89} 115}
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 8d41f00..313dc99 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -62,12 +62,12 @@ namespace OpenSim.Region.Framework.Scenes
62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate 62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
63 /// asset was found by the asset service. 63 /// asset was found by the asset service.
64 /// </summary> 64 /// </summary>
65 protected AssetBase m_requestedObjectAsset; 65 private AssetBase m_requestedObjectAsset;
66 66
67 /// <summary> 67 /// <summary>
68 /// Signal whether we are currently waiting for the asset service to deliver an asset. 68 /// Signal whether we are currently waiting for the asset service to deliver an asset.
69 /// </summary> 69 /// </summary>
70 protected bool m_waitingForObjectAsset; 70 private bool m_waitingForObjectAsset;
71 71
72 public UuidGatherer(IAssetService assetCache) 72 public UuidGatherer(IAssetService assetCache)
73 { 73 {
@@ -99,9 +99,13 @@ namespace OpenSim.Region.Framework.Scenes
99 { 99 {
100 GetGestureAssetUuids(assetUuid, assetUuids); 100 GetGestureAssetUuids(assetUuid, assetUuids);
101 } 101 }
102 else if (AssetType.Notecard == assetType)
103 {
104 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
105 }
102 else if (AssetType.LSLText == assetType) 106 else if (AssetType.LSLText == assetType)
103 { 107 {
104 GetScriptAssetUuids(assetUuid, assetUuids); 108 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
105 } 109 }
106 else if (AssetType.Object == assetType) 110 else if (AssetType.Object == assetType)
107 { 111 {
@@ -190,7 +194,7 @@ namespace OpenSim.Region.Framework.Scenes
190 /// <summary> 194 /// <summary>
191 /// The callback made when we request the asset for an object from the asset service. 195 /// The callback made when we request the asset for an object from the asset service.
192 /// </summary> 196 /// </summary>
193 protected void AssetReceived(string id, Object sender, AssetBase asset) 197 private void AssetReceived(string id, Object sender, AssetBase asset)
194 { 198 {
195 lock (this) 199 lock (this)
196 { 200 {
@@ -234,23 +238,25 @@ namespace OpenSim.Region.Framework.Scenes
234 /// </summary> 238 /// </summary>
235 /// <param name="scriptUuid"></param> 239 /// <param name="scriptUuid"></param>
236 /// <param name="assetUuids">Dictionary in which to record the references</param> 240 /// <param name="assetUuids">Dictionary in which to record the references</param>
237 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids) 241 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids)
238 { 242 {
239 AssetBase scriptAsset = GetAsset(scriptUuid); 243 m_log.DebugFormat("[ASSET GATHERER]: Getting assets for asset {0}", embeddingAssetId);
244
245 AssetBase embeddingAsset = GetAsset(embeddingAssetId);
240 246
241 if (null != scriptAsset) 247 if (null != embeddingAsset)
242 { 248 {
243 string script = Utils.BytesToString(scriptAsset.Data); 249 string script = Utils.BytesToString(embeddingAsset.Data);
244 //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); 250 m_log.DebugFormat("[ARCHIVER]: Script {0}", script);
245 MatchCollection uuidMatches = Util.UUIDPattern.Matches(script); 251 MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(script);
246 //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); 252 m_log.DebugFormat("[ARCHIVER]: Found {0} matches in text", uuidMatches.Count);
247 253
248 foreach (Match uuidMatch in uuidMatches) 254 foreach (Match uuidMatch in uuidMatches)
249 { 255 {
250 UUID uuid = new UUID(uuidMatch.Value); 256 UUID uuid = new UUID(uuidMatch.Value);
251 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); 257 m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid);
252 258
253 // Assume AssetIDs embedded in scripts are textures 259 // Assume AssetIDs embedded are textures.
254 assetUuids[uuid] = AssetType.Texture; 260 assetUuids[uuid] = AssetType.Texture;
255 } 261 }
256 } 262 }
@@ -261,7 +267,7 @@ namespace OpenSim.Region.Framework.Scenes
261 /// </summary> 267 /// </summary>
262 /// <param name="wearableAssetUuid"></param> 268 /// <param name="wearableAssetUuid"></param>
263 /// <param name="assetUuids">Dictionary in which to record the references</param> 269 /// <param name="assetUuids">Dictionary in which to record the references</param>
264 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) 270 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
265 { 271 {
266 AssetBase assetBase = GetAsset(wearableAssetUuid); 272 AssetBase assetBase = GetAsset(wearableAssetUuid);
267 273
@@ -288,7 +294,7 @@ namespace OpenSim.Region.Framework.Scenes
288 /// </summary> 294 /// </summary>
289 /// <param name="sceneObject"></param> 295 /// <param name="sceneObject"></param>
290 /// <param name="assetUuids"></param> 296 /// <param name="assetUuids"></param>
291 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) 297 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
292 { 298 {
293 AssetBase objectAsset = GetAsset(sceneObjectUuid); 299 AssetBase objectAsset = GetAsset(sceneObjectUuid);
294 300
@@ -317,7 +323,7 @@ namespace OpenSim.Region.Framework.Scenes
317 /// </summary> 323 /// </summary>
318 /// <param name="gestureUuid"></param> 324 /// <param name="gestureUuid"></param>
319 /// <param name="assetUuids"></param> 325 /// <param name="assetUuids"></param>
320 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) 326 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
321 { 327 {
322 AssetBase assetBase = GetAsset(gestureUuid); 328 AssetBase assetBase = GetAsset(gestureUuid);
323 if (null == assetBase) 329 if (null == assetBase)
diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
index efeb973..7af8bed 100644
--- a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
@@ -47,13 +47,24 @@ namespace OpenSim.Tests.Common
47 } 47 }
48 48
49 /// <summary> 49 /// <summary>
50 /// Create a notecard asset with a random uuid and dummy text. 50 /// Create a notecard asset with dummy text and a random owner.
51 /// </summary> 51 /// </summary>
52 /// <param name="assetId">/param> 52 /// <param name="assetId">/param>
53 /// <returns></returns> 53 /// <returns></returns>
54 public static AssetBase CreateNotecardAsset(UUID id) 54 public static AssetBase CreateNotecardAsset(UUID assetId)
55 { 55 {
56 return CreateAsset(id, AssetType.Notecard, "hello", UUID.Random()); 56 return CreateNotecardAsset(assetId, "hello");
57 }
58
59 /// <summary>
60 /// Create a notecard asset with a random owner.
61 /// </summary>
62 /// <param name="assetId">/param>
63 /// <param name="text"></param>
64 /// <returns></returns>
65 public static AssetBase CreateNotecardAsset(UUID assetId, string text)
66 {
67 return CreateAsset(assetId, AssetType.Notecard, text, UUID.Random());
57 } 68 }
58 69
59// /// <summary> 70// /// <summary>