diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index 5a304553c2..a03488bee3 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 4bf8646aec..8bd3811175 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 0ebbf4ebcf..8a3d332598 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; + } + } + else + { + if (UpdateRegionRow(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)) - { - return DataResponse.RESPONSE_OK; - } return DataResponse.RESPONSE_ERROR; } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 0a5800ba05..1ec26090b1 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 { @@ -407,17 +407,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 /// diff --git a/OpenSim/Data/NHibernate/NHibernateGridData.cs b/OpenSim/Data/NHibernate/NHibernateGridData.cs index fe8da59f43..018af62c8e 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) { @@ -125,22 +125,10 @@ namespace OpenSim.Data.NHibernate return DataResponse.RESPONSE_OK; } 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 4107594293..18abb8830d 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 de8fb48c5e..df6c669b0f 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 c9f5236f88..7f1c7e975b 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 670c9ff368..933fa12bc2 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 caa2c10c62..fd5a09abaa 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 8ab72dc55c..3981fe9bf1 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