From c295354ea035c7e62f8a2c58868d2303a3ede883 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 16:15:04 -0700 Subject: Fixes GetRootFolder for normal standalone, which was being incorrectly redirected to the wrong object. Probably fixes most grief in http://opensimulator.org/mantis/view.php?id=4035 http://opensimulator.org/mantis/view.php?id=4027 --- .../Inventory/LocalInventoryServiceConnector.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 562c5dd..e6edcf2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override Dictionary GetSystemFolders(UUID userID) { - InventoryFolderBase root = GetRootFolder(userID); + InventoryFolderBase root = m_InventoryService.GetRootFolder(userID); if (root != null) { InventoryCollection content = GetFolderContent(userID, root.ID); @@ -202,13 +202,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) { - m_log.InfoFormat("[INVENTORY CONNECTOR]: folder type {0} ", folder.Type); + //m_log.InfoFormat("[INVENTORY CONNECTOR]: folder type {0} ", folder.Type); folders[(AssetType)folder.Type] = folder; } } // Put the root folder there, as type Folder folders[AssetType.Folder] = root; - m_log.InfoFormat("[INVENTORY CONNECTOR]: root folder is type {0} ", root.Type); + //m_log.InfoFormat("[INVENTORY CONNECTOR]: root folder is type {0} ", root.Type); return folders; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a119efc..a9d361b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -179,8 +179,8 @@ namespace OpenSim.Region.Framework.Scenes else { m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not resolve user {0} for caps inventory update", - remoteClient.AgentId); + "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", + itemID); } return UUID.Zero; -- cgit v1.1 From f1287cc7af7da26910c5cba456a8c35b6454d815 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 18:54:20 -0500 Subject: * Switching IAssetData to follow the new naming schema, removing the separate insert and update methods. --- OpenSim/Data/AssetDataBase.cs | 10 +---- OpenSim/Data/IAssetData.cs | 5 +-- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 19 ++++++--- OpenSim/Data/MySQL/MySQLAssetData.cs | 13 +----- OpenSim/Data/NHibernate/NHibernateAssetData.cs | 24 +++++------ OpenSim/Data/SQLite/SQLiteAssetData.cs | 47 +++++++++------------- OpenSim/Data/Tests/BasicAssetTest.cs | 24 +++++------ OpenSim/Framework/Servers/GetAssetStreamHandler.cs | 2 +- .../Framework/Servers/PostAssetStreamHandler.cs | 2 +- .../Servers/Tests/GetAssetStreamHandlerTests.cs | 2 +- .../Plugins/OpenSim/OpenSimAssetStoragePlugin.cs | 8 ++-- OpenSim/Grid/AssetServer/Main.cs | 2 +- OpenSim/Services/AssetService/AssetService.cs | 10 ++--- 13 files changed, 73 insertions(+), 95 deletions(-) diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index f723ebf..5deb44e 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs @@ -36,15 +36,9 @@ namespace OpenSim.Data { public abstract class AssetDataBase : IAssetDataPlugin { - public virtual AssetBase FetchAsset(UUID uuid) - { - return FetchStoredAsset(uuid); - } - - protected abstract AssetBase FetchStoredAsset(UUID uuid); + public abstract AssetBase GetAsset(UUID uuid); - public abstract void CreateAsset(AssetBase asset); - public abstract void UpdateAsset(AssetBase asset); + public abstract void StoreAsset(AssetBase asset); public abstract bool ExistsAsset(UUID uuid); public abstract List FetchAssetMetadataSet(int start, int count); diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs index d13732b..2149bca 100644 --- a/OpenSim/Data/IAssetData.cs +++ b/OpenSim/Data/IAssetData.cs @@ -33,9 +33,8 @@ namespace OpenSim.Data { public interface IAssetDataPlugin : IPlugin { - AssetBase FetchAsset(UUID uuid); - void CreateAsset(AssetBase asset); - void UpdateAsset(AssetBase asset); + AssetBase GetAsset(UUID uuid); + void StoreAsset(AssetBase asset); bool ExistsAsset(UUID uuid); List FetchAssetMetadataSet(int start, int count); void Initialise(string connect); diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index a542584..d193cf5 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MSSQL /// /// the asset UUID /// - override protected AssetBase FetchStoredAsset(UUID assetID) + override public AssetBase GetAsset(UUID assetID) { string sql = "SELECT * FROM assets WHERE id = @id"; using (AutoClosingSqlCommand command = m_database.Query(sql)) @@ -152,7 +152,16 @@ namespace OpenSim.Data.MSSQL /// Create asset in m_database /// /// the asset - override public void CreateAsset(AssetBase asset) + override public void StoreAsset(AssetBase asset) + { + if (ExistsAsset(asset.FullID)) + UpdateAsset(asset); + else + InsertAsset(asset); + } + + + private void InsertAsset(AssetBase asset) { if (ExistsAsset(asset.FullID)) { @@ -208,7 +217,7 @@ namespace OpenSim.Data.MSSQL /// Update asset in m_database /// /// the asset - override public void UpdateAsset(AssetBase asset) + private void UpdateAsset(AssetBase asset) { string sql = @"UPDATE assets set id = @id, name = @name, description = @description, assetType = @assetType, local = @local, temporary = @temporary, data = @data @@ -250,7 +259,7 @@ namespace OpenSim.Data.MSSQL } } -// Commented out since currently unused - this probably should be called in FetchAsset() +// Commented out since currently unused - this probably should be called in GetAsset() // private void UpdateAccessTime(AssetBase asset) // { // using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) @@ -276,7 +285,7 @@ namespace OpenSim.Data.MSSQL /// true if exist. override public bool ExistsAsset(UUID uuid) { - if (FetchAsset(uuid) != null) + if (GetAsset(uuid) != null) { return true; } diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 0865083..1b4377a 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -135,7 +135,7 @@ namespace OpenSim.Data.MySQL /// Asset UUID to fetch /// Return the asset /// On failure : throw an exception and attempt to reconnect to database - override protected AssetBase FetchStoredAsset(UUID assetID) + override public AssetBase GetAsset(UUID assetID) { AssetBase asset = null; lock (_dbConnection) @@ -192,7 +192,7 @@ namespace OpenSim.Data.MySQL /// /// Asset UUID to create /// On failure : Throw an exception and attempt to reconnect to database - override public void CreateAsset(AssetBase asset) + override public void StoreAsset(AssetBase asset) { lock (_dbConnection) { @@ -285,15 +285,6 @@ namespace OpenSim.Data.MySQL } /// - /// Update a asset in database, see - /// - /// Asset UUID to update - override public void UpdateAsset(AssetBase asset) - { - CreateAsset(asset); - } - - /// /// check if the asset UUID exist in database /// /// The asset UUID diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index 9d8cec5..aaba15c 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs @@ -65,30 +65,24 @@ namespace OpenSim.Data.NHibernate } - override protected AssetBase FetchStoredAsset(UUID uuid) + override public AssetBase GetAsset(UUID uuid) { return (AssetBase)manager.Get(typeof(AssetBase), uuid); } - private void Save(AssetBase asset) + override public void StoreAsset(AssetBase asset) { AssetBase temp = (AssetBase)manager.Get(typeof(AssetBase), asset.FullID); if (temp == null) { + m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); manager.Insert(asset); } - } - - override public void CreateAsset(AssetBase asset) - { - m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); - Save(asset); - } - - override public void UpdateAsset(AssetBase asset) - { - m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID); - manager.Update(asset); + else + { + m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID); + manager.Update(asset); + } } // private void LogAssetLoad(AssetBase asset) @@ -107,7 +101,7 @@ namespace OpenSim.Data.NHibernate override public bool ExistsAsset(UUID uuid) { m_log.InfoFormat("[NHIBERNATE] ExistsAsset: {0}", uuid); - return (FetchAsset(uuid) != null); + return (GetAsset(uuid) != null); } /// diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 72af7a0..3831467 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -90,7 +90,7 @@ namespace OpenSim.Data.SQLite /// /// UUID of ... ? /// Asset base - override protected AssetBase FetchStoredAsset(UUID uuid) + override public AssetBase GetAsset(UUID uuid) { lock (this) { @@ -119,18 +119,16 @@ namespace OpenSim.Data.SQLite /// Create an asset /// /// Asset Base - override public void CreateAsset(AssetBase asset) + override public void StoreAsset(AssetBase asset) { //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString()); if (ExistsAsset(asset.FullID)) { - //m_log.Info("[ASSET DB]: Asset exists already, ignoring."); - } - else - { + LogAssetLoad(asset); + lock (this) { - using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) + using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) { cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); @@ -144,29 +142,22 @@ namespace OpenSim.Data.SQLite } } } - } - - /// - /// Update an asset - /// - /// - override public void UpdateAsset(AssetBase asset) - { - LogAssetLoad(asset); - - lock (this) + else { - using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) + lock (this) { - cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); - cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); - cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); - cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); - cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); - cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); - - cmd.ExecuteNonQuery(); + using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) + { + cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString())); + cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); + cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); + cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); + cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); + cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); + cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); + + cmd.ExecuteNonQuery(); + } } } } diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 09131c1..1969d76 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -84,34 +84,34 @@ namespace OpenSim.Data.Tests scrambler.Scramble(a2); scrambler.Scramble(a3); - db.CreateAsset(a1); - db.CreateAsset(a2); - db.CreateAsset(a3); + db.StoreAsset(a1); + db.StoreAsset(a2); + db.StoreAsset(a3); - AssetBase a1a = db.FetchAsset(uuid1); + AssetBase a1a = db.GetAsset(uuid1); Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); - AssetBase a2a = db.FetchAsset(uuid2); + AssetBase a2a = db.GetAsset(uuid2); Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); - AssetBase a3a = db.FetchAsset(uuid3); + AssetBase a3a = db.GetAsset(uuid3); Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); scrambler.Scramble(a1a); scrambler.Scramble(a2a); scrambler.Scramble(a3a); - db.UpdateAsset(a1a); - db.UpdateAsset(a2a); - db.UpdateAsset(a3a); + db.StoreAsset(a1a); + db.StoreAsset(a2a); + db.StoreAsset(a3a); - AssetBase a1b = db.FetchAsset(uuid1); + AssetBase a1b = db.GetAsset(uuid1); Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a)); - AssetBase a2b = db.FetchAsset(uuid2); + AssetBase a2b = db.GetAsset(uuid2); Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a)); - AssetBase a3b = db.FetchAsset(uuid3); + AssetBase a3b = db.GetAsset(uuid3); Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a)); Assert.That(db.ExistsAsset(uuid1), Is.True); diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs index bc046cf..c6958de 100644 --- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs +++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers protected override AssetBase GetAsset(UUID assetID) { - return m_assetProvider.FetchAsset(assetID); + return m_assetProvider.GetAsset(assetID); } } } diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs index 419b408..8bf406c 100644 --- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs +++ b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers AssetBase asset = (AssetBase) xs.Deserialize(request); m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID); - m_assetProvider.CreateAsset(asset); + m_assetProvider.StoreAsset(asset); return new byte[] {}; } diff --git a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs index 35da73f..be3f518 100644 --- a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs +++ b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs @@ -128,7 +128,7 @@ namespace OpenSim.Framework.Servers.Tests IAssetDataPlugin assetDataPlugin = new TestAssetDataPlugin(); handler = new GetAssetStreamHandler(assetDataPlugin); - assetDataPlugin.CreateAsset(asset); + assetDataPlugin.StoreAsset(asset); return asset; } } diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs index 0631ee7..92ac84f 100644 --- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs +++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimAssetStoragePlugin.cs @@ -57,7 +57,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim metadata = null; BackendResponse ret; - AssetBase asset = m_assetProvider.FetchAsset(assetID); + AssetBase asset = m_assetProvider.GetAsset(assetID); if (asset == null) ret = BackendResponse.NotFound; else @@ -75,7 +75,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim assetData = null; BackendResponse ret; - AssetBase asset = m_assetProvider.FetchAsset(assetID); + AssetBase asset = m_assetProvider.GetAsset(assetID); if (asset == null) ret = BackendResponse.NotFound; else @@ -90,7 +90,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim public BackendResponse TryFetchDataMetadata(UUID assetID, out AssetBase asset) { - asset = m_assetProvider.FetchAsset(assetID); + asset = m_assetProvider.GetAsset(assetID); if (asset == null) return BackendResponse.NotFound; @@ -107,7 +107,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim { BackendResponse ret; - m_assetProvider.CreateAsset(asset); + m_assetProvider.StoreAsset(asset); ret = BackendResponse.Success; m_server.MetricsProvider.LogAssetCreate(EXTENSION_NAME, ret, asset.FullID, asset.Data.Length, DateTime.Now); diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index f25e847..ac8f888 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -140,7 +140,7 @@ namespace OpenSim.Grid.AssetServer protected void StoreAsset(AssetBase asset) { - m_assetProvider.CreateAsset(asset); + m_assetProvider.StoreAsset(asset); } } } diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index fe663eb..88a905c 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -83,7 +83,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return null; - return m_Database.FetchAsset(assetID); + return m_Database.GetAsset(assetID); } public AssetMetadata GetMetadata(string id) @@ -93,7 +93,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return null; - AssetBase asset = m_Database.FetchAsset(assetID); + AssetBase asset = m_Database.GetAsset(assetID); return asset.Metadata; } @@ -104,7 +104,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return null; - AssetBase asset = m_Database.FetchAsset(assetID); + AssetBase asset = m_Database.GetAsset(assetID); return asset.Data; } @@ -117,7 +117,7 @@ namespace OpenSim.Services.AssetService if (!UUID.TryParse(id, out assetID)) return false; - AssetBase asset = m_Database.FetchAsset(assetID); + AssetBase asset = m_Database.GetAsset(assetID); //m_log.DebugFormat("[AssetService]: Got asset {0}", asset); @@ -129,7 +129,7 @@ namespace OpenSim.Services.AssetService public string Store(AssetBase asset) { //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); - m_Database.CreateAsset(asset); + m_Database.StoreAsset(asset); return asset.ID; } -- cgit v1.1 From b1853d9f265fb32cf51d65fdcf2d5b4741911f00 Mon Sep 17 00:00:00 2001 From: Kunnis Date: Sun, 16 Aug 2009 23:25:12 -0500 Subject: Fixing a spot I missed in assets. Switching Grid to the new naming schema with Store/Get --- OpenSim/Data/GridDataBase.cs | 3 +-- OpenSim/Data/IGridData.cs | 11 ++------- OpenSim/Data/MSSQL/MSSQLGridData.cs | 27 ++++++++++------------ OpenSim/Data/MySQL/MySQLGridData.cs | 13 +---------- OpenSim/Data/NHibernate/NHibernateGridData.cs | 14 +---------- OpenSim/Data/SQLite/SQLiteGridData.cs | 10 ++------ OpenSim/Data/Tests/BasicGridTest.cs | 8 +++---- .../Cache/UserProfileCacheService.cs | 2 +- .../Tests/Cache/UserProfileCacheServiceTests.cs | 4 ++-- OpenSim/Grid/GridServer.Modules/GridDBService.cs | 6 ++--- OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs | 13 +++++++++++ 11 files changed, 42 insertions(+), 69 deletions(-) diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index 5a30455..a03488b 100644 --- a/OpenSim/Data/GridDataBase.cs +++ b/OpenSim/Data/GridDataBase.cs @@ -38,9 +38,8 @@ namespace OpenSim.Data public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); public abstract List GetRegionsByName(string namePrefix, uint maxNum); public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); - public abstract DataResponse AddProfile(RegionProfileData profile); + public abstract DataResponse StoreProfile(RegionProfileData profile); public abstract ReservationData GetReservationAtPoint(uint x, uint y); - public abstract DataResponse UpdateProfile(RegionProfileData profile); public abstract DataResponse DeleteProfile(string uuid); public abstract void Initialise(); diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs index 4bf8646..8bd3811 100644 --- a/OpenSim/Data/IGridData.cs +++ b/OpenSim/Data/IGridData.cs @@ -99,18 +99,11 @@ namespace OpenSim.Data bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); /// - /// Adds a new profile to the database + /// Adds or updates a profile in the database /// /// The profile to add /// RESPONSE_OK if successful, error if not. - DataResponse AddProfile(RegionProfileData profile); - - /// - /// Updates a profile in the database - /// - /// - /// - DataResponse UpdateProfile(RegionProfileData profile); + DataResponse StoreProfile(RegionProfileData profile); /// /// Remove a profile from the database diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 0ebbf4e..8a3d332 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs @@ -272,26 +272,23 @@ namespace OpenSim.Data.MSSQL /// /// The profile to add /// A dataresponse enum indicating success - override public DataResponse AddProfile(RegionProfileData profile) + override public DataResponse StoreProfile(RegionProfileData profile) { - if (InsertRegionRow(profile)) + if (GetProfileByUUID(profile.UUID) == null) { - return DataResponse.RESPONSE_OK; + if (InsertRegionRow(profile)) + { + return DataResponse.RESPONSE_OK; + } } - return DataResponse.RESPONSE_ERROR; - } - - /// - /// Update the specified region in the database - /// - /// The profile to update - /// A dataresponse enum indicating success - override public DataResponse UpdateProfile(RegionProfileData profile) - { - if (UpdateRegionRow(profile)) + else { - return DataResponse.RESPONSE_OK; + if (UpdateRegionRow(profile)) + { + return DataResponse.RESPONSE_OK; + } } + return DataResponse.RESPONSE_ERROR; } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 0a5800b..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -391,7 +391,7 @@ namespace OpenSim.Data.MySQL /// /// The profile to add /// Successful? - override public DataResponse AddProfile(RegionProfileData profile) + override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); try { @@ -408,17 +408,6 @@ namespace OpenSim.Data.MySQL } /// - /// Update a sim profile - /// - /// The profile to update - /// Sucessful? - /// Same as AddProfile - override public DataResponse UpdateProfile(RegionProfileData profile) - { - return AddProfile(profile); - } - - /// /// Deletes a sim profile from the database /// /// the sim UUID diff --git a/OpenSim/Data/NHibernate/NHibernateGridData.cs b/OpenSim/Data/NHibernate/NHibernateGridData.cs index fe8da59..018af62 100644 --- a/OpenSim/Data/NHibernate/NHibernateGridData.cs +++ b/OpenSim/Data/NHibernate/NHibernateGridData.cs @@ -117,7 +117,7 @@ namespace OpenSim.Data.NHibernate throw new NotImplementedException(); } - public override DataResponse AddProfile(RegionProfileData profile) + public override DataResponse StoreProfile(RegionProfileData profile) { if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null) { @@ -126,21 +126,9 @@ namespace OpenSim.Data.NHibernate } else { - return DataResponse.RESPONSE_ERROR; - } - } - - public override DataResponse UpdateProfile(RegionProfileData profile) - { - if (manager.Get(typeof(RegionProfileData), profile.Uuid) != null) - { manager.Update(profile); return DataResponse.RESPONSE_OK; } - else - { - return DataResponse.RESPONSE_ERROR; - } } public override DataResponse DeleteProfile(string uuid) diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs index 4107594..18abb88 100644 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridData.cs @@ -203,7 +203,7 @@ namespace OpenSim.Data.SQLite /// /// The profile to add /// A dataresponse enum indicating success - override public DataResponse AddProfile(RegionProfileData profile) + override public DataResponse StoreProfile(RegionProfileData profile) { if (database.insertRow(profile)) { @@ -215,17 +215,11 @@ namespace OpenSim.Data.SQLite } } - override public DataResponse UpdateProfile(RegionProfileData profile) - { - return AddProfile(profile); - } - - /// + /// /// Deletes a sim profile from the database /// /// the sim UUID /// Successful? - //public DataResponse DeleteProfile(RegionProfileData profile) override public DataResponse DeleteProfile(string uuid) { Dictionary param = new Dictionary(); diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs index de8fb48..df6c669 100644 --- a/OpenSim/Data/Tests/BasicGridTest.cs +++ b/OpenSim/Data/Tests/BasicGridTest.cs @@ -70,7 +70,7 @@ namespace OpenSim.Data.Tests reg.Uuid = regionUUID; reg.RegionName = regionName; - db.AddProfile(reg); + db.StoreProfile(reg); return reg; } @@ -120,7 +120,7 @@ namespace OpenSim.Data.Tests RegionProfileData retreg = db.GetProfileByUUID(region2); retreg.regionName = "Gotham City"; - db.UpdateProfile(retreg); + db.StoreProfile(retreg); retreg = db.GetProfileByUUID(region2); Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))"); @@ -135,13 +135,13 @@ namespace OpenSim.Data.Tests retreg.RegionName = "Gotham Town"; retreg.Uuid = region1; - db.AddProfile(retreg); + db.StoreProfile(retreg); retreg = db.GetProfileByUUID(region2); retreg.RegionName = "Gothan Town"; retreg.Uuid = region3; - db.AddProfile(retreg); + db.StoreProfile(retreg); List listreg = db.GetRegionsByName("Gotham",10); diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index c9f5236..7f1c7e9 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -184,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache // Commented out for now. The implementation needs to be improved by protecting against race conditions, // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via // returning a read only class from the cache). -// public bool UpdateProfile(UserProfileData userProfile) +// public bool StoreProfile(UserProfileData userProfile) // { // lock (m_userProfilesById) // { diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 670c9ff..933fa12 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -110,14 +110,14 @@ namespace OpenSim.Framework.Communications.Tests IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; // Check that we can't update info before it exists - Assert.That(userCacheService.UpdateProfile(newProfile), Is.False); + Assert.That(userCacheService.StoreProfile(newProfile), Is.False); Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null); // Check that we can update a profile once it exists LocalUserServices lus = (LocalUserServices)commsManager.UserService; lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); - Assert.That(userCacheService.UpdateProfile(newProfile), Is.True); + Assert.That(userCacheService.StoreProfile(newProfile), Is.True); UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile; Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); diff --git a/OpenSim/Grid/GridServer.Modules/GridDBService.cs b/OpenSim/Grid/GridServer.Modules/GridDBService.cs index caa2c10..fd5a09a 100644 --- a/OpenSim/Grid/GridServer.Modules/GridDBService.cs +++ b/OpenSim/Grid/GridServer.Modules/GridDBService.cs @@ -206,11 +206,11 @@ namespace OpenSim.Grid.GridServer.Modules { if (existingSim == null) { - insertResponse = plugin.AddProfile(sim); + insertResponse = plugin.StoreProfile(sim); } else { - insertResponse = plugin.UpdateProfile(sim); + insertResponse = plugin.StoreProfile(sim); } } catch (Exception e) @@ -259,7 +259,7 @@ namespace OpenSim.Grid.GridServer.Modules if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) { - plugin.AddProfile(theSim); + plugin.StoreProfile(theSim); m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5, "Region successfully updated and connected to grid."); diff --git a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs index 8ab72dc..3981fe9 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetDataPlugin.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; @@ -46,6 +47,18 @@ namespace OpenSim.Tests.Common.Mock public void Initialise(string connect) {} public void Dispose() {} + private readonly List assets = new List(); + + public AssetBase GetAsset(UUID uuid) + { + return assets.Find(x=>x.FullID == uuid); + } + + public void StoreAsset(AssetBase asset) + { + assets.Add(asset); + } + public List FetchAssetMetadataSet(int start, int count) { return new List(count); } } } \ No newline at end of file -- cgit v1.1