From 6b6425aa5ee66df3e4cad3c4453854ff4a087aa8 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 27 May 2010 19:48:21 +0200 Subject: Comment noisy "CONNECTION DEBUGGING" messages, because they push more important stuff off screen too fast --- .../Framework/EntityTransfer/EntityTransferModule.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ef37f63..fa49f9f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -436,7 +436,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer KillEntity(sp.Scene, sp.LocalId); - sp.MakeChildAgent(); + // MT wrapped this in a try because I've been seeing an + // eception here, but no line number. Need to see if SP is + // valid. This may move the exception to another place + // where it can be debugged better. + try + { + sp.MakeChildAgent(); + } + catch(Exception e) + { + m_log.Error("Exception on MakeChildAgent: " + e.ToString()); + } + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) -- cgit v1.1 From a48d7f62a7e3af1aae2437668c484d4d0d1d92e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 27 May 2010 19:02:20 +0100 Subject: Revert "Comment noisy "CONNECTION DEBUGGING" messages, because they push more" Some other stuff snuck in. This reverts commit 4cc533e7ad94d148351c16f48afd2a688a64c48a. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index fa49f9f..ef37f63 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -436,19 +436,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer KillEntity(sp.Scene, sp.LocalId); - // MT wrapped this in a try because I've been seeing an - // eception here, but no line number. Need to see if SP is - // valid. This may move the exception to another place - // where it can be debugged better. - try - { - sp.MakeChildAgent(); - } - catch(Exception e) - { - m_log.Error("Exception on MakeChildAgent: " + e.ToString()); - } - + sp.MakeChildAgent(); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) -- cgit v1.1 From d72435693bf950dde2f3f20e9b5d41c91af60456 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 19:21:00 +0100 Subject: refactor: move GetStream and URI methods from ArchiveReadRequest -> ArchiveHelpers --- .../Archiver/InventoryArchiveWriteRequest.cs | 1 - .../CoreModules/World/Archiver/ArchiveHelpers.cs | 64 ++++++++++++++++++++++ .../World/Archiver/ArchiveReadRequest.cs | 64 +--------------------- 3 files changed, 65 insertions(+), 64 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index cfe3caa..8f3f65b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -37,7 +37,6 @@ using OpenSim.Framework; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; - using OpenSim.Framework.Communications.Osp; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs index 880bd7c..ddc3dd7 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveHelpers.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.IO; +using System.Net; using OpenMetaverse; using OpenSim.Framework.Serialization; using OpenSim.Region.Framework.Scenes; @@ -60,5 +63,66 @@ namespace OpenSim.Region.CoreModules.World.Archiver { return ArchiveConstants.CreateOarObjectPath(sog.Name, sog.UUID, sog.AbsolutePosition); } + + /// + /// Resolve path to a working FileStream + /// + /// + /// + public static Stream GetStream(string path) + { + if (File.Exists(path)) + { + return new FileStream(path, FileMode.Open, FileAccess.Read); + } + else + { + try + { + Uri uri = new Uri(path); + if (uri.Scheme == "file") + { + return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read); + } + else + { + if (uri.Scheme != "http") + throw new Exception(String.Format("Unsupported URI scheme ({0})", path)); + + // OK, now we know we have an HTTP URI to work with + return URIFetch(uri); + } + } + catch (UriFormatException) + { + // In many cases the user will put in a plain old filename that cannot be found so assume that + // this is the problem rather than confusing the issue with a UriFormatException + throw new Exception(String.Format("Cannot find file {0}", path)); + } + } + } + + public static Stream URIFetch(Uri uri) + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); + + // request.Credentials = credentials; + + request.ContentLength = 0; + request.KeepAlive = false; + + WebResponse response = request.GetResponse(); + Stream file = response.GetResponseStream(); + + // justincc: gonna ignore the content type for now and just try anything + //if (response.ContentType != "application/x-oar") + // throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString())); + + if (response.ContentLength == 0) + throw new Exception(String.Format("{0} returned an empty file", uri.ToString())); + + // return new BufferedStream(file, (int) response.ContentLength); + return new BufferedStream(file, 1000000); + } } } \ 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 f97ae5f..bc653ce 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver try { - m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); + m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress); } catch (EntryPointNotFoundException e) { @@ -471,68 +471,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver } /// - /// Resolve path to a working FileStream - /// - /// - /// - private Stream GetStream(string path) - { - if (File.Exists(path)) - { - return new FileStream(path, FileMode.Open, FileAccess.Read); - } - else - { - try - { - Uri uri = new Uri(path); - if (uri.Scheme == "file") - { - return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read); - } - else - { - if (uri.Scheme != "http") - throw new Exception(String.Format("Unsupported URI scheme ({0})", path)); - - // OK, now we know we have an HTTP URI to work with - - return URIFetch(uri); - } - } - catch (UriFormatException) - { - // In many cases the user will put in a plain old filename that cannot be found so assume that - // this is the problem rather than confusing the issue with a UriFormatException - throw new Exception(String.Format("Cannot find file {0}", path)); - } - } - } - - private static Stream URIFetch(Uri uri) - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); - - // request.Credentials = credentials; - - request.ContentLength = 0; - request.KeepAlive = false; - - WebResponse response = request.GetResponse(); - Stream file = response.GetResponseStream(); - - // justincc: gonna ignore the content type for now and just try anything - //if (response.ContentType != "application/x-oar") - // throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString())); - - if (response.ContentLength == 0) - throw new Exception(String.Format("{0} returned an empty file", uri.ToString())); - - // return new BufferedStream(file, (int) response.ContentLength); - return new BufferedStream(file, 1000000); - } - - /// /// Load oar control file /// /// -- cgit v1.1 From 14c39461c2f20db2a79a64d2546cbd4bcb12bee9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 19:41:13 +0100 Subject: minor: remove mono compiler warning --- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index ac6a633..c6fb18d 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1014,7 +1014,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap int lastMapRefresh = 0; int twoDays = 172800; - int RefreshSeconds = twoDays; +// int RefreshSeconds = twoDays; try { -- cgit v1.1 From fff5459f4d3a6fcb7acae9e092fd8aae3c74dd7b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 20:07:15 +0100 Subject: Add ability to load IARs directly from URIs So, something like load iar Justin Clark-Casey / PASSWORD http://justincc.org/downloads/iars/my-great-items.iar Will load my IAR directly from the web. --- .../Archiver/InventoryArchiveReadRequest.cs | 3 +-- .../Inventory/Archiver/InventoryArchiverModule.cs | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index dc7439c..806aa4f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -37,7 +37,6 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; - using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; @@ -72,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene, userInfo, invPath, - new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)) + new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress)) { } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index f570999..307db97 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -91,13 +91,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "load iar", - "load iar []", - "Load user inventory archive.", HandleLoadInvConsoleCommand); + "load iar []", + "Load user inventory archive (IAR).", + " is user's first name." + Environment.NewLine + + " is user's last name." + Environment.NewLine + + " is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine + + " is the user's password." + Environment.NewLine + + " is the filesystem path or URI from which to load the IAR." + + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), + HandleLoadInvConsoleCommand); scene.AddCommand( this, "save iar", - "save iar []", - "Save user inventory archive.", HandleSaveInvConsoleCommand); + "save iar []", + "Save user inventory archive (IAR).", + " is the user's first name." + Environment.NewLine + + " is the user's last name." + Environment.NewLine + + " is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine + + " is the filesystem path at which to save the IAR." + + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), + HandleSaveInvConsoleCommand); m_aScene = scene; } -- cgit v1.1 From 505cb82dee27fc1b681fd7c4b6f904ef18315995 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 21:14:15 +0100 Subject: fission UserAccountService.HandleCreateUser() into two methods, one which handles user command parsing and another which actually does the work --- .../Archiver/Tests/InventoryArchiverTests.cs | 102 ++++++++++----------- 1 file changed, 50 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 9c95e78..e434e46 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -38,7 +38,6 @@ using OpenSim.Framework; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; - using OpenSim.Framework.Communications.Osp; using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; using OpenSim.Region.CoreModules.World.Serialiser; @@ -541,56 +540,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// Test replication of an archive path to the user's inventory. /// - //[Test] - //public void TestReplicateArchivePathToUserInventory() - //{ - // TestHelper.InMethod(); - - // //log4net.Config.XmlConfigurator.Configure(); - - // Scene scene = SceneSetupHelpers.SetupScene("inventory"); - // CommunicationsManager commsManager = scene.CommsManager; - // CachedUserInfo userInfo; - - // lock (this) - // { - // // !!! REFACTORING PROBLEM. This needs to be rewritten - // userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); - // Monitor.Wait(this, 60000); - // } - - // //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); - - // Dictionary foldersCreated = new Dictionary(); - // List nodesLoaded = new List(); - - // string folder1Name = "a"; - // string folder2Name = "b"; - // string itemName = "c.lsl"; - - // string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); - // string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); - // string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - // string itemArchivePath - // = string.Format( - // "{0}{1}{2}{3}", - // ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); - - // //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); - - // new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) - // .ReplicateArchivePathToUserInventory( - // itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), - // foldersCreated, nodesLoaded); - - // //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); - // //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); - // InventoryFolderBase folder1 - // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); - // Assert.That(folder1, Is.Not.Null, "Could not find folder a"); - // InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); - // Assert.That(folder2, Is.Not.Null, "Could not find folder b"); - //} +// [Test] +// public void TestReplicateArchivePathToUserInventory() +// { +// TestHelper.InMethod(); +// //log4net.Config.XmlConfigurator.Configure(); +// +// Scene scene = SceneSetupHelpers.SetupScene("inventory"); +// CommunicationsManager commsManager = scene.CommsManager; +// CachedUserInfo userInfo; +// +// lock (this) +// { +// // !!! REFACTORING PROBLEM. This needs to be rewritten +// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); +// Monitor.Wait(this, 60000); +// } +// +// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); +// +// Dictionary foldersCreated = new Dictionary(); +// List nodesLoaded = new List(); +// +// string folder1Name = "a"; +// string folder2Name = "b"; +// string itemName = "c.lsl"; +// +// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); +// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); +// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); +// +// string itemArchivePath +// = string.Format( +// "{0}{1}{2}{3}", +// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); +// +// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); +// +// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) +// .ReplicateArchivePathToUserInventory( +// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), +// foldersCreated, nodesLoaded); +// +// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); +// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); +// InventoryFolderBase folder1 +// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); +// Assert.That(folder1, Is.Not.Null, "Could not find folder a"); +// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); +// Assert.That(folder2, Is.Not.Null, "Could not find folder b"); +// } } } -- cgit v1.1 From a60ca5236c247b88909a3c0462675627575b334c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 21:37:48 +0100 Subject: restore InventoryArchiverTests.TestReplicateArchivePathToUserInventory() to work with the new UserAccountService/InventoryService --- .../Archiver/Tests/InventoryArchiverTests.cs | 88 +++++++++------------- 1 file changed, 37 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e434e46..d339543 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -540,55 +540,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// Test replication of an archive path to the user's inventory. /// -// [Test] -// public void TestReplicateArchivePathToUserInventory() -// { -// TestHelper.InMethod(); -// //log4net.Config.XmlConfigurator.Configure(); -// -// Scene scene = SceneSetupHelpers.SetupScene("inventory"); -// CommunicationsManager commsManager = scene.CommsManager; -// CachedUserInfo userInfo; -// -// lock (this) -// { -// // !!! REFACTORING PROBLEM. This needs to be rewritten -// userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); -// Monitor.Wait(this, 60000); -// } -// -// //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); -// -// Dictionary foldersCreated = new Dictionary(); -// List nodesLoaded = new List(); -// -// string folder1Name = "a"; -// string folder2Name = "b"; -// string itemName = "c.lsl"; -// -// string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); -// string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); -// string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); -// -// string itemArchivePath -// = string.Format( -// "{0}{1}{2}{3}", -// ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); -// -// //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); -// -// new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) -// .ReplicateArchivePathToUserInventory( -// itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), -// foldersCreated, nodesLoaded); -// -// //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); -// //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); -// InventoryFolderBase folder1 -// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); -// Assert.That(folder1, Is.Not.Null, "Could not find folder a"); -// InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); -// Assert.That(folder2, Is.Not.Null, "Could not find folder b"); -// } + [Test] + public void TestReplicateArchivePathToUserInventory() + { + TestHelper.InMethod(); + //log4net.Config.XmlConfigurator.Configure(); + + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); + + Dictionary foldersCreated = new Dictionary(); + List nodesLoaded = new List(); + + string folder1Name = "a"; + string folder2Name = "b"; + string itemName = "c.lsl"; + + string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); + string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); + string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + + string itemArchivePath + = string.Format( + "{0}{1}{2}{3}", + ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); + + new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null) + .ReplicateArchivePathToUserInventory( + itemArchivePath, false, scene.InventoryService.GetRootFolder(ua1.PrincipalID), + foldersCreated, nodesLoaded); + + InventoryFolderBase folder1 + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, "a"); + Assert.That(folder1, Is.Not.Null, "Could not find folder a"); + InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); + Assert.That(folder2, Is.Not.Null, "Could not find folder b"); + } } -} +} \ No newline at end of file -- cgit v1.1 From 191db0e6a4327e8bf84350a541a9edc579ae1c54 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 May 2010 23:14:24 +0100 Subject: get TestSaveIarV0_1() uncommented but not running as a test yet since I didn't get the authentication server to work and my brain is about to fizzle out my ears --- .../Archiver/Tests/InventoryArchiverTests.cs | 205 ++++++++++----------- 1 file changed, 99 insertions(+), 106 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d339543..c81f295 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -76,125 +76,118 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Commenting for now! The mock inventory service needs more beef, at least for // GetFolderForType // REFACTORING PROBLEM. This needs to be rewritten. + //[Test] + public void TestSaveIarV0_1() + { + TestHelper.InMethod(); + log4net.Config.XmlConfigurator.Configure(); -// [Test] -// public void TestSaveIarV0_1() -// { -// TestHelper.InMethod(); -// //log4net.Config.XmlConfigurator.Configure(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); -// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); -// Scene scene = SceneSetupHelpers.SetupScene("Inventory"); -// SceneSetupHelpers.SetupSceneModules(scene, archiverModule); -// CommunicationsManager cm = scene.CommsManager; - -// // Create user -// string userFirstName = "Jock"; -// string userLastName = "Stirrup"; -// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - -// lock (this) -// { -// UserProfileTestUtils.CreateUserWithInventory( -// cm, userFirstName, userLastName, userId, InventoryReceived); -// Monitor.Wait(this, 60000); -// } + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + string userPassword = "troll"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); -// // Create asset -// SceneObjectGroup object1; -// SceneObjectPart part1; -// { -// string partName = "My Little Dog Object"; -// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); -// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); -// Vector3 groupPosition = new Vector3(10, 20, 30); -// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); -// Vector3 offsetPosition = new Vector3(5, 10, 15); - -// part1 -// = new SceneObjectPart( -// ownerId, shape, groupPosition, rotationOffset, offsetPosition); -// part1.Name = partName; - -// object1 = new SceneObjectGroup(part1); -// scene.AddNewSceneObject(object1, false); -// } - -// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); -// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); -// scene.AssetService.Store(asset1); - -// // Create item -// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); -// InventoryItemBase item1 = new InventoryItemBase(); -// item1.Name = "My Little Dog"; -// item1.AssetID = asset1.FullID; -// item1.ID = item1Id; -// InventoryFolderBase objsFolder -// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); -// item1.Folder = objsFolder.ID; -// scene.AddInventoryItem(userId, item1); - -// MemoryStream archiveWriteStream = new MemoryStream(); -// archiverModule.OnInventoryArchiveSaved += SaveCompleted; - -// mre.Reset(); -// archiverModule.ArchiveInventory( -// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); -// mre.WaitOne(60000, false); - -// byte[] archive = archiveWriteStream.ToArray(); -// MemoryStream archiveReadStream = new MemoryStream(archive); -// TarArchiveReader tar = new TarArchiveReader(archiveReadStream); - -// //bool gotControlFile = false; -// bool gotObject1File = false; -// //bool gotObject2File = false; -// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); -// string expectedObject1FilePath = string.Format( -// "{0}{1}{2}", -// ArchiveConstants.INVENTORY_PATH, -// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), -// expectedObject1FileName); + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "My Little Dog Object"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } -// string filePath; -// TarArchiveReader.TarEntryType tarEntryType; + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); + scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = "My Little Dog"; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); + item1.Folder = objsFolder.ID; + scene.AddInventoryItem(userId, item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + archiverModule.OnInventoryArchiveSaved += SaveCompleted; + + mre.Reset(); + archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); + mre.WaitOne(60000, false); + + byte[] archive = archiveWriteStream.ToArray(); + MemoryStream archiveReadStream = new MemoryStream(archive); + TarArchiveReader tar = new TarArchiveReader(archiveReadStream); + + //bool gotControlFile = false; + bool gotObject1File = false; + //bool gotObject2File = false; + string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); + string expectedObject1FilePath = string.Format( + "{0}{1}{2}", + ArchiveConstants.INVENTORY_PATH, + InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), + expectedObject1FileName); + + string filePath; + TarArchiveReader.TarEntryType tarEntryType; // Console.WriteLine("Reading archive"); -// while (tar.ReadEntry(out filePath, out tarEntryType) != null) -// { -// Console.WriteLine("Got {0}", filePath); + while (tar.ReadEntry(out filePath, out tarEntryType) != null) + { + Console.WriteLine("Got {0}", filePath); -//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) -//// { -//// gotControlFile = true; -//// } - -// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) +// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) // { -//// string fileName = filePath.Remove(0, "Objects/".Length); -//// -//// if (fileName.StartsWith(part1.Name)) -//// { -// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); -// gotObject1File = true; -//// } -//// else if (fileName.StartsWith(part2.Name)) -//// { -//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); -//// gotObject2File = true; -//// } +// gotControlFile = true; // } -// } + + if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) + { +// string fileName = filePath.Remove(0, "Objects/".Length); +// +// if (fileName.StartsWith(part1.Name)) +// { + Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); + gotObject1File = true; +// } +// else if (fileName.StartsWith(part2.Name)) +// { +// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); +// gotObject2File = true; +// } + } + } -//// Assert.That(gotControlFile, Is.True, "No control file in archive"); -// Assert.That(gotObject1File, Is.True, "No item1 file in archive"); -//// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); +// Assert.That(gotControlFile, Is.True, "No control file in archive"); + Assert.That(gotObject1File, Is.True, "No item1 file in archive"); +// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); -// // TODO: Test presence of more files and contents of files. -// } + // TODO: Test presence of more files and contents of files. + } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where -- cgit v1.1