29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Services.Base;
36 using OpenSim.Services.Interfaces;
43 namespace OpenSim.Services.InventoryService
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 get {
return m_LibraryRootFolder; }
60 private UUID libOwner =
new UUID(
"11111111-1111-0000-0000-000100bba000");
66 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
67 =
new Dictionary<UUID, InventoryFolderImpl>();
72 string pLibrariesLocation = Path.Combine(
"inventory",
"Libraries.xml");
73 string pLibName =
"OpenSim Library";
75 IConfig libConfig = config.Configs[
"LibraryService"];
76 if (libConfig != null)
78 pLibrariesLocation = libConfig.GetString(
"DefaultLibrary", pLibrariesLocation);
79 pLibName = libConfig.GetString(
"LibraryName", pLibName);
82 m_log.Debug(
"[LIBRARY]: Starting library service...");
85 m_LibraryRootFolder.Owner = libOwner;
86 m_LibraryRootFolder.ID =
new UUID(
"00000112-000f-0000-0000-000100bba000");
87 m_LibraryRootFolder.Name = pLibName;
88 m_LibraryRootFolder.ParentID = UUID.Zero;
89 m_LibraryRootFolder.Type = (short)8;
90 m_LibraryRootFolder.Version = (ushort)1;
92 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
94 LoadLibraries(pLibrariesLocation);
98 int assetType,
int invType, UUID parentFolderID)
101 item.Owner = libOwner;
102 item.CreatorId = libOwner.ToString();
103 item.ID = inventoryID;
104 item.AssetID = assetID;
105 item.Description = description;
107 item.AssetType = assetType;
108 item.InvType = invType;
109 item.Folder = parentFolderID;
110 item.BasePermissions = 0x7FFFFFFF;
111 item.EveryOnePermissions = 0x7FFFFFFF;
112 item.CurrentPermissions = 0x7FFFFFFF;
113 item.NextPermissions = 0x7FFFFFFF;
124 m_log.InfoFormat(
"[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
125 LoadFromFile(librariesControlPath,
"Libraries control", ReadLibraryFromConfig);
134 string basePath = Path.GetDirectoryName(path);
137 basePath, config.GetString(
"foldersFile", String.Empty));
139 LoadFromFile(foldersPath,
"Library folders", ReadFolderFromConfig);
143 basePath, config.GetString(
"itemsFile", String.Empty));
145 LoadFromFile(itemsPath,
"Library items", ReadItemFromConfig);
152 private void ReadFolderFromConfig(IConfig config,
string path)
156 folderInfo.ID =
new UUID(config.GetString(
"folderID", m_LibraryRootFolder.ID.ToString()));
157 folderInfo.Name = config.GetString(
"name",
"unknown");
158 folderInfo.ParentID =
new UUID(config.GetString(
"parentFolderID", m_LibraryRootFolder.ID.ToString()));
159 folderInfo.Type = (short)config.GetInt(
"type", 8);
161 folderInfo.Owner = libOwner;
162 folderInfo.Version = 1;
164 if (libraryFolders.ContainsKey(folderInfo.
ParentID))
168 libraryFolders.Add(folderInfo.ID, folderInfo);
169 parentFolder.AddChildFolder(folderInfo);
176 "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
177 folderInfo.Name, folderInfo.ID, folderInfo.ParentID);
185 private void ReadItemFromConfig(IConfig config,
string path)
188 item.Owner = libOwner;
189 item.CreatorId = libOwner.ToString();
190 item.ID =
new UUID(config.GetString(
"inventoryID", m_LibraryRootFolder.ID.ToString()));
191 item.AssetID =
new UUID(config.GetString(
"assetID", item.
ID.ToString()));
192 item.Folder =
new UUID(config.GetString(
"folderID", m_LibraryRootFolder.ID.ToString()));
193 item.Name = config.GetString(
"name", String.Empty);
194 item.Description = config.GetString(
"description", item.Name);
195 item.InvType = config.GetInt(
"inventoryType", 0);
196 item.AssetType = config.GetInt(
"assetType", item.InvType);
197 item.CurrentPermissions = (uint)config.GetLong(
"currentPermissions", (uint)
PermissionMask.All);
198 item.NextPermissions = (uint)config.GetLong(
"nextPermissions", (uint)
PermissionMask.All);
199 item.EveryOnePermissions
201 item.BasePermissions = (uint)config.GetLong(
"basePermissions", (uint)
PermissionMask.All);
202 item.Flags = (uint)config.GetInt(
"flags", 0);
204 if (libraryFolders.ContainsKey(item.
Folder))
209 parentFolder.Items.Add(item.ID, item);
213 m_log.WarnFormat(
"[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
219 "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
220 item.Name, item.ID, item.Folder);
224 private delegate
void ConfigAction(IConfig config,
string path);
232 private static void LoadFromFile(
string path,
string fileDescription, ConfigAction action)
234 if (
File.Exists(path))
238 XmlConfigSource source =
new XmlConfigSource(path);
240 for (
int i = 0; i < source.Configs.Count; i++)
242 action(source.Configs[i], path);
245 catch (XmlException e)
247 m_log.ErrorFormat(
"[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
252 m_log.ErrorFormat(
"[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
263 Dictionary<UUID, InventoryFolderImpl> fs =
new Dictionary<UUID, InventoryFolderImpl>();
264 fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
265 List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder);
276 List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls();
277 List<InventoryFolderImpl> subs =
new List<InventoryFolderImpl>();
279 subs.AddRange(TraverseFolder(f));
281 folders.AddRange(subs);
void ReadLibraryFromConfig(IConfig config, string path)
Read a library set from config
OpenSim.Framework.PermissionMask PermissionMask
Inventory Item - contains all the properties associated with an individual inventory piece...
Interactive OpenSim region server
UUID ID
A UUID containing the ID for the inventory node itself
LibraryService(IConfigSource config)
Dictionary< UUID, InventoryFolderImpl > GetAllFolders()
Looks like a simple getter, but is written like this for some consistency with the other Request meth...
void LoadLibraries(string librariesControlPath)
Use the asset set information at path to load assets
InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, int assetType, int invType, UUID parentFolderID)
Basically a hack to give us a Inventory library while we don't have a inventory server once the serve...