clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.Linq; |
||
31 | using System.Reflection; |
||
32 | using log4net; |
||
33 | using OpenMetaverse; |
||
34 | using OpenSim.Framework; |
||
35 | using OpenSim.Data; |
||
36 | using OpenSim.Data.Null; |
||
37 | |||
38 | namespace OpenSim.Tests.Common.Mock |
||
39 | { |
||
40 | public class TestXInventoryDataPlugin : NullGenericDataHandler, IXInventoryData |
||
41 | { |
||
42 | private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>(); |
||
43 | private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>(); |
||
44 | |||
45 | public TestXInventoryDataPlugin(string conn, string realm) {} |
||
46 | |||
47 | public XInventoryItem[] GetItems(string[] fields, string[] vals) |
||
48 | { |
||
49 | List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); |
||
50 | |||
51 | return origItems.Select(i => i.Clone()).ToArray(); |
||
52 | } |
||
53 | |||
54 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) |
||
55 | { |
||
56 | // Console.WriteLine( |
||
57 | // "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals)); |
||
58 | |||
59 | List<XInventoryFolder> origFolders |
||
60 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); |
||
61 | |||
62 | return origFolders.Select(f => f.Clone()).ToArray(); |
||
63 | } |
||
64 | |||
65 | public bool StoreFolder(XInventoryFolder folder) |
||
66 | { |
||
67 | m_allFolders[folder.folderID] = folder.Clone(); |
||
68 | |||
69 | // Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID); |
||
70 | |||
71 | return true; |
||
72 | } |
||
73 | |||
74 | public bool StoreItem(XInventoryItem item) |
||
75 | { |
||
76 | m_allItems[item.inventoryID] = item.Clone(); |
||
77 | |||
78 | // Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); |
||
79 | |||
80 | return true; |
||
81 | } |
||
82 | |||
83 | public bool DeleteFolders(string field, string val) |
||
84 | { |
||
85 | return DeleteFolders(new string[] { field }, new string[] { val }); |
||
86 | } |
||
87 | |||
88 | public bool DeleteFolders(string[] fields, string[] vals) |
||
89 | { |
||
90 | XInventoryFolder[] foldersToDelete = GetFolders(fields, vals); |
||
91 | Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID)); |
||
92 | |||
93 | return true; |
||
94 | } |
||
95 | |||
96 | public bool DeleteItems(string field, string val) |
||
97 | { |
||
98 | return DeleteItems(new string[] { field }, new string[] { val }); |
||
99 | } |
||
100 | |||
101 | public bool DeleteItems(string[] fields, string[] vals) |
||
102 | { |
||
103 | XInventoryItem[] itemsToDelete = GetItems(fields, vals); |
||
104 | Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID)); |
||
105 | |||
106 | return true; |
||
107 | } |
||
108 | |||
109 | public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } |
||
110 | |||
111 | public bool MoveFolder(string id, string newParent) |
||
112 | { |
||
113 | // Don't use GetFolders() here - it takes a clone! |
||
114 | XInventoryFolder folder = m_allFolders[new UUID(id)]; |
||
115 | |||
116 | if (folder == null) |
||
117 | return false; |
||
118 | |||
119 | folder.parentFolderID = new UUID(newParent); |
||
120 | |||
121 | // XInventoryFolder[] newParentFolders |
||
122 | // = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() }); |
||
123 | |||
124 | // Console.WriteLine( |
||
125 | // "Moved folder {0} {1}, to {2} {3}", |
||
126 | // folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID); |
||
127 | |||
128 | // TODO: Really need to implement folder version incrementing, though this should be common code anyway, |
||
129 | // not reimplemented in each db plugin. |
||
130 | |||
131 | return true; |
||
132 | } |
||
133 | |||
134 | public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } |
||
135 | public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } |
||
136 | } |
||
137 | } |