From ae4b02e1152b775dc1cdccd1abfbff44ab1a8949 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 25 Nov 2010 11:14:16 -0800 Subject: WARNING: LOTS OF CONFIGURATION CHANGES AFFECTING PRIMARILY HG CONFIGS. Added capability to preserve creator information on HG asset transfers. Added a new HGAssetService that is intended to be the one outside the firewall. It processes and filters the assets that go out of the grid. Also fixed the normal AssetService to do special things for the main instance (console commands, etc). Moved HGInventoryService to OpenSim.Services.HypergridService. Changed the way the login service gets the ServiceURL configs. --- .../Services/HypergridService/HGAssetService.cs | 181 +++++++++++ .../HypergridService/HGInventoryService.cs | 333 +++++++++++++++++++++ 2 files changed, 514 insertions(+) create mode 100644 OpenSim/Services/HypergridService/HGAssetService.cs create mode 100644 OpenSim/Services/HypergridService/HGInventoryService.cs (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs new file mode 100644 index 0000000..6e0d4cd --- /dev/null +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -0,0 +1,181 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; + +using Nini.Config; +using log4net; +using OpenMetaverse; + +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.AssetService; + +namespace OpenSim.Services.HypergridService +{ + public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ProfileServiceURL; + private IUserAccountService m_UserAccountService; + + private UserAccountCache m_Cache; + + public HGAssetService(IConfigSource config) : base(config) + { + m_log.Debug("[HGAsset Service]: Starting"); + IConfig assetConfig = config.Configs["HGAssetService"]; + if (assetConfig == null) + throw new Exception("No HGAssetService configuration"); + + string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty); + if (userAccountsDll == string.Empty) + throw new Exception("Please specify UserAccountsService in HGAssetService configuration"); + + Object[] args = new Object[] { config }; + m_UserAccountService = ServerUtils.LoadPlugin(userAccountsDll, args); + if (m_UserAccountService == null) + throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); + + m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty); + + m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); + } + + #region IAssetService overrides + public override AssetBase Get(string id) + { + AssetBase asset = base.Get(id); + + if (asset == null) + return null; + + if (asset.Metadata.Type == (sbyte)AssetType.Object) + asset.Data = AdjustIdentifiers(asset.Data); ; + + AdjustIdentifiers(asset.Metadata); + + return asset; + } + + public override AssetMetadata GetMetadata(string id) + { + AssetMetadata meta = base.GetMetadata(id); + + if (meta == null) + return null; + + AdjustIdentifiers(meta); + + return meta; + } + + public override byte[] GetData(string id) + { + byte[] data = base.GetData(id); + + if (data == null) + return null; + + return AdjustIdentifiers(data); + } + + //public virtual bool Get(string id, Object sender, AssetRetrieved handler) + + public override bool Delete(string id) + { + // NOGO + return false; + } + + #endregion + + protected void AdjustIdentifiers(AssetMetadata meta) + { + UserAccount creator = m_Cache.GetUser(meta.CreatorID); + if (creator != null) + meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; + + } + + protected byte[] AdjustIdentifiers(byte[] data) + { + string xml = Utils.BytesToString(data); + return Utils.StringToBytes(RewriteSOP(xml)); + } + + protected string RewriteSOP(string xml) + { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); + + foreach (XmlNode sop in sops) + { + UserAccount creator = null; + bool hasCreatorData = false; + XmlNodeList nodes = sop.ChildNodes; + foreach (XmlNode node in nodes) + { + if (node.Name == "CreatorID") + creator = m_Cache.GetUser(node.InnerText); + if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) + hasCreatorData = true; + + //if (node.Name == "OwnerID") + //{ + // UserAccount owner = GetUser(node.InnerText); + // if (owner != null) + // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; + //} + } + if (!hasCreatorData && creator != null) + { + XmlElement creatorData = doc.CreateElement("CreatorData"); + creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; + sop.AppendChild(creatorData); + } + } + + using (StringWriter wr = new StringWriter()) + { + doc.Save(wr); + return wr.ToString(); + } + + } + + } + +} diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs new file mode 100644 index 0000000..a04f0c4 --- /dev/null +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -0,0 +1,333 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using log4net; +using Nini.Config; +using System.Reflection; +using OpenSim.Services.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.InventoryService; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Server.Base; + +namespace OpenSim.Services.HypergridService +{ + public class HGInventoryService : XInventoryService, IInventoryService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + protected new IXInventoryData m_Database; + + private string m_ProfileServiceURL; + private IUserAccountService m_UserAccountService; + + private UserAccountCache m_Cache; + + public HGInventoryService(IConfigSource config) + : base(config) + { + m_log.Debug("[HGInventory Service]: Starting"); + + string dllName = String.Empty; + string connString = String.Empty; + //string realm = "Inventory"; // OSG version doesn't use this + + // + // Try reading the [DatabaseService] section, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + if (dllName == String.Empty) + dllName = dbConfig.GetString("StorageProvider", String.Empty); + if (connString == String.Empty) + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + // + // Try reading the [InventoryService] section, if it exists + // + IConfig invConfig = config.Configs["HGInventoryService"]; + if (invConfig != null) + { + dllName = invConfig.GetString("StorageProvider", dllName); + connString = invConfig.GetString("ConnectionString", connString); + + // realm = authConfig.GetString("Realm", realm); + string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); + if (userAccountsDll == string.Empty) + throw new Exception("Please specify UserAccountsService in HGInventoryService configuration"); + + Object[] args = new Object[] { config }; + m_UserAccountService = ServerUtils.LoadPlugin(userAccountsDll, args); + if (m_UserAccountService == null) + throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); + + m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty); + + m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (dllName == String.Empty) + throw new Exception("No StorageProvider configured"); + + m_Database = LoadPlugin(dllName, + new Object[] {connString, String.Empty}); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + + m_log.Debug("[HG INVENTORY SERVICE]: Starting..."); + } + + public override bool CreateUserInventory(UUID principalID) + { + // NOGO + return false; + } + + + public override List GetInventorySkeleton(UUID principalID) + { + // NOGO for this inventory service + return new List(); + } + + public override InventoryFolderBase GetRootFolder(UUID principalID) + { + // Warp! Root folder for travelers + XInventoryFolder[] folders = m_Database.GetFolders( + new string[] { "agentID", "folderName"}, + new string[] { principalID.ToString(), "My Suitcase" }); + + if (folders.Length > 0) + return ConvertToOpenSim(folders[0]); + + // make one + XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)AssetType.Folder, "My Suitcase"); + return ConvertToOpenSim(suitcase); + } + + //private bool CreateSystemFolders(UUID principalID, XInventoryFolder suitcase) + //{ + + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Animation, "Animations"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Bodypart, "Body Parts"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.CallingCard, "Calling Cards"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Clothing, "Clothing"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Gesture, "Gestures"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Landmark, "Landmarks"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.LostAndFoundFolder, "Lost And Found"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Notecard, "Notecards"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Object, "Objects"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.SnapshotFolder, "Photo Album"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.LSLText, "Scripts"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Sound, "Sounds"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.Texture, "Textures"); + // CreateFolder(principalID, suitcase.folderID, (int)AssetType.TrashFolder, "Trash"); + + // return true; + //} + + + public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) + { + return GetRootFolder(principalID); + } + + // + // Use the inherited methods + // + //public InventoryCollection GetFolderContent(UUID principalID, UUID folderID) + //{ + //} + + //public List GetFolderItems(UUID principalID, UUID folderID) + //{ + //} + + //public override bool AddFolder(InventoryFolderBase folder) + //{ + // // Check if it's under the Suitcase folder + // List skel = base.GetInventorySkeleton(folder.Owner); + // InventoryFolderBase suitcase = GetRootFolder(folder.Owner); + // List suitDescendents = GetDescendents(skel, suitcase.ID); + + // foreach (InventoryFolderBase f in suitDescendents) + // if (folder.ParentID == f.ID) + // { + // XInventoryFolder xFolder = ConvertFromOpenSim(folder); + // return m_Database.StoreFolder(xFolder); + // } + // return false; + //} + + private List GetDescendents(List lst, UUID root) + { + List direct = lst.FindAll(delegate(InventoryFolderBase f) { return f.ParentID == root; }); + if (direct == null) + return new List(); + + List indirect = new List(); + foreach (InventoryFolderBase f in direct) + indirect.AddRange(GetDescendents(lst, f.ID)); + + direct.AddRange(indirect); + return direct; + } + + // Use inherited method + //public bool UpdateFolder(InventoryFolderBase folder) + //{ + //} + + //public override bool MoveFolder(InventoryFolderBase folder) + //{ + // XInventoryFolder[] x = m_Database.GetFolders( + // new string[] { "folderID" }, + // new string[] { folder.ID.ToString() }); + + // if (x.Length == 0) + // return false; + + // // Check if it's under the Suitcase folder + // List skel = base.GetInventorySkeleton(folder.Owner); + // InventoryFolderBase suitcase = GetRootFolder(folder.Owner); + // List suitDescendents = GetDescendents(skel, suitcase.ID); + + // foreach (InventoryFolderBase f in suitDescendents) + // if (folder.ParentID == f.ID) + // { + // x[0].parentFolderID = folder.ParentID; + // return m_Database.StoreFolder(x[0]); + // } + + // return false; + //} + + public override bool DeleteFolders(UUID principalID, List folderIDs) + { + // NOGO + return false; + } + + public override bool PurgeFolder(InventoryFolderBase folder) + { + // NOGO + return false; + } + + // Unfortunately we need to use the inherited method because of how DeRez works. + // The viewer sends the folderID hard-wired in the derez message + //public override bool AddItem(InventoryItemBase item) + //{ + // // Check if it's under the Suitcase folder + // List skel = base.GetInventorySkeleton(item.Owner); + // InventoryFolderBase suitcase = GetRootFolder(item.Owner); + // List suitDescendents = GetDescendents(skel, suitcase.ID); + + // foreach (InventoryFolderBase f in suitDescendents) + // if (item.Folder == f.ID) + // return m_Database.StoreItem(ConvertFromOpenSim(item)); + + // return false; + //} + + //public override bool UpdateItem(InventoryItemBase item) + //{ + // // Check if it's under the Suitcase folder + // List skel = base.GetInventorySkeleton(item.Owner); + // InventoryFolderBase suitcase = GetRootFolder(item.Owner); + // List suitDescendents = GetDescendents(skel, suitcase.ID); + + // foreach (InventoryFolderBase f in suitDescendents) + // if (item.Folder == f.ID) + // return m_Database.StoreItem(ConvertFromOpenSim(item)); + + // return false; + //} + + //public override bool MoveItems(UUID principalID, List items) + //{ + // // Principal is b0rked. *sigh* + // // + // // Let's assume they all have the same principal + // // Check if it's under the Suitcase folder + // List skel = base.GetInventorySkeleton(items[0].Owner); + // InventoryFolderBase suitcase = GetRootFolder(items[0].Owner); + // List suitDescendents = GetDescendents(skel, suitcase.ID); + + // foreach (InventoryItemBase i in items) + // { + // foreach (InventoryFolderBase f in suitDescendents) + // if (i.Folder == f.ID) + // m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString()); + // } + + // return true; + //} + + // Let these pass. Use inherited methods. + //public bool DeleteItems(UUID principalID, List itemIDs) + //{ + //} + + public override InventoryItemBase GetItem(InventoryItemBase item) + { + InventoryItemBase it = base.GetItem(item); + + UserAccount user = m_Cache.GetUser(it.CreatorId); + + // Adjust the creator data + if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) + it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName; + + return it; + } + + //public InventoryFolderBase GetFolder(InventoryFolderBase folder) + //{ + //} + + //public List GetActiveGestures(UUID principalID) + //{ + //} + + //public int GetAssetPermissions(UUID principalID, UUID assetID) + //{ + //} + + } +} -- cgit v1.1 From 3292a2255882018b7fed3e80f430dc26892b92ea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Nov 2010 22:06:34 -0800 Subject: Creator information preserved upon HG transfers. --- OpenSim/Services/HypergridService/HGAssetService.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 6e0d4cd..9b098a0 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -126,7 +126,6 @@ namespace OpenSim.Services.HypergridService UserAccount creator = m_Cache.GetUser(meta.CreatorID); if (creator != null) meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; - } protected byte[] AdjustIdentifiers(byte[] data) -- cgit v1.1 From 947d730b56d901478f81fa396fca9373f1415eae Mon Sep 17 00:00:00 2001 From: Marck Date: Sat, 27 Nov 2010 09:18:39 +0100 Subject: Make gatekeeper's address check case-insensitive. --- OpenSim/Services/HypergridService/GatekeeperService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 3f5c4f1..0aa5352 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -333,7 +333,8 @@ namespace OpenSim.Services.HypergridService string addressee = parts[0]; m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName); - return (addressee == m_ExternalName); + + return string.Equals(addressee, m_ExternalName, StringComparison.OrdinalIgnoreCase); } #endregion -- cgit v1.1 From f86c438653fc3c8356a8f0c43a055b1928183f02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 29 Nov 2010 08:43:33 -0800 Subject: Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function. --- .../Services/HypergridService/HGAssetService.cs | 44 +-------- .../Services/HypergridService/UserAccountCache.cs | 105 +++++++++++++++++++++ 2 files changed, 107 insertions(+), 42 deletions(-) create mode 100644 OpenSim/Services/HypergridService/UserAccountCache.cs (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 9b098a0..584ab6f 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -35,6 +35,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Serialization.External; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenSim.Services.AssetService; @@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService protected byte[] AdjustIdentifiers(byte[] data) { string xml = Utils.BytesToString(data); - return Utils.StringToBytes(RewriteSOP(xml)); - } - - protected string RewriteSOP(string xml) - { - XmlDocument doc = new XmlDocument(); - doc.LoadXml(xml); - XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); - - foreach (XmlNode sop in sops) - { - UserAccount creator = null; - bool hasCreatorData = false; - XmlNodeList nodes = sop.ChildNodes; - foreach (XmlNode node in nodes) - { - if (node.Name == "CreatorID") - creator = m_Cache.GetUser(node.InnerText); - if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) - hasCreatorData = true; - - //if (node.Name == "OwnerID") - //{ - // UserAccount owner = GetUser(node.InnerText); - // if (owner != null) - // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; - //} - } - if (!hasCreatorData && creator != null) - { - XmlElement creatorData = doc.CreateElement("CreatorData"); - creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; - sop.AppendChild(creatorData); - } - } - - using (StringWriter wr = new StringWriter()) - { - doc.Save(wr); - return wr.ToString(); - } - + return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); } } diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs new file mode 100644 index 0000000..3e9aea1 --- /dev/null +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using log4net; +using OpenMetaverse; + +using OpenSim.Services.Interfaces; + +namespace OpenSim.Services.HypergridService +{ + public class UserAccountCache : IUserAccountService + { + private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! + + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + private ExpiringCache m_UUIDCache; + + private IUserAccountService m_UserAccountService; + + private static UserAccountCache m_Singleton; + + public static UserAccountCache CreateUserAccountCache(IUserAccountService u) + { + if (m_Singleton == null) + m_Singleton = new UserAccountCache(u); + + return m_Singleton; + } + + private UserAccountCache(IUserAccountService u) + { + m_UUIDCache = new ExpiringCache(); + m_UserAccountService = u; + } + + public void Cache(UUID userID, UserAccount account) + { + // Cache even null accounts + m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); + + //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); + } + + public UserAccount Get(UUID userID, out bool inCache) + { + UserAccount account = null; + inCache = false; + if (m_UUIDCache.TryGetValue(userID, out account)) + { + //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); + inCache = true; + return account; + } + + return null; + } + + public UserAccount GetUser(string id) + { + UUID uuid = UUID.Zero; + UUID.TryParse(id, out uuid); + bool inCache = false; + UserAccount account = Get(uuid, out inCache); + if (!inCache) + { + account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid); + Cache(uuid, account); + } + + return account; + } + + #region IUserAccountService + public UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + return GetUser(userID.ToString()); + } + + public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) + { + return null; + } + + public UserAccount GetUserAccount(UUID scopeID, string Email) + { + return null; + } + + public List GetUserAccounts(UUID scopeID, string query) + { + return null; + } + + public bool StoreUserAccount(UserAccount data) + { + return false; + } + #endregion + + } + +} -- cgit v1.1 From 7d24dbca3c85cafe182648139ab132563e3e1cdd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 1 Dec 2010 16:01:22 -0800 Subject: Added some comments. Better than listening to the boring speaker... --- OpenSim/Services/HypergridService/HGAssetService.cs | 5 +++++ OpenSim/Services/HypergridService/HGInventoryService.cs | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'OpenSim/Services/HypergridService') diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 584ab6f..a82d0d1 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -42,6 +42,11 @@ using OpenSim.Services.AssetService; namespace OpenSim.Services.HypergridService { + /// + /// Hypergrid asset service. It serves the IAssetService interface, + /// but implements it in ways that are appropriate for inter-grid + /// asset exchanges. + /// public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService { private static readonly ILog m_log = diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index a04f0c4..9ee1ae4 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -40,6 +40,13 @@ using OpenSim.Server.Base; namespace OpenSim.Services.HypergridService { + /// + /// Hypergrid inventory service. It serves the IInventoryService interface, + /// but implements it in ways that are appropriate for inter-grid + /// inventory exchanges. Specifically, it does not performs deletions + /// and it responds to GetRootFolder requests with the ID of the + /// Suitcase folder, not the actual "My Inventory" folder. + /// public class HGInventoryService : XInventoryService, IInventoryService { private static readonly ILog m_log = -- cgit v1.1