From 1121a214b9258487dae0d84dad1a0b495d2f80bd Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sat, 21 Mar 2009 17:46:58 +0000
Subject: Add a QueryItem method to the inventory subsystem. Currently
implemented for MySQL only, stubs for the others. This allows updating the
cache with a single item from the database.
---
OpenSim/Data/IInventoryData.cs | 6 ++++
OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 5 +++
OpenSim/Data/MySQL/MySQLInventoryData.cs | 5 +++
OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 5 +++
OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 5 +++
.../Communications/Cache/CachedUserInfo.cs | 42 ++++++++++++++++++++++
.../Framework/Communications/IInventoryServices.cs | 8 +++++
.../Communications/InventoryServiceBase.cs | 14 ++++++++
OpenSim/Grid/InventoryServer/Main.cs | 4 +++
.../Communications/OGS1/OGS1InventoryService.cs | 16 +++++++++
.../Tests/Common/Mock/TestInventoryDataPlugin.cs | 5 +++
11 files changed, 115 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/IInventoryData.cs b/OpenSim/Data/IInventoryData.cs
index 03b1cbe..84a857c 100644
--- a/OpenSim/Data/IInventoryData.cs
+++ b/OpenSim/Data/IInventoryData.cs
@@ -109,6 +109,12 @@ namespace OpenSim.Data
void deleteInventoryItem(UUID item);
///
+ ///
+ ///
+ ///
+ InventoryItemBase queryInventoryItem(UUID item);
+
+ ///
/// Adds a new folder specified by folder
///
/// The inventory folder
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
index 348682c..3d25ed0 100644
--- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
@@ -530,6 +530,11 @@ namespace OpenSim.Data.MSSQL
}
}
+ public InventoryItemBase queryInventoryItem(UUID itemID)
+ {
+ return null;
+ }
+
///
/// Returns all activated gesture-items in the inventory of the specified avatar.
///
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 7d29061..1a6f068 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -539,6 +539,11 @@ namespace OpenSim.Data.MySQL
}
}
+ public InventoryItemBase queryInventoryItem(UUID itemID)
+ {
+ return getInventoryItem(itemID);
+ }
+
///
/// Creates a new inventory folder
///
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index 612ab59..74f6eae 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -177,6 +177,11 @@ namespace OpenSim.Data.NHibernate
}
+ public InventoryItemBase queryInventoryItem(UUID itemID)
+ {
+ return null;
+ }
+
///
/// Returns an inventory folder by its UUID
///
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 6391c6d..3be320f 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -618,6 +618,11 @@ namespace OpenSim.Data.SQLite
}
}
+ public InventoryItemBase queryInventoryItem(UUID itemID)
+ {
+ return null;
+ }
+
///
/// Delete all items in the specified folder
///
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index c5bbd6a..57c3ece 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications.Cache
internal delegate void AddItemDelegate(InventoryItemBase itemInfo);
internal delegate void UpdateItemDelegate(InventoryItemBase itemInfo);
internal delegate void DeleteItemDelegate(UUID itemID);
+ internal delegate void QueryItemDelegate(UUID itemID);
internal delegate void CreateFolderDelegate(string folderName, UUID folderID, ushort folderType, UUID parentID);
internal delegate void MoveFolderDelegate(UUID folderID, UUID parentID);
@@ -767,6 +768,47 @@ namespace OpenSim.Framework.Communications.Cache
return RootFolder.FindFolderForType(type);
}
+
+ // Load additional items that other regions have put into the database
+ // The item will be added tot he local cache. Returns true if the item
+ // was found and can be sent to the client
+ //
+ public bool QueryItem(UUID itemID)
+ {
+ if (m_hasReceivedInventory)
+ {
+ InventoryItemBase item = RootFolder.FindItem(itemID);
+
+ if (item != null)
+ {
+ // Item is in local cache, just update client
+ //
+ return true;
+ }
+
+ InventoryItemBase itemInfo = m_commsManager.InventoryService.QueryItem(item);
+ if (itemInfo != null)
+ {
+ InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder);
+ ItemReceive(itemInfo, folder);
+ return true;
+ }
+
+ return false;
+ }
+ else
+ {
+ AddRequest(
+ new InventoryRequest(
+ Delegate.CreateDelegate(typeof(QueryItemDelegate), this, "QueryItem"),
+ new object[] { itemID }));
+
+ return true;
+ }
+
+ return false;
+ }
+
}
///
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs
index aead3be..fc9d8af 100644
--- a/OpenSim/Framework/Communications/IInventoryServices.cs
+++ b/OpenSim/Framework/Communications/IInventoryServices.cs
@@ -105,6 +105,14 @@ namespace OpenSim.Framework.Communications
bool DeleteItem(InventoryItemBase item);
///
+ /// Query the server for an item that may have been added by
+ /// another region
+ ///
+ ///
+ /// true if the item was found in local cache
+ InventoryItemBase QueryItem(InventoryItemBase item);
+
+ ///
/// Does the given user have an inventory structure?
///
///
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index 8068080..cad7989 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -278,6 +278,20 @@ namespace OpenSim.Framework.Communications
return true;
}
+ public virtual InventoryItemBase QueryItem(InventoryItemBase item)
+ {
+ foreach (IInventoryDataPlugin plugin in m_plugins)
+ {
+ InventoryItemBase result = plugin.queryInventoryItem(item.ID);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+ return null;
+ }
+
///
/// Purge a folder of all items items and subfolders.
///
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs
index 8ca7c3d..70bfe60 100644
--- a/OpenSim/Grid/InventoryServer/Main.cs
+++ b/OpenSim/Grid/InventoryServer/Main.cs
@@ -127,6 +127,10 @@ namespace OpenSim.Grid.InventoryServer
new RestDeserialiseSecureHandler(
"POST", "/DeleteItem/", m_inventoryService.DeleteItem, m_inventoryService.CheckAuthSession));
+ m_httpServer.AddStreamHandler(
+ new RestDeserialiseSecureHandler(
+ "POST", "/QueryItem/", m_inventoryService.QueryItem, m_inventoryService.CheckAuthSession));
+
// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g
// system folders such as Objects, Textures), but it now returns the entire inventory skeleton.
// It would have been better to rename this request, but complexities in the BaseHttpServer
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
index 49d5938..56566a8 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs
@@ -296,6 +296,22 @@ namespace OpenSim.Region.Communications.OGS1
return false;
}
+ public InventoryItemBase QueryItem(InventoryItemBase item)
+ {
+ try
+ {
+ return SynchronousRestObjectPoster.BeginPostObject(
+ "POST", _inventoryServerUrl + "/QueryItem/", item);
+ }
+ catch (WebException e)
+ {
+ m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Query inventory item operation failed, {0} {1}",
+ e.Source, e.Message);
+ }
+
+ return null;
+ }
+
public bool HasInventoryForUser(UUID userID)
{
return false;
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
index 59d923c..69b0917 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs
@@ -115,6 +115,11 @@ namespace OpenSim.Tests.Common.Mock
public void updateInventoryItem(InventoryItemBase item) {}
public void deleteInventoryItem(UUID item) {}
+ public InventoryItemBase queryInventoryItem(UUID item)
+ {
+ return null;
+ }
+
public void addInventoryFolder(InventoryFolderBase folder)
{
m_folders[folder.ID] = folder;
--
cgit v1.1