diff options
Diffstat (limited to 'OpenSim/Services/InventoryService')
3 files changed, 59 insertions, 67 deletions
diff --git a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs index ec89097..2e3fb3e 100644 --- a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs | |||
@@ -2,7 +2,7 @@ | |||
2 | using System.Runtime.CompilerServices; | 2 | using System.Runtime.CompilerServices; |
3 | using System.Runtime.InteropServices; | 3 | using System.Runtime.InteropServices; |
4 | 4 | ||
5 | // General Information about an assembly is controlled through the following | 5 | // General Information about an assembly is controlled through the following |
6 | // set of attributes. Change these attribute values to modify the information | 6 | // set of attributes. Change these attribute values to modify the information |
7 | // associated with an assembly. | 7 | // associated with an assembly. |
8 | [assembly: AssemblyTitle("OpenSim.Services.InventoryService")] | 8 | [assembly: AssemblyTitle("OpenSim.Services.InventoryService")] |
@@ -14,8 +14,8 @@ using System.Runtime.InteropServices; | |||
14 | [assembly: AssemblyTrademark("")] | 14 | [assembly: AssemblyTrademark("")] |
15 | [assembly: AssemblyCulture("")] | 15 | [assembly: AssemblyCulture("")] |
16 | 16 | ||
17 | // Setting ComVisible to false makes the types in this assembly not visible | 17 | // Setting ComVisible to false makes the types in this assembly not visible |
18 | // to COM components. If you need to access a type in this assembly from | 18 | // to COM components. If you need to access a type in this assembly from |
19 | // COM, set the ComVisible attribute to true on that type. | 19 | // COM, set the ComVisible attribute to true on that type. |
20 | [assembly: ComVisible(false)] | 20 | [assembly: ComVisible(false)] |
21 | 21 | ||
@@ -25,9 +25,9 @@ using System.Runtime.InteropServices; | |||
25 | // Version information for an assembly consists of the following four values: | 25 | // Version information for an assembly consists of the following four values: |
26 | // | 26 | // |
27 | // Major Version | 27 | // Major Version |
28 | // Minor Version | 28 | // Minor Version |
29 | // Build Number | 29 | // Build Number |
30 | // Revision | 30 | // Revision |
31 | // | 31 | // |
32 | [assembly: AssemblyVersion("0.8.3.*")] | 32 | [assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)] |
33 | 33 | ||
diff --git a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs index 9e3fa69..2e4637c 100644 --- a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs +++ b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
47 | { | 47 | { |
48 | private IInventoryService CreateXInventoryService() | 48 | private IInventoryService CreateXInventoryService() |
49 | { | 49 | { |
50 | IConfigSource config = new IniConfigSource(); | 50 | IConfigSource config = new IniConfigSource(); |
51 | config.AddConfig("InventoryService"); | 51 | config.AddConfig("InventoryService"); |
52 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 52 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
53 | 53 | ||
@@ -73,25 +73,24 @@ namespace OpenSim.Services.InventoryService.Tests | |||
73 | UUID folderId = TestHelpers.ParseTail(0x30); | 73 | UUID folderId = TestHelpers.ParseTail(0x30); |
74 | int invType = (int)InventoryType.Animation; | 74 | int invType = (int)InventoryType.Animation; |
75 | int assetType = (int)AssetType.Animation; | 75 | int assetType = (int)AssetType.Animation; |
76 | string itemName = "item1"; | 76 | string itemName = "item1"; |
77 | 77 | ||
78 | IInventoryService xis = CreateXInventoryService(); | 78 | IInventoryService xis = CreateXInventoryService(); |
79 | 79 | ||
80 | InventoryItemBase itemToStore | 80 | InventoryItemBase itemToStore |
81 | = new InventoryItemBase(itemId, ownerId) | 81 | = new InventoryItemBase(itemId, ownerId) |
82 | { | 82 | { |
83 | CreatorIdentification = creatorId.ToString(), | 83 | CreatorIdentification = creatorId.ToString(), |
84 | AssetID = assetId, | 84 | AssetID = assetId, |
85 | Name = itemName, | 85 | Name = itemName, |
86 | Folder = folderId, | 86 | Folder = folderId, |
87 | InvType = invType, | 87 | InvType = invType, |
88 | AssetType = assetType | 88 | AssetType = assetType |
89 | }; | 89 | }; |
90 | 90 | ||
91 | Assert.That(xis.AddItem(itemToStore), Is.True); | 91 | Assert.That(xis.AddItem(itemToStore), Is.True); |
92 | 92 | ||
93 | InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); | 93 | InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); |
94 | itemRetrieved = xis.GetItem(itemRetrieved); | ||
95 | 94 | ||
96 | Assert.That(itemRetrieved, Is.Not.Null); | 95 | Assert.That(itemRetrieved, Is.Not.Null); |
97 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); | 96 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); |
@@ -116,20 +115,20 @@ namespace OpenSim.Services.InventoryService.Tests | |||
116 | UUID folderId = TestHelpers.ParseTail(0x30); | 115 | UUID folderId = TestHelpers.ParseTail(0x30); |
117 | int invType = (int)InventoryType.Animation; | 116 | int invType = (int)InventoryType.Animation; |
118 | int assetType = (int)AssetType.Animation; | 117 | int assetType = (int)AssetType.Animation; |
119 | string itemName = "item1"; | 118 | string itemName = "item1"; |
120 | string itemName2 = "item2"; | 119 | string itemName2 = "item2"; |
121 | 120 | ||
122 | IInventoryService xis = CreateXInventoryService(); | 121 | IInventoryService xis = CreateXInventoryService(); |
123 | 122 | ||
124 | InventoryItemBase itemToStore | 123 | InventoryItemBase itemToStore |
125 | = new InventoryItemBase(itemId, ownerId) | 124 | = new InventoryItemBase(itemId, ownerId) |
126 | { | 125 | { |
127 | CreatorIdentification = creatorId.ToString(), | 126 | CreatorIdentification = creatorId.ToString(), |
128 | AssetID = assetId, | 127 | AssetID = assetId, |
129 | Name = itemName, | 128 | Name = itemName, |
130 | Folder = folderId, | 129 | Folder = folderId, |
131 | InvType = invType, | 130 | InvType = invType, |
132 | AssetType = assetType | 131 | AssetType = assetType |
133 | }; | 132 | }; |
134 | 133 | ||
135 | Assert.That(xis.AddItem(itemToStore), Is.True); | 134 | Assert.That(xis.AddItem(itemToStore), Is.True); |
@@ -139,8 +138,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
139 | 138 | ||
140 | Assert.That(xis.UpdateItem(itemToStore), Is.True); | 139 | Assert.That(xis.UpdateItem(itemToStore), Is.True); |
141 | 140 | ||
142 | InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); | 141 | InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); |
143 | itemRetrieved = xis.GetItem(itemRetrieved); | ||
144 | 142 | ||
145 | Assert.That(itemRetrieved, Is.Not.Null); | 143 | Assert.That(itemRetrieved, Is.Not.Null); |
146 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); | 144 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); |
@@ -151,7 +149,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
151 | UUID folderId2 = TestHelpers.ParseTail(0x70); | 149 | UUID folderId2 = TestHelpers.ParseTail(0x70); |
152 | int invType2 = (int)InventoryType.CallingCard; | 150 | int invType2 = (int)InventoryType.CallingCard; |
153 | int assetType2 = (int)AssetType.CallingCard; | 151 | int assetType2 = (int)AssetType.CallingCard; |
154 | string itemName3 = "item3"; | 152 | string itemName3 = "item3"; |
155 | 153 | ||
156 | itemToStore.CreatorIdentification = creatorId2.ToString(); | 154 | itemToStore.CreatorIdentification = creatorId2.ToString(); |
157 | itemToStore.Owner = ownerId2; | 155 | itemToStore.Owner = ownerId2; |
@@ -162,7 +160,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
162 | 160 | ||
163 | Assert.That(xis.UpdateItem(itemToStore), Is.True); | 161 | Assert.That(xis.UpdateItem(itemToStore), Is.True); |
164 | 162 | ||
165 | itemRetrieved = xis.GetItem(itemRetrieved); | 163 | itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID); |
166 | 164 | ||
167 | Assert.That(itemRetrieved, Is.Not.Null); | 165 | Assert.That(itemRetrieved, Is.Not.Null); |
168 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); | 166 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); |
@@ -174,4 +172,4 @@ namespace OpenSim.Services.InventoryService.Tests | |||
174 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); | 172 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); |
175 | } | 173 | } |
176 | } | 174 | } |
177 | } \ No newline at end of file | 175 | } |
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index b75193f..b8ed46c 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -176,7 +176,7 @@ namespace OpenSim.Services.InventoryService | |||
176 | protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID) | 176 | protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID) |
177 | { | 177 | { |
178 | // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); | 178 | // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); |
179 | 179 | ||
180 | XInventoryFolder[] allFolders = m_Database.GetFolders( | 180 | XInventoryFolder[] allFolders = m_Database.GetFolders( |
181 | new string[] { "agentID", "parentFolderID" }, | 181 | new string[] { "agentID", "parentFolderID" }, |
182 | new string[] { principalID.ToString(), rootID.ToString() }); | 182 | new string[] { principalID.ToString(), rootID.ToString() }); |
@@ -192,7 +192,7 @@ namespace OpenSim.Services.InventoryService | |||
192 | 192 | ||
193 | // m_log.DebugFormat( | 193 | // m_log.DebugFormat( |
194 | // "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID); | 194 | // "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID); |
195 | 195 | ||
196 | return sysFolders; | 196 | return sysFolders; |
197 | } | 197 | } |
198 | 198 | ||
@@ -234,7 +234,7 @@ namespace OpenSim.Services.InventoryService | |||
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | if (root == null) // oops | 238 | if (root == null) // oops |
239 | root = folders[0]; | 239 | root = folders[0]; |
240 | 240 | ||
@@ -255,7 +255,7 @@ namespace OpenSim.Services.InventoryService | |||
255 | 255 | ||
256 | return null; | 256 | return null; |
257 | } | 257 | } |
258 | 258 | ||
259 | return GetSystemFolderForType(rootFolder, type); | 259 | return GetSystemFolderForType(rootFolder, type); |
260 | } | 260 | } |
261 | 261 | ||
@@ -315,8 +315,7 @@ namespace OpenSim.Services.InventoryService | |||
315 | inventory.Items.Add(ConvertToOpenSim(i)); | 315 | inventory.Items.Add(ConvertToOpenSim(i)); |
316 | } | 316 | } |
317 | 317 | ||
318 | InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); | 318 | InventoryFolderBase f = GetFolder(principalID, folderID); |
319 | f = GetFolder(f); | ||
320 | if (f != null) | 319 | if (f != null) |
321 | { | 320 | { |
322 | inventory.Version = f.Version; | 321 | inventory.Version = f.Version; |
@@ -336,11 +335,11 @@ namespace OpenSim.Services.InventoryService | |||
336 | 335 | ||
337 | return multiple; | 336 | return multiple; |
338 | } | 337 | } |
339 | 338 | ||
340 | public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) | 339 | public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) |
341 | { | 340 | { |
342 | // m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID); | 341 | // m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID); |
343 | 342 | ||
344 | // Since we probably don't get a valid principal here, either ... | 343 | // Since we probably don't get a valid principal here, either ... |
345 | // | 344 | // |
346 | List<InventoryItemBase> invItems = new List<InventoryItemBase>(); | 345 | List<InventoryItemBase> invItems = new List<InventoryItemBase>(); |
@@ -359,7 +358,7 @@ namespace OpenSim.Services.InventoryService | |||
359 | { | 358 | { |
360 | // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); | 359 | // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); |
361 | 360 | ||
362 | InventoryFolderBase check = GetFolder(folder); | 361 | InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); |
363 | if (check != null) | 362 | if (check != null) |
364 | return false; | 363 | return false; |
365 | 364 | ||
@@ -387,7 +386,7 @@ namespace OpenSim.Services.InventoryService | |||
387 | m_log.WarnFormat( | 386 | m_log.WarnFormat( |
388 | "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}", | 387 | "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}", |
389 | folder.Type, folder.Name, folder.ParentID, folder.Owner); | 388 | folder.Type, folder.Name, folder.ParentID, folder.Owner); |
390 | 389 | ||
391 | return false; | 390 | return false; |
392 | } | 391 | } |
393 | } | 392 | } |
@@ -402,7 +401,7 @@ namespace OpenSim.Services.InventoryService | |||
402 | // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); | 401 | // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); |
403 | 402 | ||
404 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 403 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); |
405 | InventoryFolderBase check = GetFolder(folder); | 404 | InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); |
406 | 405 | ||
407 | if (check == null) | 406 | if (check == null) |
408 | return AddFolder(folder); | 407 | return AddFolder(folder); |
@@ -499,7 +498,7 @@ namespace OpenSim.Services.InventoryService | |||
499 | { | 498 | { |
500 | // m_log.DebugFormat( | 499 | // m_log.DebugFormat( |
501 | // "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner); | 500 | // "[XINVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", item.Name, item.ID, item.Folder, item.Owner); |
502 | 501 | ||
503 | return m_Database.StoreItem(ConvertFromOpenSim(item)); | 502 | return m_Database.StoreItem(ConvertFromOpenSim(item)); |
504 | } | 503 | } |
505 | 504 | ||
@@ -512,32 +511,32 @@ namespace OpenSim.Services.InventoryService | |||
512 | // m_log.InfoFormat( | 511 | // m_log.InfoFormat( |
513 | // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | 512 | // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); |
514 | 513 | ||
515 | InventoryItemBase retrievedItem = GetItem(item); | 514 | InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID); |
516 | 515 | ||
517 | if (retrievedItem == null) | 516 | if (retrievedItem == null) |
518 | { | 517 | { |
519 | m_log.WarnFormat( | 518 | m_log.WarnFormat( |
520 | "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.", | 519 | "[XINVENTORY SERVICE]: Tried to update item {0} {1}, owner {2} but no existing item found.", |
521 | item.Name, item.ID, item.Owner); | 520 | item.Name, item.ID, item.Owner); |
522 | 521 | ||
523 | return false; | 522 | return false; |
524 | } | 523 | } |
525 | 524 | ||
526 | // Do not allow invariants to change. Changes to folder ID occur in MoveItems() | 525 | // Do not allow invariants to change. Changes to folder ID occur in MoveItems() |
527 | if (retrievedItem.InvType != item.InvType | 526 | if (retrievedItem.InvType != item.InvType |
528 | || retrievedItem.AssetType != item.AssetType | 527 | || retrievedItem.AssetType != item.AssetType |
529 | || retrievedItem.Folder != item.Folder | 528 | || retrievedItem.Folder != item.Folder |
530 | || retrievedItem.CreatorIdentification != item.CreatorIdentification | 529 | || retrievedItem.CreatorIdentification != item.CreatorIdentification |
531 | || retrievedItem.Owner != item.Owner) | 530 | || retrievedItem.Owner != item.Owner) |
532 | { | 531 | { |
533 | m_log.WarnFormat( | 532 | m_log.WarnFormat( |
534 | "[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})", | 533 | "[XINVENTORY SERVICE]: Caller to UpdateItem() for {0} {1} tried to alter property(s) that should be invariant, (InvType, AssetType, Folder, CreatorIdentification, Owner), existing ({2}, {3}, {4}, {5}, {6}), update ({7}, {8}, {9}, {10}, {11})", |
535 | retrievedItem.Name, | 534 | retrievedItem.Name, |
536 | retrievedItem.ID, | 535 | retrievedItem.ID, |
537 | retrievedItem.InvType, | 536 | retrievedItem.InvType, |
538 | retrievedItem.AssetType, | 537 | retrievedItem.AssetType, |
539 | retrievedItem.Folder, | 538 | retrievedItem.Folder, |
540 | retrievedItem.CreatorIdentification, | 539 | retrievedItem.CreatorIdentification, |
541 | retrievedItem.Owner, | 540 | retrievedItem.Owner, |
542 | item.InvType, | 541 | item.InvType, |
543 | item.AssetType, | 542 | item.AssetType, |
@@ -598,11 +597,11 @@ namespace OpenSim.Services.InventoryService | |||
598 | return true; | 597 | return true; |
599 | } | 598 | } |
600 | 599 | ||
601 | public virtual InventoryItemBase GetItem(InventoryItemBase item) | 600 | public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) |
602 | { | 601 | { |
603 | XInventoryItem[] items = m_Database.GetItems( | 602 | XInventoryItem[] items = m_Database.GetItems( |
604 | new string[] { "inventoryID" }, | 603 | new string[] { "inventoryID" }, |
605 | new string[] { item.ID.ToString() }); | 604 | new string[] { itemID.ToString() }); |
606 | 605 | ||
607 | if (items.Length == 0) | 606 | if (items.Length == 0) |
608 | return null; | 607 | return null; |
@@ -614,22 +613,17 @@ namespace OpenSim.Services.InventoryService | |||
614 | { | 613 | { |
615 | InventoryItemBase[] items = new InventoryItemBase[ids.Length]; | 614 | InventoryItemBase[] items = new InventoryItemBase[ids.Length]; |
616 | int i = 0; | 615 | int i = 0; |
617 | InventoryItemBase item = new InventoryItemBase(); | ||
618 | item.Owner = userID; | ||
619 | foreach (UUID id in ids) | 616 | foreach (UUID id in ids) |
620 | { | 617 | items[i++] = GetItem(userID, id); |
621 | item.ID = id; | ||
622 | items[i++] = GetItem(item); | ||
623 | } | ||
624 | 618 | ||
625 | return items; | 619 | return items; |
626 | } | 620 | } |
627 | 621 | ||
628 | public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) | 622 | public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID) |
629 | { | 623 | { |
630 | XInventoryFolder[] folders = m_Database.GetFolders( | 624 | XInventoryFolder[] folders = m_Database.GetFolders( |
631 | new string[] { "folderID"}, | 625 | new string[] { "folderID"}, |
632 | new string[] { folder.ID.ToString() }); | 626 | new string[] { folderID.ToString() }); |
633 | 627 | ||
634 | if (folders.Length == 0) | 628 | if (folders.Length == 0) |
635 | return null; | 629 | return null; |
@@ -645,7 +639,7 @@ namespace OpenSim.Services.InventoryService | |||
645 | return new List<InventoryItemBase>(); | 639 | return new List<InventoryItemBase>(); |
646 | 640 | ||
647 | List<InventoryItemBase> ret = new List<InventoryItemBase>(); | 641 | List<InventoryItemBase> ret = new List<InventoryItemBase>(); |
648 | 642 | ||
649 | foreach (XInventoryItem x in items) | 643 | foreach (XInventoryItem x in items) |
650 | ret.Add(ConvertToOpenSim(x)); | 644 | ret.Add(ConvertToOpenSim(x)); |
651 | 645 | ||