diff options
author | Justin Clark-Casey (justincc) | 2011-10-22 02:16:46 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-22 02:16:46 +0100 |
commit | ffdf59a57c936189e3b161b79b4a76a3a9b260bb (patch) | |
tree | c857a6214e291e5b91f1241107b84baa3b9f246f | |
parent | redirect UserInventoryHelpers to use a different CreateNotecardAsset() so we ... (diff) | |
download | opensim-SC-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.zip opensim-SC-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.gz opensim-SC-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.bz2 opensim-SC-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.xz |
Get UUIDGatherer to scan notecards in the graph for asset uuids.
This is to support npc baked texture saving in oars and iars.
May address http://opensimulator.org/mantis/view.php?id=5743
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Tests/UtilTest.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 38 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Helpers/AssetHelpers.cs | 17 |
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 c4fc643..21cfc09 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -46,7 +46,6 @@ using System.Threading; | |||
46 | using log4net; | 46 | using log4net; |
47 | using Nini.Config; | 47 | using Nini.Config; |
48 | using Nwc.XmlRpc; | 48 | using Nwc.XmlRpc; |
49 | // using BclExtras; | ||
50 | using OpenMetaverse; | 49 | using OpenMetaverse; |
51 | using OpenMetaverse.StructuredData; | 50 | using OpenMetaverse.StructuredData; |
52 | using Amib.Threading; | 51 | using 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 3acdaf8..cc3f7a3 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 | { |
@@ -103,9 +103,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | { | 103 | { |
104 | GetGestureAssetUuids(assetUuid, assetUuids); | 104 | GetGestureAssetUuids(assetUuid, assetUuids); |
105 | } | 105 | } |
106 | else if (AssetType.Notecard == assetType) | ||
107 | { | ||
108 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | ||
109 | } | ||
106 | else if (AssetType.LSLText == assetType) | 110 | else if (AssetType.LSLText == assetType) |
107 | { | 111 | { |
108 | GetScriptAssetUuids(assetUuid, assetUuids); | 112 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); |
109 | } | 113 | } |
110 | else if (AssetType.Object == assetType) | 114 | else if (AssetType.Object == assetType) |
111 | { | 115 | { |
@@ -194,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | /// <summary> | 198 | /// <summary> |
195 | /// The callback made when we request the asset for an object from the asset service. | 199 | /// The callback made when we request the asset for an object from the asset service. |
196 | /// </summary> | 200 | /// </summary> |
197 | protected void AssetReceived(string id, Object sender, AssetBase asset) | 201 | private void AssetReceived(string id, Object sender, AssetBase asset) |
198 | { | 202 | { |
199 | lock (this) | 203 | lock (this) |
200 | { | 204 | { |
@@ -238,23 +242,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
238 | /// </summary> | 242 | /// </summary> |
239 | /// <param name="scriptUuid"></param> | 243 | /// <param name="scriptUuid"></param> |
240 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 244 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
241 | protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids) | 245 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) |
242 | { | 246 | { |
243 | AssetBase scriptAsset = GetAsset(scriptUuid); | 247 | m_log.DebugFormat("[ASSET GATHERER]: Getting assets for asset {0}", embeddingAssetId); |
248 | |||
249 | AssetBase embeddingAsset = GetAsset(embeddingAssetId); | ||
244 | 250 | ||
245 | if (null != scriptAsset) | 251 | if (null != embeddingAsset) |
246 | { | 252 | { |
247 | string script = Utils.BytesToString(scriptAsset.Data); | 253 | string script = Utils.BytesToString(embeddingAsset.Data); |
248 | //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); | 254 | m_log.DebugFormat("[ARCHIVER]: Script {0}", script); |
249 | MatchCollection uuidMatches = Util.UUIDPattern.Matches(script); | 255 | MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(script); |
250 | //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); | 256 | m_log.DebugFormat("[ARCHIVER]: Found {0} matches in text", uuidMatches.Count); |
251 | 257 | ||
252 | foreach (Match uuidMatch in uuidMatches) | 258 | foreach (Match uuidMatch in uuidMatches) |
253 | { | 259 | { |
254 | UUID uuid = new UUID(uuidMatch.Value); | 260 | UUID uuid = new UUID(uuidMatch.Value); |
255 | //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); | 261 | m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid); |
256 | 262 | ||
257 | // Assume AssetIDs embedded in scripts are textures | 263 | // Assume AssetIDs embedded are textures. |
258 | assetUuids[uuid] = AssetType.Texture; | 264 | assetUuids[uuid] = AssetType.Texture; |
259 | } | 265 | } |
260 | } | 266 | } |
@@ -265,7 +271,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | /// </summary> | 271 | /// </summary> |
266 | /// <param name="wearableAssetUuid"></param> | 272 | /// <param name="wearableAssetUuid"></param> |
267 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 273 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
268 | protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) | 274 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) |
269 | { | 275 | { |
270 | AssetBase assetBase = GetAsset(wearableAssetUuid); | 276 | AssetBase assetBase = GetAsset(wearableAssetUuid); |
271 | 277 | ||
@@ -292,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | /// </summary> | 298 | /// </summary> |
293 | /// <param name="sceneObject"></param> | 299 | /// <param name="sceneObject"></param> |
294 | /// <param name="assetUuids"></param> | 300 | /// <param name="assetUuids"></param> |
295 | protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) | 301 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) |
296 | { | 302 | { |
297 | AssetBase objectAsset = GetAsset(sceneObjectUuid); | 303 | AssetBase objectAsset = GetAsset(sceneObjectUuid); |
298 | 304 | ||
@@ -321,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | /// </summary> | 327 | /// </summary> |
322 | /// <param name="gestureUuid"></param> | 328 | /// <param name="gestureUuid"></param> |
323 | /// <param name="assetUuids"></param> | 329 | /// <param name="assetUuids"></param> |
324 | protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) | 330 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) |
325 | { | 331 | { |
326 | AssetBase assetBase = GetAsset(gestureUuid); | 332 | AssetBase assetBase = GetAsset(gestureUuid); |
327 | if (null == assetBase) | 333 | 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> |