aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs17
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs104
4 files changed, 126 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index 350ad66..915b59e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -218,24 +218,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
218 218
219 public bool AddItem(InventoryItemBase item) 219 public bool AddItem(InventoryItemBase item)
220 { 220 {
221 m_log.DebugFormat( 221// m_log.DebugFormat(
222 "[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}", 222// "[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}",
223 item.Name, item.Owner, item.Folder); 223// item.Name, item.Owner, item.Folder);
224 224
225 if (UUID.Zero == item.Folder) 225 if (UUID.Zero == item.Folder)
226 { 226 {
227 InventoryFolderBase f = m_InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); 227 InventoryFolderBase f = m_InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType);
228 if (f != null) 228 if (f != null)
229 { 229 {
230// m_log.DebugFormat(
231// "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}",
232// f.Name, (AssetType)f.Type, item.Name);
233
230 item.Folder = f.ID; 234 item.Folder = f.ID;
231 } 235 }
232 else 236 else
233 { 237 {
234 f = m_InventoryService.GetRootFolder(item.Owner); 238 f = m_InventoryService.GetRootFolder(item.Owner);
235 if (f != null) 239 if (f != null)
240 {
236 item.Folder = f.ID; 241 item.Folder = f.ID;
242 }
237 else 243 else
244 {
245// m_log.WarnFormat(
246// "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
247// item.Owner, item.Name);
238 return false; 248 return false;
249 }
239 } 250 }
240 } 251 }
241 252
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 7ac3bb9..4211fa9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -240,9 +240,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
240 { 240 {
241 f = m_RemoteConnector.GetRootFolder(item.Owner); 241 f = m_RemoteConnector.GetRootFolder(item.Owner);
242 if (f != null) 242 if (f != null)
243 {
243 item.Folder = f.ID; 244 item.Folder = f.ID;
245 }
244 else 246 else
247 {
248 m_log.WarnFormat(
249 "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified",
250 item.Owner, item.Name);
245 return false; 251 return false;
252 }
246 } 253 }
247 } 254 }
248 255
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 241e100..fa9653f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
106 else 106 else
107 { 107 {
108 m_log.WarnFormat( 108 m_log.WarnFormat(
109 "[AGENT INVENTORY]: Agent {1} could not add item {2} {3}", 109 "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}",
110 AgentID, item.Name, item.ID); 110 AgentID, item.Name, item.ID);
111 111
112 return; 112 return;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
new file mode 100644
index 0000000..f848e80
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenMetaverse.Assets;
40using OpenSim.Framework;
41using OpenSim.Framework.Communications;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
45using OpenSim.Region.CoreModules.World.Serialiser;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
47using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49using OpenSim.Tests.Common.Setup;
50
51namespace OpenSim.Region.Framework.Tests
52{
53 [TestFixture]
54 public class TaskInventoryTests
55 {
56 /// <summary>
57 /// Test MoveTaskInventoryItem where the item has no parent folder assigned.
58 /// </summary>
59 /// This should place it in the most suitable user folder.
60 [Test]
61 public void TestMoveTaskInventoryItemNoParent()
62 {
63 TestHelper.InMethod();
64// log4net.Config.XmlConfigurator.Configure();
65
66 Scene scene = SceneSetupHelpers.SetupScene("inventory");
67
68 // Create user
69 string userFirstName = "Jock";
70 string userLastName = "Stirrup";
71 string userPassword = "troll";
72 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
73 UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
74
75 // Create scene object
76 string part1Name = "part1";
77 UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000");
78 SceneObjectPart part1
79 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
80 { Name = part1Name, UUID = part1Id };
81 SceneObjectGroup so = new SceneObjectGroup(part1);
82
83 // Create scene object inventory item
84 AssetNotecard nc = new AssetNotecard("Hello World!");
85 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
86 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
87 AssetBase ncAsset
88 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
89 scene.AssetService.Store(ncAsset);
90 TaskInventoryItem ncItem
91 = new TaskInventoryItem
92 { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid,
93 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
94 part1.Inventory.AddInventoryItem(ncItem, true);
95
96 // Perform test
97 scene.MoveTaskInventoryItem(userId, UUID.Zero, part1, ncItemUuid);
98
99 InventoryItemBase ncUserItem
100 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userId, "Notecards/ncItem");
101 Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found");
102 }
103 }
104} \ No newline at end of file