aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/InventoryService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/InventoryService')
-rw-r--r--OpenSim/Services/InventoryService/LibraryService.cs54
1 files changed, 44 insertions, 10 deletions
diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs
index c4a5572..89967a7 100644
--- a/OpenSim/Services/InventoryService/LibraryService.cs
+++ b/OpenSim/Services/InventoryService/LibraryService.cs
@@ -50,25 +50,35 @@ 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
73 public LibraryService(IConfigSource config):base(config)
71 { 74 {
75 lock(m_rootLock)
76 {
77 if(m_root != null)
78 return;
79 m_root = this;
80 }
81
72 string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); 82 string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml");
73 string pLibName = "OpenSim Library"; 83 string pLibName = "OpenSim Library";
74 84
@@ -187,7 +197,8 @@ namespace OpenSim.Services.InventoryService
187 InventoryItemBase item = new InventoryItemBase(); 197 InventoryItemBase item = new InventoryItemBase();
188 item.Owner = libOwner; 198 item.Owner = libOwner;
189 item.CreatorId = libOwner.ToString(); 199 item.CreatorId = libOwner.ToString();
190 item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); 200 UUID itID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString()));
201 item.ID = itID;
191 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); 202 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString()));
192 item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); 203 item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString()));
193 item.Name = config.GetString("name", String.Empty); 204 item.Name = config.GetString("name", String.Empty);
@@ -204,11 +215,12 @@ namespace OpenSim.Services.InventoryService
204 if (libraryFolders.ContainsKey(item.Folder)) 215 if (libraryFolders.ContainsKey(item.Folder))
205 { 216 {
206 InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; 217 InventoryFolderImpl parentFolder = libraryFolders[item.Folder];
207 try 218 if(!parentFolder.Items.ContainsKey(itID))
208 { 219 {
209 parentFolder.Items.Add(item.ID, item); 220 parentFolder.Items.Add(itID, item);
221 m_items[itID] = item;
210 } 222 }
211 catch (Exception) 223 else
212 { 224 {
213 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); 225 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
214 } 226 }
@@ -281,5 +293,27 @@ namespace OpenSim.Services.InventoryService
281 folders.AddRange(subs); 293 folders.AddRange(subs);
282 return folders; 294 return folders;
283 } 295 }
296
297 public InventoryItemBase GetItem(UUID itemID)
298 {
299 if(m_items.ContainsKey(itemID))
300 return m_items[itemID];
301 return null;
302 }
303
304 public InventoryItemBase[] GetMultipleItems(UUID[] ids)
305 {
306 List<InventoryItemBase> items = new List<InventoryItemBase>();
307 int i = 0;
308 foreach (UUID id in ids)
309 {
310 if(m_items.ContainsKey(id))
311 items.Add(m_items[id]);
312 }
313
314 if(items.Count == 0)
315 return null;
316 return items.ToArray();
317 }
284 } 318 }
285} 319}