diff options
Diffstat (limited to 'OpenSim/Services/InventoryService/LibraryService.cs')
-rw-r--r-- | OpenSim/Services/InventoryService/LibraryService.cs | 87 |
1 files changed, 63 insertions, 24 deletions
diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs index c4a5572..de1c784 100644 --- a/OpenSim/Services/InventoryService/LibraryService.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs | |||
@@ -50,25 +50,40 @@ namespace OpenSim.Services.InventoryService | |||
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private InventoryFolderImpl m_LibraryRootFolder; | 53 | static private InventoryFolderImpl m_LibraryRootFolder; |
54 | 54 | ||
55 | public InventoryFolderImpl LibraryRootFolder | 55 | public InventoryFolderImpl LibraryRootFolder |
56 | { | 56 | { |
57 | get { return m_LibraryRootFolder; } | 57 | get { return m_LibraryRootFolder; } |
58 | } | 58 | } |
59 | 59 | ||
60 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); | 60 | static private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// Holds the root library folder and all its descendents. This is really only used during inventory | 63 | /// Holds the root library folder and all its descendents. This is really only used during inventory |
64 | /// setup so that we don't have to repeatedly search the tree of library folders. | 64 | /// setup so that we don't have to repeatedly search the tree of library folders. |
65 | /// </summary> | 65 | /// </summary> |
66 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders | 66 | static protected Dictionary<UUID, InventoryFolderImpl> libraryFolders |
67 | = new Dictionary<UUID, InventoryFolderImpl>(); | 67 | = new Dictionary<UUID, InventoryFolderImpl>(32); |
68 | 68 | ||
69 | public LibraryService(IConfigSource config) | 69 | static protected Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>(256); |
70 | : base(config) | 70 | static LibraryService m_root; |
71 | static object m_rootLock = new object(); | ||
72 | static readonly uint m_BasePermissions = (uint)PermissionMask.AllAndExport; | ||
73 | static readonly uint m_EveryOnePermissions = (uint)PermissionMask.AllAndExportNoMod; | ||
74 | static readonly uint m_CurrentPermissions = (uint)PermissionMask.AllAndExport; | ||
75 | static readonly uint m_NextPermissions = (uint)PermissionMask.AllAndExport; | ||
76 | static readonly uint m_GroupPermissions = 0; | ||
77 | |||
78 | public LibraryService(IConfigSource config):base(config) | ||
71 | { | 79 | { |
80 | lock(m_rootLock) | ||
81 | { | ||
82 | if(m_root != null) | ||
83 | return; | ||
84 | m_root = this; | ||
85 | } | ||
86 | |||
72 | string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); | 87 | string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); |
73 | string pLibName = "OpenSim Library"; | 88 | string pLibName = "OpenSim Library"; |
74 | 89 | ||
@@ -86,8 +101,8 @@ namespace OpenSim.Services.InventoryService | |||
86 | m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); | 101 | m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); |
87 | m_LibraryRootFolder.Name = pLibName; | 102 | m_LibraryRootFolder.Name = pLibName; |
88 | m_LibraryRootFolder.ParentID = UUID.Zero; | 103 | m_LibraryRootFolder.ParentID = UUID.Zero; |
89 | m_LibraryRootFolder.Type = (short)8; | 104 | m_LibraryRootFolder.Type = 8; |
90 | m_LibraryRootFolder.Version = (ushort)1; | 105 | m_LibraryRootFolder.Version = 1; |
91 | 106 | ||
92 | libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); | 107 | libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); |
93 | 108 | ||
@@ -107,10 +122,11 @@ namespace OpenSim.Services.InventoryService | |||
107 | item.AssetType = assetType; | 122 | item.AssetType = assetType; |
108 | item.InvType = invType; | 123 | item.InvType = invType; |
109 | item.Folder = parentFolderID; | 124 | item.Folder = parentFolderID; |
110 | item.BasePermissions = 0x7FFFFFFF; | 125 | item.BasePermissions = m_BasePermissions; |
111 | item.EveryOnePermissions = 0x7FFFFFFF; | 126 | item.EveryOnePermissions = m_EveryOnePermissions; |
112 | item.CurrentPermissions = 0x7FFFFFFF; | 127 | item.CurrentPermissions = m_CurrentPermissions; |
113 | item.NextPermissions = 0x7FFFFFFF; | 128 | item.NextPermissions = m_NextPermissions; |
129 | item.GroupPermissions = m_GroupPermissions; | ||
114 | return item; | 130 | return item; |
115 | } | 131 | } |
116 | 132 | ||
@@ -132,6 +148,7 @@ namespace OpenSim.Services.InventoryService | |||
132 | protected void ReadLibraryFromConfig(IConfig config, string path) | 148 | protected void ReadLibraryFromConfig(IConfig config, string path) |
133 | { | 149 | { |
134 | string basePath = Path.GetDirectoryName(path); | 150 | string basePath = Path.GetDirectoryName(path); |
151 | m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", 1); | ||
135 | string foldersPath | 152 | string foldersPath |
136 | = Path.Combine( | 153 | = Path.Combine( |
137 | basePath, config.GetString("foldersFile", String.Empty)); | 154 | basePath, config.GetString("foldersFile", String.Empty)); |
@@ -157,9 +174,8 @@ namespace OpenSim.Services.InventoryService | |||
157 | folderInfo.Name = config.GetString("name", "unknown"); | 174 | folderInfo.Name = config.GetString("name", "unknown"); |
158 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); | 175 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); |
159 | folderInfo.Type = (short)config.GetInt("type", 8); | 176 | folderInfo.Type = (short)config.GetInt("type", 8); |
160 | 177 | folderInfo.Version = (ushort)config.GetInt("version", 1); | |
161 | folderInfo.Owner = libOwner; | 178 | folderInfo.Owner = libOwner; |
162 | folderInfo.Version = 1; | ||
163 | 179 | ||
164 | if (libraryFolders.ContainsKey(folderInfo.ParentID)) | 180 | if (libraryFolders.ContainsKey(folderInfo.ParentID)) |
165 | { | 181 | { |
@@ -187,28 +203,30 @@ namespace OpenSim.Services.InventoryService | |||
187 | InventoryItemBase item = new InventoryItemBase(); | 203 | InventoryItemBase item = new InventoryItemBase(); |
188 | item.Owner = libOwner; | 204 | item.Owner = libOwner; |
189 | item.CreatorId = libOwner.ToString(); | 205 | item.CreatorId = libOwner.ToString(); |
190 | item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); | 206 | UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); |
207 | item.ID = itID; | ||
191 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); | 208 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); |
192 | item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); | 209 | item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); |
193 | item.Name = config.GetString("name", String.Empty); | 210 | item.Name = config.GetString("name", String.Empty); |
194 | item.Description = config.GetString("description", item.Name); | 211 | item.Description = config.GetString("description", item.Name); |
195 | item.InvType = config.GetInt("inventoryType", 0); | 212 | item.InvType = config.GetInt("inventoryType", 0); |
196 | item.AssetType = config.GetInt("assetType", item.InvType); | 213 | item.AssetType = config.GetInt("assetType", item.InvType); |
197 | item.CurrentPermissions = (uint)config.GetLong("currentPermissions", (uint)PermissionMask.All); | 214 | item.CurrentPermissions = (uint)config.GetLong("currentPermissions", m_CurrentPermissions); |
198 | item.NextPermissions = (uint)config.GetLong("nextPermissions", (uint)PermissionMask.All); | 215 | item.NextPermissions = (uint)config.GetLong("nextPermissions", m_NextPermissions); |
199 | item.EveryOnePermissions | 216 | item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", m_EveryOnePermissions); |
200 | = (uint)config.GetLong("everyonePermissions", (uint)PermissionMask.All - (uint)PermissionMask.Modify); | 217 | item.BasePermissions = (uint)config.GetLong("basePermissions", m_BasePermissions); |
201 | item.BasePermissions = (uint)config.GetLong("basePermissions", (uint)PermissionMask.All); | 218 | item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);; |
202 | item.Flags = (uint)config.GetInt("flags", 0); | 219 | item.Flags = (uint)config.GetInt("flags", 0); |
203 | 220 | ||
204 | if (libraryFolders.ContainsKey(item.Folder)) | 221 | if (libraryFolders.ContainsKey(item.Folder)) |
205 | { | 222 | { |
206 | InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; | 223 | InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; |
207 | try | 224 | if(!parentFolder.Items.ContainsKey(itID)) |
208 | { | 225 | { |
209 | parentFolder.Items.Add(item.ID, item); | 226 | parentFolder.Items.Add(itID, item); |
227 | m_items[itID] = item; | ||
210 | } | 228 | } |
211 | catch (Exception) | 229 | else |
212 | { | 230 | { |
213 | m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); | 231 | m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); |
214 | } | 232 | } |
@@ -281,5 +299,26 @@ namespace OpenSim.Services.InventoryService | |||
281 | folders.AddRange(subs); | 299 | folders.AddRange(subs); |
282 | return folders; | 300 | return folders; |
283 | } | 301 | } |
302 | |||
303 | public InventoryItemBase GetItem(UUID itemID) | ||
304 | { | ||
305 | if(m_items.ContainsKey(itemID)) | ||
306 | return m_items[itemID]; | ||
307 | return null; | ||
308 | } | ||
309 | |||
310 | public InventoryItemBase[] GetMultipleItems(UUID[] ids) | ||
311 | { | ||
312 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | ||
313 | foreach (UUID id in ids) | ||
314 | { | ||
315 | if(m_items.ContainsKey(id)) | ||
316 | items.Add(m_items[id]); | ||
317 | } | ||
318 | |||
319 | if(items.Count == 0) | ||
320 | return null; | ||
321 | return items.ToArray(); | ||
322 | } | ||
284 | } | 323 | } |
285 | } | 324 | } |