aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs257
-rw-r--r--OpenSim/Framework/Communications/Osp/OspResolver.cs1
2 files changed, 0 insertions, 258 deletions
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
deleted file mode 100644
index 74ba0a5..0000000
--- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs
+++ /dev/null
@@ -1,257 +0,0 @@
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.IO;
31using System.Reflection;
32using System.Xml;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36
37namespace OpenSim.Framework.Communications.Cache
38{
39 /// <summary>
40 /// Basically a hack to give us a Inventory library while we don't have a inventory server
41 /// once the server is fully implemented then should read the data from that
42 /// </summary>
43 public class LibraryRootFolder : InventoryFolderImpl
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000");
48
49 /// <summary>
50 /// Holds the root library folder and all its descendents. This is really only used during inventory
51 /// setup so that we don't have to repeatedly search the tree of library folders.
52 /// </summary>
53 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
54 = new Dictionary<UUID, InventoryFolderImpl>();
55
56 public LibraryRootFolder(string pLibrariesLocation)
57 {
58 Owner = libOwner;
59 ID = new UUID("00000112-000f-0000-0000-000100bba000");
60 Name = "OpenSim Library";
61 ParentID = UUID.Zero;
62 Type = (short) 8;
63 Version = (ushort) 1;
64
65 libraryFolders.Add(ID, this);
66
67 LoadLibraries(pLibrariesLocation);
68 }
69
70 public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description,
71 int assetType, int invType, UUID parentFolderID)
72 {
73 InventoryItemBase item = new InventoryItemBase();
74 item.Owner = libOwner;
75 item.CreatorId = libOwner.ToString();
76 item.ID = inventoryID;
77 item.AssetID = assetID;
78 item.Description = description;
79 item.Name = name;
80 item.AssetType = assetType;
81 item.InvType = invType;
82 item.Folder = parentFolderID;
83 item.BasePermissions = 0x7FFFFFFF;
84 item.EveryOnePermissions = 0x7FFFFFFF;
85 item.CurrentPermissions = 0x7FFFFFFF;
86 item.NextPermissions = 0x7FFFFFFF;
87 return item;
88 }
89
90 /// <summary>
91 /// Use the asset set information at path to load assets
92 /// </summary>
93 /// <param name="path"></param>
94 /// <param name="assets"></param>
95 protected void LoadLibraries(string librariesControlPath)
96 {
97 m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
98 LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
99 }
100
101 /// <summary>
102 /// Read a library set from config
103 /// </summary>
104 /// <param name="config"></param>
105 protected void ReadLibraryFromConfig(IConfig config, string path)
106 {
107 string basePath = Path.GetDirectoryName(path);
108 string foldersPath
109 = Path.Combine(
110 basePath, config.GetString("foldersFile", String.Empty));
111
112 LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
113
114 string itemsPath
115 = Path.Combine(
116 basePath, config.GetString("itemsFile", String.Empty));
117
118 LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
119 }
120
121 /// <summary>
122 /// Read a library inventory folder from a loaded configuration
123 /// </summary>
124 /// <param name="source"></param>
125 private void ReadFolderFromConfig(IConfig config, string path)
126 {
127 InventoryFolderImpl folderInfo = new InventoryFolderImpl();
128
129 folderInfo.ID = new UUID(config.GetString("folderID", ID.ToString()));
130 folderInfo.Name = config.GetString("name", "unknown");
131 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", ID.ToString()));
132 folderInfo.Type = (short)config.GetInt("type", 8);
133
134 folderInfo.Owner = libOwner;
135 folderInfo.Version = 1;
136
137 if (libraryFolders.ContainsKey(folderInfo.ParentID))
138 {
139 InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID];
140
141 libraryFolders.Add(folderInfo.ID, folderInfo);
142 parentFolder.AddChildFolder(folderInfo);
143
144// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
145 }
146 else
147 {
148 m_log.WarnFormat(
149 "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
150 folderInfo.Name, folderInfo.ID, folderInfo.ParentID);
151 }
152 }
153
154 /// <summary>
155 /// Read a library inventory item metadata from a loaded configuration
156 /// </summary>
157 /// <param name="source"></param>
158 private void ReadItemFromConfig(IConfig config, string path)
159 {
160 InventoryItemBase item = new InventoryItemBase();
161 item.Owner = libOwner;
162 item.CreatorId = libOwner.ToString();
163 item.ID = new UUID(config.GetString("inventoryID", ID.ToString()));
164 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString()));
165 item.Folder = new UUID(config.GetString("folderID", ID.ToString()));
166 item.Name = config.GetString("name", String.Empty);
167 item.Description = config.GetString("description", item.Name);
168 item.InvType = config.GetInt("inventoryType", 0);
169 item.AssetType = config.GetInt("assetType", item.InvType);
170 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF);
171 item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF);
172 item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF);
173 item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF);
174 item.Flags = (uint)config.GetInt("flags", 0);
175
176 if (libraryFolders.ContainsKey(item.Folder))
177 {
178 InventoryFolderImpl parentFolder = libraryFolders[item.Folder];
179 try
180 {
181 parentFolder.Items.Add(item.ID, item);
182 }
183 catch (Exception)
184 {
185 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
186 }
187 }
188 else
189 {
190 m_log.WarnFormat(
191 "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
192 item.Name, item.ID, item.Folder);
193 }
194 }
195
196 private delegate void ConfigAction(IConfig config, string path);
197
198 /// <summary>
199 /// Load the given configuration at a path and perform an action on each Config contained within it
200 /// </summary>
201 /// <param name="path"></param>
202 /// <param name="fileDescription"></param>
203 /// <param name="action"></param>
204 private static void LoadFromFile(string path, string fileDescription, ConfigAction action)
205 {
206 if (File.Exists(path))
207 {
208 try
209 {
210 XmlConfigSource source = new XmlConfigSource(path);
211
212 for (int i = 0; i < source.Configs.Count; i++)
213 {
214 action(source.Configs[i], path);
215 }
216 }
217 catch (XmlException e)
218 {
219 m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
220 }
221 }
222 else
223 {
224 m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
225 }
226 }
227
228 /// <summary>
229 /// Looks like a simple getter, but is written like this for some consistency with the other Request
230 /// methods in the superclass
231 /// </summary>
232 /// <returns></returns>
233 public Dictionary<UUID, InventoryFolderImpl> RequestSelfAndDescendentFolders()
234 {
235 Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>();
236 fs.Add(ID, this);
237 List<InventoryFolderImpl> fis = TraverseFolder(this);
238 foreach (InventoryFolderImpl f in fis)
239 {
240 fs.Add(f.ID, f);
241 }
242 //return libraryFolders;
243 return fs;
244 }
245
246 private List<InventoryFolderImpl> TraverseFolder(InventoryFolderImpl node)
247 {
248 List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls();
249 List<InventoryFolderImpl> subs = new List<InventoryFolderImpl>();
250 foreach (InventoryFolderImpl f in folders)
251 subs.AddRange(TraverseFolder(f));
252
253 folders.AddRange(subs);
254 return folders;
255 }
256 }
257}
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs
index 14f813a..2e55f53 100644
--- a/OpenSim/Framework/Communications/Osp/OspResolver.cs
+++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs
@@ -30,7 +30,6 @@ using System.Text;
30using log4net; 30using log4net;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
35 34
36namespace OpenSim.Framework.Communications.Osp 35namespace OpenSim.Framework.Communications.Osp