Merge branch 'master' into careminster
commit
192e1e7cf0
|
@ -161,7 +161,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
string filePath = "ERROR";
|
||||
|
||||
List<InventoryFolderBase> folderCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(
|
||||
= InventoryArchiveUtils.FindFoldersByPath(
|
||||
m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath);
|
||||
|
||||
if (folderCandidates.Count == 0)
|
||||
|
@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
// iar name and try to find that instead.
|
||||
string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath);
|
||||
List<InventoryFolderBase> folderCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(
|
||||
= InventoryArchiveUtils.FindFoldersByPath(
|
||||
m_scene.InventoryService, m_userInfo.PrincipalID, plainPath);
|
||||
|
||||
if (folderCandidates.Count != 0)
|
||||
|
|
|
@ -52,13 +52,82 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// <summary>
|
||||
/// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We have no way of distinguishing folders with the same path
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
/// </remarks>
|
||||
/// <param name="inventoryService">
|
||||
/// Inventory service to query
|
||||
/// </param>
|
||||
/// <param name="userId">
|
||||
/// User id to search
|
||||
/// </param>
|
||||
/// <param name="path">
|
||||
/// The path to the required folder.
|
||||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>The folder found. Please note that if there are multiple folders with the same name then an
|
||||
/// unspecified one will be returned. If no such folder eixsts then null is returned</returns>
|
||||
public static InventoryFolderBase FindFolderByPath(
|
||||
IInventoryService inventoryService, UUID userId, string path)
|
||||
{
|
||||
List<InventoryFolderBase> folders = FindFoldersByPath(inventoryService, userId, path);
|
||||
|
||||
if (folders.Count == 0)
|
||||
return null;
|
||||
else
|
||||
return folders[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a folder given a PATH_DELIMITER delimited path starting from a given folder
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We have no way of distinguishing folders with the same path
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
/// </remarks>
|
||||
/// <param name="inventoryService">
|
||||
/// Inventory service to query
|
||||
/// </param>
|
||||
/// <param name="startFolder">
|
||||
/// The folder from which the path starts
|
||||
/// </param>
|
||||
/// <param name="path">
|
||||
/// The path to the required folder.
|
||||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>The folder found. Please note that if there are multiple folders with the same name then an
|
||||
/// unspecified one will be returned. If no such folder eixsts then null is returned</returns>
|
||||
public static InventoryFolderBase FindFolderByPath(
|
||||
IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
|
||||
{
|
||||
if (null == startFolder)
|
||||
return null;
|
||||
|
||||
List<InventoryFolderBase> folders = FindFoldersByPath(inventoryService, startFolder, path);
|
||||
|
||||
if (folders.Count == 0)
|
||||
return null;
|
||||
else
|
||||
return folders[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a set of folders given a PATH_DELIMITER delimited path starting from a user's root folder
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We have no way of distinguishing folders with the same path
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
/// </remarks>
|
||||
/// <param name="inventoryService">
|
||||
/// Inventory service to query
|
||||
/// </param>
|
||||
|
@ -70,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
|
||||
public static List<InventoryFolderBase> FindFolderByPath(
|
||||
public static List<InventoryFolderBase> FindFoldersByPath(
|
||||
IInventoryService inventoryService, UUID userId, string path)
|
||||
{
|
||||
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
|
||||
|
@ -78,19 +147,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
if (null == rootFolder)
|
||||
return new List<InventoryFolderBase>();
|
||||
|
||||
return FindFolderByPath(inventoryService, rootFolder, path);
|
||||
return FindFoldersByPath(inventoryService, rootFolder, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a folder given a PATH_DELIMITER delimited path starting from this folder
|
||||
/// Find a set of folders given a PATH_DELIMITER delimited path starting from this folder
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This method does not handle paths that contain multiple delimitors
|
||||
///
|
||||
/// FIXME: We have no way of distinguishing folders with the same path.
|
||||
///
|
||||
/// FIXME: Delimitors which occur in names themselves are not currently escapable.
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="inventoryService">
|
||||
/// Inventory service to query
|
||||
/// </param>
|
||||
|
@ -102,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
/// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
|
||||
/// </param>
|
||||
/// <returns>An empty list if the folder is not found, otherwise a list of all folders that match the name</returns>
|
||||
public static List<InventoryFolderBase> FindFolderByPath(
|
||||
public static List<InventoryFolderBase> FindFoldersByPath(
|
||||
IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
|
||||
{
|
||||
List<InventoryFolderBase> foundFolders = new List<InventoryFolderBase>();
|
||||
|
@ -133,12 +202,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
|
||||
InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "Found {0} folders in {1} for {2}", contents.Folders.Count, startFolder.Name, startFolder.Owner);
|
||||
|
||||
foreach (InventoryFolderBase folder in contents.Folders)
|
||||
{
|
||||
if (folder.Name == components[0])
|
||||
{
|
||||
if (components.Length > 1)
|
||||
foundFolders.AddRange(FindFolderByPath(inventoryService, folder, components[1]));
|
||||
foundFolders.AddRange(FindFoldersByPath(inventoryService, folder, components[1]));
|
||||
else
|
||||
foundFolders.Add(folder);
|
||||
}
|
||||
|
|
|
@ -272,6 +272,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
saveFolderContentsOnly = true;
|
||||
maxComponentIndex--;
|
||||
}
|
||||
else if (maxComponentIndex == -1)
|
||||
{
|
||||
// If the user has just specified "/", then don't save the root "My Inventory" folder. This is
|
||||
// more intuitive then requiring the user to specify "/*" for this.
|
||||
saveFolderContentsOnly = true;
|
||||
}
|
||||
|
||||
m_invPath = String.Empty;
|
||||
for (int i = 0; i <= maxComponentIndex; i++)
|
||||
|
@ -289,7 +295,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|||
{
|
||||
m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER));
|
||||
List<InventoryFolderBase> candidateFolders
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, rootFolder, m_invPath);
|
||||
if (candidateFolders.Count > 0)
|
||||
inventoryFolder = candidateFolders[0];
|
||||
}
|
||||
|
|
|
@ -48,124 +48,8 @@ using OpenSim.Tests.Common.Mock;
|
|||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathTests : InventoryArchiveTestCase
|
||||
public class InventoryArchiveLoadPathTests : InventoryArchiveTestCase
|
||||
{
|
||||
/// <summary>
|
||||
/// Test saving an inventory path to a V0.1 OpenSim Inventory Archive
|
||||
/// (subject to change since there is no fixed format yet).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestSavePathToIarV0_1()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
||||
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
SceneHelpers.SetupSceneModules(scene, archiverModule);
|
||||
|
||||
// Create user
|
||||
string userFirstName = "Jock";
|
||||
string userLastName = "Stirrup";
|
||||
string userPassword = "troll";
|
||||
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
|
||||
UserAccountHelpers.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")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(item1);
|
||||
|
||||
MemoryStream archiveWriteStream = new MemoryStream();
|
||||
archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||
|
||||
// Test saving a particular path
|
||||
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);
|
||||
|
||||
// if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
|
||||
// {
|
||||
// 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");
|
||||
|
||||
// TODO: Test presence of more files and contents of files.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test loading an IAR to various different inventory paths.
|
||||
/// </summary>
|
||||
|
@ -193,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
|
||||
|
||||
// Now try loading to a root child folder
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false);
|
||||
MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());
|
||||
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);
|
||||
|
||||
|
@ -202,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");
|
||||
|
||||
// Now try loading to a more deeply nested folder
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false);
|
||||
archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
|
||||
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);
|
||||
|
||||
|
@ -287,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
scene.AddInventoryItem(item1);
|
||||
|
||||
|
@ -351,12 +235,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
foldersCreated, nodesLoaded);
|
||||
|
||||
List<InventoryFolderBase> folder1Candidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
|
||||
Assert.That(folder1Candidates.Count, Is.EqualTo(1));
|
||||
|
||||
InventoryFolderBase folder1 = folder1Candidates[0];
|
||||
List<InventoryFolderBase> folder2aCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
|
||||
Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
|
@ -368,17 +252,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
foldersCreated, nodesLoaded);
|
||||
|
||||
List<InventoryFolderBase> folder1Candidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
|
||||
Assert.That(folder1Candidates.Count, Is.EqualTo(1));
|
||||
|
||||
InventoryFolderBase folder1 = folder1Candidates[0];
|
||||
|
||||
List<InventoryFolderBase> folder2aCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
|
||||
Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
|
||||
|
||||
List<InventoryFolderBase> folder2bCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2bName);
|
||||
Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
|
||||
InventoryFolderBase folder1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(
|
||||
scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false);
|
||||
|
||||
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
|
||||
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||
|
@ -414,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
||||
|
||||
List<InventoryFolderBase> folder1PostCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));
|
||||
|
||||
// FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
|
||||
|
@ -430,7 +314,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
// Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));
|
||||
|
||||
List<InventoryFolderBase> folder2PostCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1Post, "b");
|
||||
Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
|
@ -452,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
|
||||
InventoryFolderBase folder1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(
|
||||
scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
scene.InventoryService, ua1.PrincipalID, folder1ExistingName, false);
|
||||
|
||||
string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
|
||||
string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
|
||||
|
@ -465,13 +349,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
|
||||
|
||||
List<InventoryFolderBase> folder1PostCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);
|
||||
Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
|
||||
Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));
|
||||
|
||||
List<InventoryFolderBase> folder2PostCandidates
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1PostCandidates[0], "b");
|
||||
Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Data;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Serialization;
|
||||
using OpenSim.Framework.Serialization.External;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class InventoryArchiveLoadTests : InventoryArchiveTestCase
|
||||
{
|
||||
protected TestScene m_scene;
|
||||
protected InventoryArchiverModule m_archiverModule;
|
||||
|
||||
[SetUp]
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
SerialiserModule serialiserModule = new SerialiserModule();
|
||||
m_archiverModule = new InventoryArchiverModule();
|
||||
|
||||
m_scene = new SceneHelpers().SetupScene();
|
||||
SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadCoalesecedItem()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password");
|
||||
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);
|
||||
|
||||
InventoryItemBase coaItem
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
|
||||
|
||||
Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");
|
||||
|
||||
string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);
|
||||
|
||||
CoalescedSceneObjects coa;
|
||||
bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);
|
||||
|
||||
Assert.That(readResult, Is.True);
|
||||
Assert.That(coa.Count, Is.EqualTo(2));
|
||||
|
||||
List<SceneObjectGroup> coaObjects = coa.Objects;
|
||||
Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
|
||||
Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));
|
||||
|
||||
Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
|
||||
Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
|
||||
/// objects.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestLoadIarCreatorAccountPresent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
|
||||
|
||||
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
|
||||
InventoryItemBase foundItem1
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
|
||||
|
||||
Assert.That(
|
||||
foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
|
||||
"Loaded item non-uuid creator doesn't match original");
|
||||
Assert.That(
|
||||
foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
|
||||
"Loaded item uuid creator doesn't match original");
|
||||
Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
|
||||
"Loaded item owner doesn't match inventory reciever");
|
||||
|
||||
AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
string xmlData = Utils.BytesToString(asset1.Data);
|
||||
SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||
// /// an account exists with the same name as the creator, though not the same id.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void TestLoadIarV0_1SameNameCreator()
|
||||
// {
|
||||
// TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
//
|
||||
// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
|
||||
// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
|
||||
//
|
||||
// m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
|
||||
// InventoryItemBase foundItem1
|
||||
// = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
||||
//
|
||||
// Assert.That(
|
||||
// foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
|
||||
// "Loaded item non-uuid creator doesn't match original");
|
||||
// Assert.That(
|
||||
// foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
|
||||
// "Loaded item uuid creator doesn't match original");
|
||||
// Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
|
||||
// "Loaded item owner doesn't match inventory reciever");
|
||||
//
|
||||
// AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
// string xmlData = Utils.BytesToString(asset1.Data);
|
||||
// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
//
|
||||
// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||
/// the creator or an account with the creator's name does not exist within the system.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestLoadIarV0_1AbsentCreator()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password");
|
||||
m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
|
||||
|
||||
InventoryItemBase foundItem1
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
||||
|
||||
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
|
||||
Assert.That(
|
||||
foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
|
||||
"Loaded item non-uuid creator doesn't match that of the loading user");
|
||||
Assert.That(
|
||||
foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
|
||||
"Loaded item uuid creator doesn't match that of the loading user");
|
||||
|
||||
AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
string xmlData = Utils.BytesToString(asset1.Data);
|
||||
SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ using OpenSim.Tests.Common.Mock;
|
|||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class InventoryArchiverTests : InventoryArchiveTestCase
|
||||
public class InventoryArchiveSaveTests : InventoryArchiveTestCase
|
||||
{
|
||||
protected TestScene m_scene;
|
||||
protected InventoryArchiverModule m_archiverModule;
|
||||
|
@ -65,36 +65,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadCoalesecedItem()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password");
|
||||
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream);
|
||||
|
||||
InventoryItemBase coaItem
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_coaItemName);
|
||||
|
||||
Assert.That(coaItem, Is.Not.Null, "Didn't find loaded item 1");
|
||||
|
||||
string assetXml = AssetHelpers.ReadAssetAsString(m_scene.AssetService, coaItem.AssetID);
|
||||
|
||||
CoalescedSceneObjects coa;
|
||||
bool readResult = CoalescedSceneObjectsSerializer.TryFromXml(assetXml, out coa);
|
||||
|
||||
Assert.That(readResult, Is.True);
|
||||
Assert.That(coa.Count, Is.EqualTo(2));
|
||||
|
||||
List<SceneObjectGroup> coaObjects = coa.Objects;
|
||||
Assert.That(coaObjects[0].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000120")));
|
||||
Assert.That(coaObjects[0].AbsolutePosition, Is.EqualTo(new Vector3(15, 30, 45)));
|
||||
|
||||
Assert.That(coaObjects[1].UUID, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000140")));
|
||||
Assert.That(coaObjects[1].AbsolutePosition, Is.EqualTo(new Vector3(25, 50, 75)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that the IAR has the required files in the right order.
|
||||
/// </summary>
|
||||
|
@ -122,6 +92,139 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
Assert.That(iarr.ControlFileLoaded, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveRootFolderToIar()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
string userFirstName = "Jock";
|
||||
string userLastName = "Stirrup";
|
||||
string userPassword = "troll";
|
||||
UUID userId = TestHelpers.ParseTail(0x20);
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
|
||||
|
||||
MemoryStream archiveWriteStream = new MemoryStream();
|
||||
m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||
|
||||
mre.Reset();
|
||||
m_archiverModule.ArchiveInventory(
|
||||
Guid.NewGuid(), userFirstName, userLastName, "/", userPassword, archiveWriteStream);
|
||||
mre.WaitOne(60000, false);
|
||||
|
||||
// Test created iar
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||
|
||||
// InventoryArchiveUtils.
|
||||
bool gotObjectsFolder = false;
|
||||
|
||||
string objectsFolderName
|
||||
= string.Format(
|
||||
"{0}{1}",
|
||||
ArchiveConstants.INVENTORY_PATH,
|
||||
InventoryArchiveWriteRequest.CreateArchiveFolderName(
|
||||
UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, userId, "Objects")));
|
||||
|
||||
string filePath;
|
||||
TarArchiveReader.TarEntryType tarEntryType;
|
||||
|
||||
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
||||
{
|
||||
// Console.WriteLine("Got {0}", filePath);
|
||||
|
||||
// Lazily, we only bother to look for the system objects folder created when we call CreateUserWithInventory()
|
||||
// XXX: But really we need to stop all that stuff being created in tests or check for such folders
|
||||
// more thoroughly
|
||||
if (filePath == objectsFolderName)
|
||||
gotObjectsFolder = true;
|
||||
}
|
||||
|
||||
Assert.That(gotObjectsFolder, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveNonRootFolderToIar()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
string userFirstName = "Jock";
|
||||
string userLastName = "Stirrup";
|
||||
string userPassword = "troll";
|
||||
UUID userId = TestHelpers.ParseTail(0x20);
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);
|
||||
|
||||
// Create base folder
|
||||
InventoryFolderBase f1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1", true);
|
||||
|
||||
// Create item1
|
||||
SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Dog Object", 0x5);
|
||||
InventoryItemBase i1 = UserInventoryHelpers.AddInventoryItem(m_scene, so1, 0x50, 0x60, "f1");
|
||||
|
||||
// Create embedded folder
|
||||
InventoryFolderBase f1_1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1/f1.1", true);
|
||||
|
||||
// Create embedded item
|
||||
SceneObjectGroup so1_1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Cat Object", 0x6);
|
||||
InventoryItemBase i2 = UserInventoryHelpers.AddInventoryItem(m_scene, so1_1, 0x500, 0x600, "f1/f1.1");
|
||||
|
||||
MemoryStream archiveWriteStream = new MemoryStream();
|
||||
m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||
|
||||
mre.Reset();
|
||||
m_archiverModule.ArchiveInventory(
|
||||
Guid.NewGuid(), userFirstName, userLastName, "f1", userPassword, archiveWriteStream);
|
||||
mre.WaitOne(60000, false);
|
||||
|
||||
// Test created iar
|
||||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||
|
||||
// InventoryArchiveUtils.
|
||||
bool gotf1 = false, gotf1_1 = false, gotso1 = false, gotso2 = false;
|
||||
|
||||
string f1FileName
|
||||
= string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1));
|
||||
string f1_1FileName
|
||||
= string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1_1));
|
||||
string so1FileName
|
||||
= string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i1));
|
||||
string so2FileName
|
||||
= string.Format("{0}{1}", f1_1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i2));
|
||||
|
||||
string filePath;
|
||||
TarArchiveReader.TarEntryType tarEntryType;
|
||||
|
||||
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
||||
{
|
||||
// Console.WriteLine("Got {0}", filePath);
|
||||
|
||||
if (filePath == f1FileName)
|
||||
gotf1 = true;
|
||||
else if (filePath == f1_1FileName)
|
||||
gotf1_1 = true;
|
||||
else if (filePath == so1FileName)
|
||||
gotso1 = true;
|
||||
else if (filePath == so2FileName)
|
||||
gotso2 = true;
|
||||
}
|
||||
|
||||
// Assert.That(gotControlFile, Is.True, "No control file in archive");
|
||||
Assert.That(gotf1, Is.True);
|
||||
Assert.That(gotf1_1, Is.True);
|
||||
Assert.That(gotso1, Is.True);
|
||||
Assert.That(gotso2, Is.True);
|
||||
|
||||
// TODO: Test presence of more files and contents of files.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test saving a single inventory item to an IAR
|
||||
/// (subject to change since there is no fixed format yet).
|
||||
|
@ -155,7 +258,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
m_scene.AddInventoryItem(item1);
|
||||
|
||||
|
@ -250,7 +353,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
m_scene.AddInventoryItem(item1);
|
||||
|
||||
|
@ -317,101 +420,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
|||
|
||||
// TODO: Test presence of more files and contents of files.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized
|
||||
/// objects.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestLoadIarCreatorAccountPresent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood");
|
||||
|
||||
m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream);
|
||||
InventoryItemBase foundItem1
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name);
|
||||
|
||||
Assert.That(
|
||||
foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()),
|
||||
"Loaded item non-uuid creator doesn't match original");
|
||||
Assert.That(
|
||||
foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID),
|
||||
"Loaded item uuid creator doesn't match original");
|
||||
Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID),
|
||||
"Loaded item owner doesn't match inventory reciever");
|
||||
|
||||
AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
string xmlData = Utils.BytesToString(asset1.Data);
|
||||
SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID));
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||
// /// an account exists with the same name as the creator, though not the same id.
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public void TestLoadIarV0_1SameNameCreator()
|
||||
// {
|
||||
// TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
//
|
||||
// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "meowfood");
|
||||
// UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire");
|
||||
//
|
||||
// m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
|
||||
// InventoryItemBase foundItem1
|
||||
// = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
||||
//
|
||||
// Assert.That(
|
||||
// foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()),
|
||||
// "Loaded item non-uuid creator doesn't match original");
|
||||
// Assert.That(
|
||||
// foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID),
|
||||
// "Loaded item uuid creator doesn't match original");
|
||||
// Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID),
|
||||
// "Loaded item owner doesn't match inventory reciever");
|
||||
//
|
||||
// AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
// string xmlData = Utils.BytesToString(asset1.Data);
|
||||
// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
//
|
||||
// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where
|
||||
/// the creator or an account with the creator's name does not exist within the system.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestLoadIarV0_1AbsentCreator()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaMT, "password");
|
||||
m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream);
|
||||
|
||||
InventoryItemBase foundItem1
|
||||
= InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);
|
||||
|
||||
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
|
||||
Assert.That(
|
||||
foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()),
|
||||
"Loaded item non-uuid creator doesn't match that of the loading user");
|
||||
Assert.That(
|
||||
foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID),
|
||||
"Loaded item uuid creator doesn't match that of the loading user");
|
||||
|
||||
AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString());
|
||||
string xmlData = Utils.BytesToString(asset1.Data);
|
||||
SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
|
||||
Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
m_scene.AddInventoryItem(item1);
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
|
|||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
m_scene.AddInventoryItem(item1);
|
||||
|
||||
|
|
|
@ -156,6 +156,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids)
|
||||
{
|
||||
// m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key);
|
||||
|
||||
// m_assetService.Get(kvp.Key.ToString(), kvp.Value, PreAssetRequestCallback);
|
||||
AssetBase asset = m_assetService.Get(kvp.Key.ToString());
|
||||
PreAssetRequestCallback(kvp.Key.ToString(), kvp.Value, asset);
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
|
||||
UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
|
||||
InventoryFolderBase folder1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1");
|
||||
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);
|
||||
|
||||
IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
|
||||
scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
|
||||
|
||||
InventoryFolderBase folder
|
||||
= InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
|
||||
= InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
|
||||
|
||||
// Perform test
|
||||
scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID);
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
Scene scene = new SceneHelpers().SetupScene();
|
||||
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
|
||||
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName);
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
|
||||
|
||||
List<InventoryFolderBase> oneFolder
|
||||
= UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
|
||||
|
@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
InventoryFolderBase firstRetrievedFolder = oneFolder[0];
|
||||
Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName));
|
||||
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName);
|
||||
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
|
||||
|
||||
List<InventoryFolderBase> twoFolders
|
||||
= UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
|
||||
|
@ -121,7 +121,7 @@ namespace OpenSim.Region.Framework.Tests
|
|||
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
|
||||
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
|
||||
InventoryFolderBase folder1
|
||||
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1");
|
||||
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
|
||||
|
||||
scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ namespace OpenSim.Tests.Common
|
|||
/// <summary>
|
||||
/// Add an existing scene object as an item in the user's inventory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Will be added to the system Objects folder.
|
||||
/// </remarks>
|
||||
/// <param name='scene'></param>
|
||||
/// <param name='so'></param>
|
||||
/// <param name='inventoryIdTail'></param>
|
||||
|
@ -63,7 +66,29 @@ namespace OpenSim.Tests.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a notecard in the objects folder and specify an item id.
|
||||
/// Add an existing scene object as an item in the user's inventory at the given path.
|
||||
/// </summary>
|
||||
/// <param name='scene'></param>
|
||||
/// <param name='so'></param>
|
||||
/// <param name='inventoryIdTail'></param>
|
||||
/// <param name='assetIdTail'></param>
|
||||
/// <returns>The inventory item created.</returns>
|
||||
public static InventoryItemBase AddInventoryItem(
|
||||
Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail, string path)
|
||||
{
|
||||
return AddInventoryItem(
|
||||
scene,
|
||||
so.Name,
|
||||
TestHelpers.ParseTail(inventoryIdTail),
|
||||
InventoryType.Object,
|
||||
AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
|
||||
so.OwnerID,
|
||||
path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given item to the existing system folder for its type (e.g. an object will go in the "Objects"
|
||||
/// folder).
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="itemName"></param>
|
||||
|
@ -74,6 +99,25 @@ namespace OpenSim.Tests.Common
|
|||
/// <returns></returns>
|
||||
private static InventoryItemBase AddInventoryItem(
|
||||
Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
|
||||
{
|
||||
return AddInventoryItem(
|
||||
scene, itemName, itemId, itemType, asset, userId,
|
||||
scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type).Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given item to an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="itemName"></param>
|
||||
/// <param name="itemId"></param>
|
||||
/// <param name="itemType"></param>
|
||||
/// <param name="asset">The serialized asset for this item</param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="path">Existing inventory path at which to add.</param>
|
||||
/// <returns></returns>
|
||||
private static InventoryItemBase AddInventoryItem(
|
||||
Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId, string path)
|
||||
{
|
||||
scene.AssetService.Store(asset);
|
||||
|
||||
|
@ -85,7 +129,7 @@ namespace OpenSim.Tests.Common
|
|||
item.AssetType = asset.Type;
|
||||
item.InvType = (int)itemType;
|
||||
|
||||
InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);
|
||||
InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];
|
||||
|
||||
item.Folder = folder.ID;
|
||||
scene.AddInventoryItem(item);
|
||||
|
@ -156,58 +200,83 @@ namespace OpenSim.Tests.Common
|
|||
/// <summary>
|
||||
/// Create inventory folders starting from the user's root folder.
|
||||
/// </summary>
|
||||
///
|
||||
/// Ignores any existing folders with the same name
|
||||
///
|
||||
/// <param name="inventoryService"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="path">
|
||||
/// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
|
||||
/// </param>
|
||||
/// <param name="useExistingFolders">
|
||||
/// If true, then folders in the path which already the same name are
|
||||
/// used. This applies to the terminal folder as well.
|
||||
/// If false, then all folders in the path are created, even if there is already a folder at a particular
|
||||
/// level with the same name.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The folder created. If the path contains multiple folders then the last one created is returned.
|
||||
/// Will return null if the root folder could not be found.
|
||||
/// </returns>
|
||||
public static InventoryFolderBase CreateInventoryFolder(
|
||||
IInventoryService inventoryService, UUID userId, string path)
|
||||
IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
|
||||
{
|
||||
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
|
||||
|
||||
if (null == rootFolder)
|
||||
return null;
|
||||
|
||||
return CreateInventoryFolder(inventoryService, rootFolder, path);
|
||||
return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create inventory folders starting from a given parent folder
|
||||
/// </summary>
|
||||
///
|
||||
/// Ignores any existing folders with the same name
|
||||
///
|
||||
/// <remarks>
|
||||
/// If any stem of the path names folders that already exist then these are not recreated. This includes the
|
||||
/// final folder.
|
||||
/// TODO: May need to make it an option to create duplicate folders.
|
||||
/// </remarks>
|
||||
/// <param name="inventoryService"></param>
|
||||
/// <param name="parentFolder"></param>
|
||||
/// <param name="path">
|
||||
/// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
|
||||
/// The folder to create.
|
||||
/// </param>
|
||||
/// <param name="useExistingFolders">
|
||||
/// If true, then folders in the path which already the same name are
|
||||
/// used. This applies to the terminal folder as well.
|
||||
/// If false, then all folders in the path are created, even if there is already a folder at a particular
|
||||
/// level with the same name.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The folder created. If the path contains multiple folders then the last one created is returned.
|
||||
/// </returns>
|
||||
public static InventoryFolderBase CreateInventoryFolder(
|
||||
IInventoryService inventoryService, InventoryFolderBase parentFolder, string path)
|
||||
IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
|
||||
{
|
||||
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
|
||||
|
||||
InventoryFolderBase newFolder
|
||||
InventoryFolderBase folder = null;
|
||||
|
||||
if (useExistingFolders)
|
||||
folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]);
|
||||
|
||||
if (folder == null)
|
||||
{
|
||||
// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
|
||||
|
||||
folder
|
||||
= new InventoryFolderBase(
|
||||
UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
|
||||
|
||||
inventoryService.AddFolder(newFolder);
|
||||
inventoryService.AddFolder(folder);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("Found existing folder {0}", folder.Name);
|
||||
// }
|
||||
|
||||
if (components.Length > 1)
|
||||
return CreateInventoryFolder(inventoryService, newFolder, components[1]);
|
||||
return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders);
|
||||
else
|
||||
return newFolder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -237,7 +306,7 @@ namespace OpenSim.Tests.Common
|
|||
/// <returns>An empty list if no matching folders were found</returns>
|
||||
public static List<InventoryFolderBase> GetInventoryFolders(IInventoryService inventoryService, UUID userId, string path)
|
||||
{
|
||||
return InventoryArchiveUtils.FindFolderByPath(inventoryService, userId, path);
|
||||
return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue