29 using System.Collections.Generic;
31 using OpenSim.Framework;
32 using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
33 using OpenSim.Region.Framework.Scenes;
34 using OpenSim.Services.Interfaces;
36 namespace OpenSim.Tests.Common
41 public static class UserInventoryHelpers
43 public static readonly
string PATH_DELIMITER =
"/";
59 return AddInventoryItem(
62 TestHelpers.ParseTail(inventoryIdTail),
64 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
79 return AddInventoryItem(
82 TestHelpers.ParseTail(inventoryIdTail),
84 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
101 Scene scene,
string itemName, UUID itemId, InventoryType itemType,
AssetBase asset, UUID userId)
103 return AddInventoryItem(
104 scene, itemName, itemId, itemType, asset, userId,
120 Scene scene,
string itemName, UUID itemId, InventoryType itemType,
AssetBase asset, UUID userId,
string path)
122 scene.AssetService.Store(asset);
125 item.Name = itemName;
126 item.AssetID = asset.FullID;
129 item.AssetType = asset.Type;
130 item.InvType = (int)itemType;
132 InventoryFolderBase folder = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, path)[0];
134 item.Folder = folder.ID;
135 scene.AddInventoryItem(item);
150 return CreateInventoryItem(scene, itemName,
UUID.Random(), UUID.Random(), userId, InventoryType.Notecard);
163 Scene scene,
string itemName, UUID userId, InventoryType type)
165 return CreateInventoryItem(scene, itemName,
UUID.Random(), UUID.Random(), userId, type);
179 Scene scene,
string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType)
183 if (itemType == InventoryType.Notecard)
185 asset = AssetHelpers.CreateNotecardAsset();
186 asset.CreatorID = userId.ToString();
188 else if (itemType == InventoryType.Object)
190 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
194 throw new Exception(
string.Format(
"Inventory type {0} not supported", itemType));
197 return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId);
219 IInventoryService inventoryService, UUID userId,
string path,
bool useExistingFolders)
244 IInventoryService inventoryService, UUID userId, UUID folderId,
string path,
bool useExistingFolders)
248 if (null == rootFolder)
280 string[] components = path.Split(
new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
284 if (useExistingFolders)
285 folder = InventoryArchiveUtils.FindFolderByPath(inventoryService, parentFolder, components[0]);
291 UUID folderIdForCreate;
293 if (components.Length > 1)
294 folderIdForCreate = UUID.Random();
296 folderIdForCreate = folderId;
300 folderIdForCreate, components[0], parentFolder.Owner, (
short)AssetType.Unknown, parentFolder.ID, 0);
302 inventoryService.AddFolder(folder);
309 if (components.Length > 1)
325 List<InventoryFolderBase> folders = GetInventoryFolders(inventoryService, userId, path);
327 if (folders.Count != 0)
340 public static List<InventoryFolderBase> GetInventoryFolders(
IInventoryService inventoryService, UUID userId,
string path)
342 return InventoryArchiveUtils.FindFoldersByPath(inventoryService, userId, path);
355 return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path);
365 public static List<InventoryItemBase> GetInventoryItems(
IInventoryService inventoryService, UUID userId,
string path)
367 return InventoryArchiveUtils.FindItemsByPath(inventoryService, userId, path);
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
sbyte Type
(sbyte) AssetType enum
Asset class. All Assets are reference by this class or a class derived from this class ...
Inventory Item - contains all the properties associated with an individual inventory piece...
delegate void CreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, string folderName, UUID parentID)
IInventoryService InventoryService
override string Name
The name of an object grouping is always the same as its root part
InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
Gets the user folder for the given folder-type