aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-06-12 00:08:20 +0100
committerMelanie2010-06-12 00:08:20 +0100
commit836728e5ded245df7553b6a1b6c279d2e11ee370 (patch)
treed0ff3f9a5cc3747357f36aa09367c5d2eb8a7543
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-836728e5ded245df7553b6a1b6c279d2e11ee370.zip
opensim-SC_OLD-836728e5ded245df7553b6a1b6c279d2e11ee370.tar.gz
opensim-SC_OLD-836728e5ded245df7553b6a1b6c279d2e11ee370.tar.bz2
opensim-SC_OLD-836728e5ded245df7553b6a1b6c279d2e11ee370.tar.xz
Merge branch 'master' into careminster-presence-refactor
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs34
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs28
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrain.cs1
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs84
-rw-r--r--OpenSim/Tests/Common/Setup/AssetHelpers.cs46
-rw-r--r--OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs18
10 files changed, 215 insertions, 106 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 60d1720..b4f1ed6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -219,40 +219,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
219 CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes); 219 CreateFoldersForPath(destFolder, archivePathSectionToCreate, resolvedFolders, loadedNodes);
220 220
221 return destFolder; 221 return destFolder;
222
223 /*
224 string[] rawFolders = filePath.Split(new char[] { '/' });
225
226 // Find the folders that do exist along the path given
227 int i = 0;
228 bool noFolder = false;
229 InventoryFolderImpl foundFolder = rootDestinationFolder;
230 while (!noFolder && i < rawFolders.Length)
231 {
232 InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
233 if (null != folder)
234 {
235 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
236 foundFolder = folder;
237 i++;
238 }
239 else
240 {
241 noFolder = true;
242 }
243 }
244
245 // Create any folders that did not previously exist
246 while (i < rawFolders.Length)
247 {
248 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
249
250 UUID newFolderId = UUID.Random();
251 m_userInfo.CreateFolder(
252 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
253 foundFolder = foundFolder.GetChildFolder(newFolderId);
254 }
255 */
256 } 222 }
257 223
258 /// <summary> 224 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 59cd386..00bd27a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
279 public void TestIarV0_1WithEscapedChars() 279 public void TestIarV0_1WithEscapedChars()
280 { 280 {
281 TestHelper.InMethod(); 281 TestHelper.InMethod();
282 log4net.Config.XmlConfigurator.Configure(); 282// log4net.Config.XmlConfigurator.Configure();
283 283
284 string itemName = "You & you are a mean/man/"; 284 string itemName = "You & you are a mean/man/";
285 string humanEscapedItemName = @"You & you are a mean\/man\/"; 285 string humanEscapedItemName = @"You & you are a mean\/man\/";
@@ -505,7 +505,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
505 /// Test replication of an archive path to the user's inventory. 505 /// Test replication of an archive path to the user's inventory.
506 /// </summary> 506 /// </summary>
507 [Test] 507 [Test]
508 public void TestReplicateArchivePathToUserInventory() 508 public void TestNewIarPath()
509 { 509 {
510 TestHelper.InMethod(); 510 TestHelper.InMethod();
511 //log4net.Config.XmlConfigurator.Configure(); 511 //log4net.Config.XmlConfigurator.Configure();
@@ -540,5 +540,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); 540 InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b");
541 Assert.That(folder2, Is.Not.Null, "Could not find folder b"); 541 Assert.That(folder2, Is.Not.Null, "Could not find folder b");
542 } 542 }
543
544 /// <summary>
545 /// Test replication of a partly existing archive path to the user's inventory.
546 /// </summary>
547 [Test]
548 public void TestPartExistingIarPath()
549 {
550 TestHelper.InMethod();
551 //log4net.Config.XmlConfigurator.Configure();
552
553 Scene scene = SceneSetupHelpers.SetupScene("inventory");
554 UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene);
555
556 string folder1ExistingName = "a";
557 string folder2Name = "b";
558 string itemName = "c.lsl";
559
560 InventoryFolderBase folder1
561 = UserInventoryTestUtils.CreateInventoryFolder(
562 scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
563
564 string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
565 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
566 string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random());
567
568 string itemArchivePath
569 = string.Format(
570 "{0}{1}{2}{3}",
571 ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName);
572
573 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null)
574 .ReplicateArchivePathToUserInventory(
575 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
576 new Dictionary<string, InventoryFolderBase>(), new List<InventoryNodeBase>());
577
578 InventoryFolderBase folder1Post
579 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
580 Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
581 /*
582 InventoryFolderBase folder2
583 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
584 Assert.That(folder2, Is.Not.Null);
585 InventoryItemBase item = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, folder2, itemName);
586 Assert.That(item, Is.Not.Null);
587 */
588 }
543 } 589 }
544} \ No newline at end of file 590} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
index b71b5f6..b96d95a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
@@ -70,10 +70,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
70 70
71 #region IMapImageGenerator Members 71 #region IMapImageGenerator Members
72 72
73 public byte[] WriteJpeg2000Image(string gradientmap) 73 public Bitmap CreateMapTile(string gradientmap)
74 { 74 {
75 byte[] imageData = null;
76
77 bool drawPrimVolume = true; 75 bool drawPrimVolume = true;
78 bool textureTerrain = false; 76 bool textureTerrain = false;
79 77
@@ -98,32 +96,36 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
98 } 96 }
99 terrainRenderer.Initialise(m_scene, m_config); 97 terrainRenderer.Initialise(m_scene, m_config);
100 98
101 using (Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize)) 99 Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
102 { 100 //long t = System.Environment.TickCount;
103 //long t = System.Environment.TickCount; 101 //for (int i = 0; i < 10; ++i) {
104 //for (int i = 0; i < 10; ++i) { 102 terrainRenderer.TerrainToBitmap(mapbmp);
105 terrainRenderer.TerrainToBitmap(mapbmp); 103 //}
106 //} 104 //t = System.Environment.TickCount - t;
107 //t = System.Environment.TickCount - t; 105 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
108 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
109 106
110 107
111 if (drawPrimVolume) 108 if (drawPrimVolume)
112 { 109 {
113 DrawObjectVolume(m_scene, mapbmp); 110 DrawObjectVolume(m_scene, mapbmp);
114 } 111 }
115 112
116 try 113 return mapbmp;
117 { 114 }
118 imageData = OpenJPEG.EncodeFromImage(mapbmp, true); 115
119 } 116 public byte[] WriteJpeg2000Image(string gradientmap)
120 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 117 {
121 { 118 try
122 m_log.Error("Failed generating terrain map: " + e); 119 {
123 } 120 using (Bitmap mapbmp = CreateMapTile(gradientmap))
121 return OpenJPEG.EncodeFromImage(mapbmp, true);
122 }
123 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
124 {
125 m_log.Error("Failed generating terrain map: " + e);
124 } 126 }
125 127
126 return imageData; 128 return null;
127 } 129 }
128 130
129 #endregion 131 #endregion
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
index a297cf3..fef2ef3 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
@@ -37,6 +37,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
37{ 37{
38 public class ShadedMapTileRenderer : IMapTileTerrainRenderer 38 public class ShadedMapTileRenderer : IMapTileTerrainRenderer
39 { 39 {
40 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
41
40 private static readonly ILog m_log = 42 private static readonly ILog m_log =
41 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 44
@@ -221,8 +223,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
221 223
222 try 224 try
223 { 225 {
224 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 226 mapbmp.SetPixel(x, yr, WATER_COLOR);
225 mapbmp.SetPixel(x, yr, water);
226 } 227 }
227 catch (ArgumentException) 228 catch (ArgumentException)
228 { 229 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
index 4ecad74..8b34f6e 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
@@ -136,6 +136,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
136 private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c"); 136 private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
137 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200); 137 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
138 138
139 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
140
139 #endregion 141 #endregion
140 142
141 143
@@ -406,8 +408,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
406 408
407 heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0 409 heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0
408 410
409 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 411 mapbmp.SetPixel(x, yr, WATER_COLOR);
410 mapbmp.SetPixel(x, yr, water);
411 } 412 }
412 } 413 }
413 } 414 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index c6fb18d..0e849e5 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1002,41 +1002,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1002 1002
1003 public void RegenerateMaptile(byte[] data) 1003 public void RegenerateMaptile(byte[] data)
1004 { 1004 {
1005 // Overwrites the local Asset cache with new maptile data
1006 // Assets are single write, this causes the asset server to ignore this update,
1007 // but the local asset cache does not
1008
1009 // this is on purpose! The net result of this is the region always has the most up to date
1010 // map tile while protecting the (grid) asset database from bloat caused by a new asset each
1011 // time a mapimage is generated!
1012
1013 UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; 1005 UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
1014 1006
1015 int lastMapRefresh = 0;
1016 int twoDays = 172800;
1017// int RefreshSeconds = twoDays;
1018
1019 try
1020 {
1021 lastMapRefresh = Convert.ToInt32(m_scene.RegionInfo.lastMapRefresh);
1022 }
1023 catch (ArgumentException)
1024 {
1025 }
1026 catch (FormatException)
1027 {
1028 }
1029 catch (OverflowException)
1030 {
1031 }
1032
1033 m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE"); 1007 m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE");
1034 1008
1035 m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random(); 1009 m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();
1036 1010
1037 AssetBase asset = new AssetBase( 1011 AssetBase asset = new AssetBase(
1038 m_scene.RegionInfo.RegionSettings.TerrainImageID, 1012 m_scene.RegionInfo.RegionSettings.TerrainImageID,
1039 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), 1013 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(),
1040 (sbyte)AssetType.Texture, 1014 (sbyte)AssetType.Texture,
1041 m_scene.RegionInfo.RegionID.ToString()); 1015 m_scene.RegionInfo.RegionID.ToString());
1042 asset.Data = data; 1016 asset.Data = data;
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrain.cs b/OpenSim/Region/Framework/Interfaces/ITerrain.cs
index f5662cb..b42e872 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrain.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrain.cs
@@ -73,6 +73,7 @@ namespace OpenSim.Region.Framework.Interfaces
73 73
74 public interface IMapImageGenerator 74 public interface IMapImageGenerator
75 { 75 {
76 System.Drawing.Bitmap CreateMapTile(string gradientmap);
76 byte[] WriteJpeg2000Image(string gradientmap); 77 byte[] WriteJpeg2000Image(string gradientmap);
77 } 78 }
78} 79}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 57924b7..119868b 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,17 +28,18 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
33using System.IO;
31using System.Net; 34using System.Net;
32using System.Reflection; 35using System.Reflection;
33using log4net; 36using log4net;
34using Mono.Addins; 37using Mono.Addins;
35using Nini.Config; 38using Nini.Config;
36using OpenSim.Framework; 39using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
41using OpenSim.Server.Base;
42using OpenMetaverse; 43using OpenMetaverse;
43using OpenMetaverse.StructuredData; 44using OpenMetaverse.StructuredData;
44 45
@@ -62,7 +63,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
62 #region ISharedRegionModule 63 #region ISharedRegionModule
63 64
64 public Type ReplaceableInterface { get { return null; } } 65 public Type ReplaceableInterface { get { return null; } }
65 public void RegionLoaded(Scene scene) { } 66 public void RegionLoaded(Scene scene) { UploadMapTile(scene); }
66 public void PostInitialise() { } 67 public void PostInitialise() { }
67 public void Close() { } 68 public void Close() { }
68 69
@@ -358,6 +359,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
358 359
359 #endregion IGridService 360 #endregion IGridService
360 361
362 private void UploadMapTile(IScene scene)
363 {
364 string errorMessage = null;
365
366 // Create a PNG map tile and upload it to the AddMapTile API
367 byte[] pngData = Utils.EmptyBytes;
368 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
369 if (tileGenerator == null)
370 {
371 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
372 return;
373 }
374
375 using (Image mapTile = tileGenerator.CreateMapTile("defaultstripe.png"))
376 {
377 using (MemoryStream stream = new MemoryStream())
378 {
379 mapTile.Save(stream, ImageFormat.Png);
380 pngData = stream.ToArray();
381 }
382 }
383
384 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
385 {
386 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
387 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
388 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
389 };
390
391 // Make the remote storage request
392 try
393 {
394 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
395
396 HttpWebResponse response = MultipartForm.Post(request, postParameters);
397 using (Stream responseStream = response.GetResponseStream())
398 {
399 string responseStr = null;
400
401 try
402 {
403 responseStr = responseStream.GetStreamString();
404 OSD responseOSD = OSDParser.Deserialize(responseStr);
405 if (responseOSD.Type == OSDType.Map)
406 {
407 OSDMap responseMap = (OSDMap)responseOSD;
408 if (responseMap["Success"].AsBoolean())
409 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
410 else
411 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
412 }
413 else
414 {
415 errorMessage = "Response format was invalid:\n" + responseStr;
416 }
417 }
418 catch (Exception ex)
419 {
420 if (!String.IsNullOrEmpty(responseStr))
421 errorMessage = "Failed to parse the response:\n" + responseStr;
422 else
423 errorMessage = "Failed to retrieve the response: " + ex.Message;
424 }
425 }
426 }
427 catch (WebException ex)
428 {
429 errorMessage = ex.Message;
430 }
431
432 if (!String.IsNullOrEmpty(errorMessage))
433 {
434 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
435 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
436 }
437 }
438
361 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 439 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
362 { 440 {
363 NameValueCollection requestArgs = new NameValueCollection 441 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
index 6dc993f..f9a80b0 100644
--- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs
@@ -36,25 +36,29 @@ namespace OpenSim.Tests.Common
36 public class AssetHelpers 36 public class AssetHelpers
37 { 37 {
38 /// <summary> 38 /// <summary>
39 /// Create an asset from the given data 39 /// Create a notecard asset with a random uuid and dummy text.
40 /// </summary> 40 /// </summary>
41 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID) 41 /// <param name="creatorId">/param>
42 /// <returns></returns>
43 public static AssetBase CreateAsset(UUID creatorId)
42 { 44 {
43 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString()); 45 return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
44 asset.Data = data;
45 return asset;
46 } 46 }
47 47
48 /// <summary> 48 /// <summary>
49 /// Create an asset from the given data 49 /// Create and store a notecard asset with a random uuid and dummy text.
50 /// </summary> 50 /// </summary>
51 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID) 51 /// <param name="creatorId">/param>
52 /// <returns></returns>
53 public static AssetBase CreateAsset(Scene scene, UUID creatorId)
52 { 54 {
53 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID); 55 AssetBase asset = CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
54 } 56 scene.AssetService.Store(asset);
55 57 return asset;
58 }
59
56 /// <summary> 60 /// <summary>
57 /// Create an asset from the given scene object 61 /// Create an asset from the given scene object.
58 /// </summary> 62 /// </summary>
59 /// <param name="assetUuid"></param> 63 /// <param name="assetUuid"></param>
60 /// <param name="sog"></param> 64 /// <param name="sog"></param>
@@ -67,5 +71,23 @@ namespace OpenSim.Tests.Common
67 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)), 71 Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)),
68 sog.OwnerID); 72 sog.OwnerID);
69 } 73 }
74
75 /// <summary>
76 /// Create an asset from the given data.
77 /// </summary>
78 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, string data, UUID creatorID)
79 {
80 return CreateAsset(assetUuid, assetType, Encoding.ASCII.GetBytes(data), creatorID);
81 }
82
83 /// <summary>
84 /// Create an asset from the given data.
85 /// </summary>
86 public static AssetBase CreateAsset(UUID assetUuid, AssetType assetType, byte[] data, UUID creatorID)
87 {
88 AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)assetType, creatorID.ToString());
89 asset.Data = data;
90 return asset;
91 }
70 } 92 }
71} 93}
diff --git a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
index 7e0c567..c57363a 100644
--- a/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserInventoryTestUtils.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
31using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
32 33
33namespace OpenSim.Tests.Common 34namespace OpenSim.Tests.Common
@@ -39,6 +40,23 @@ namespace OpenSim.Tests.Common
39 { 40 {
40 public static readonly string PATH_DELIMITER = "/"; 41 public static readonly string PATH_DELIMITER = "/";
41 42
43 public static InventoryItemBase CreateInventoryItem(
44 Scene scene, string itemName, UUID itemId, string folderPath, UUID userId)
45 {
46 InventoryItemBase item = new InventoryItemBase();
47 item.Name = itemName;
48 item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID;
49 item.ID = itemId;
50
51 // Really quite bad since the objs folder could be moved in the future and confuse the tests
52 InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object);
53
54 item.Folder = objsFolder.ID;
55 scene.AddInventoryItem(userId, item);
56
57 return item;
58 }
59
42 /// <summary> 60 /// <summary>
43 /// Create inventory folders starting from the user's root folder. 61 /// Create inventory folders starting from the user's root folder.
44 /// </summary> 62 /// </summary>