Fixing a spot I missed in assets. Switching Grid to the new naming schema with Store/Get

arthursv
Kunnis 2009-08-16 23:25:12 -05:00 committed by Melanie
parent f1287cc7af
commit b1853d9f26
11 changed files with 43 additions and 70 deletions

View File

@ -38,9 +38,8 @@ namespace OpenSim.Data
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum); public abstract List<RegionProfileData> GetRegionsByName(string namePrefix, uint maxNum);
public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); 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 ReservationData GetReservationAtPoint(uint x, uint y);
public abstract DataResponse UpdateProfile(RegionProfileData profile);
public abstract DataResponse DeleteProfile(string uuid); public abstract DataResponse DeleteProfile(string uuid);
public abstract void Initialise(); public abstract void Initialise();

View File

@ -99,18 +99,11 @@ namespace OpenSim.Data
bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey);
/// <summary> /// <summary>
/// Adds a new profile to the database /// Adds or updates a profile in the database
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>RESPONSE_OK if successful, error if not.</returns> /// <returns>RESPONSE_OK if successful, error if not.</returns>
DataResponse AddProfile(RegionProfileData profile); DataResponse StoreProfile(RegionProfileData profile);
/// <summary>
/// Updates a profile in the database
/// </summary>
/// <param name="profile"></param>
/// <returns></returns>
DataResponse UpdateProfile(RegionProfileData profile);
/// <summary> /// <summary>
/// Remove a profile from the database /// Remove a profile from the database

View File

@ -272,26 +272,23 @@ namespace OpenSim.Data.MSSQL
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns> /// <returns>A dataresponse enum indicating success</returns>
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;
}
/// <summary>
/// Update the specified region in the database
/// </summary>
/// <param name="profile">The profile to update</param>
/// <returns>A dataresponse enum indicating success</returns>
override public DataResponse UpdateProfile(RegionProfileData profile)
{
if (UpdateRegionRow(profile))
{
return DataResponse.RESPONSE_OK;
}
return DataResponse.RESPONSE_ERROR; return DataResponse.RESPONSE_ERROR;
} }

View File

@ -391,7 +391,7 @@ namespace OpenSim.Data.MySQL
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>Successful?</returns> /// <returns>Successful?</returns>
override public DataResponse AddProfile(RegionProfileData profile) override public DataResponse StoreProfile(RegionProfileData profile)
{ {
MySQLSuperManager dbm = GetLockedConnection(); MySQLSuperManager dbm = GetLockedConnection();
try { try {
@ -407,17 +407,6 @@ namespace OpenSim.Data.MySQL
} }
} }
/// <summary>
/// Update a sim profile
/// </summary>
/// <param name="profile">The profile to update</param>
/// <returns>Sucessful?</returns>
/// <remarks>Same as AddProfile</remarks>
override public DataResponse UpdateProfile(RegionProfileData profile)
{
return AddProfile(profile);
}
/// <summary> /// <summary>
/// Deletes a sim profile from the database /// Deletes a sim profile from the database
/// </summary> /// </summary>

View File

@ -117,7 +117,7 @@ namespace OpenSim.Data.NHibernate
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override DataResponse AddProfile(RegionProfileData profile) public override DataResponse StoreProfile(RegionProfileData profile)
{ {
if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null) if (manager.Get(typeof(RegionProfileData), profile.Uuid) == null)
{ {
@ -125,22 +125,10 @@ namespace OpenSim.Data.NHibernate
return DataResponse.RESPONSE_OK; return DataResponse.RESPONSE_OK;
} }
else else
{
return DataResponse.RESPONSE_ERROR;
}
}
public override DataResponse UpdateProfile(RegionProfileData profile)
{
if (manager.Get(typeof(RegionProfileData), profile.Uuid) != null)
{ {
manager.Update(profile); manager.Update(profile);
return DataResponse.RESPONSE_OK; return DataResponse.RESPONSE_OK;
} }
else
{
return DataResponse.RESPONSE_ERROR;
}
} }
public override DataResponse DeleteProfile(string uuid) public override DataResponse DeleteProfile(string uuid)

View File

@ -203,7 +203,7 @@ namespace OpenSim.Data.SQLite
/// </summary> /// </summary>
/// <param name="profile">The profile to add</param> /// <param name="profile">The profile to add</param>
/// <returns>A dataresponse enum indicating success</returns> /// <returns>A dataresponse enum indicating success</returns>
override public DataResponse AddProfile(RegionProfileData profile) override public DataResponse StoreProfile(RegionProfileData profile)
{ {
if (database.insertRow(profile)) if (database.insertRow(profile))
{ {
@ -215,17 +215,11 @@ namespace OpenSim.Data.SQLite
} }
} }
override public DataResponse UpdateProfile(RegionProfileData profile) /// <summary>
{
return AddProfile(profile);
}
/// <summary>
/// Deletes a sim profile from the database /// Deletes a sim profile from the database
/// </summary> /// </summary>
/// <param name="uuid">the sim UUID</param> /// <param name="uuid">the sim UUID</param>
/// <returns>Successful?</returns> /// <returns>Successful?</returns>
//public DataResponse DeleteProfile(RegionProfileData profile)
override public DataResponse DeleteProfile(string uuid) override public DataResponse DeleteProfile(string uuid)
{ {
Dictionary<string, string> param = new Dictionary<string, string>(); Dictionary<string, string> param = new Dictionary<string, string>();

View File

@ -70,7 +70,7 @@ namespace OpenSim.Data.Tests
reg.Uuid = regionUUID; reg.Uuid = regionUUID;
reg.RegionName = regionName; reg.RegionName = regionName;
db.AddProfile(reg); db.StoreProfile(reg);
return reg; return reg;
} }
@ -120,7 +120,7 @@ namespace OpenSim.Data.Tests
RegionProfileData retreg = db.GetProfileByUUID(region2); RegionProfileData retreg = db.GetProfileByUUID(region2);
retreg.regionName = "Gotham City"; retreg.regionName = "Gotham City";
db.UpdateProfile(retreg); db.StoreProfile(retreg);
retreg = db.GetProfileByUUID(region2); retreg = db.GetProfileByUUID(region2);
Assert.That(retreg.RegionName, Is.EqualTo("Gotham City"), "Assert.That(retreg.RegionName, Is.EqualTo(\"Gotham City\"))"); 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.RegionName = "Gotham Town";
retreg.Uuid = region1; retreg.Uuid = region1;
db.AddProfile(retreg); db.StoreProfile(retreg);
retreg = db.GetProfileByUUID(region2); retreg = db.GetProfileByUUID(region2);
retreg.RegionName = "Gothan Town"; retreg.RegionName = "Gothan Town";
retreg.Uuid = region3; retreg.Uuid = region3;
db.AddProfile(retreg); db.StoreProfile(retreg);
List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10); List<RegionProfileData> listreg = db.GetRegionsByName("Gotham",10);

View File

@ -184,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache
// Commented out for now. The implementation needs to be improved by protecting against race conditions, // 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 // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via
// returning a read only class from the cache). // returning a read only class from the cache).
// public bool UpdateProfile(UserProfileData userProfile) // public bool StoreProfile(UserProfileData userProfile)
// { // {
// lock (m_userProfilesById) // lock (m_userProfilesById)
// { // {

View File

@ -110,14 +110,14 @@ namespace OpenSim.Framework.Communications.Tests
IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin; IUserDataPlugin userDataPlugin = commsManager.UserDataPlugin;
// Check that we can't update info before it exists // 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); Assert.That(userDataPlugin.GetUserByUUID(userId), Is.Null);
// Check that we can update a profile once it exists // Check that we can update a profile once it exists
LocalUserServices lus = (LocalUserServices)commsManager.UserService; LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser(firstName, originalLastName, "pingu", "ted@excellentadventure.com", 1000, 1000, userId); 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; UserProfileData retrievedProfile = userCacheService.GetUserDetails(userId).UserProfile;
Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName)); Assert.That(retrievedProfile.SurName, Is.EqualTo(newLastName));
Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName)); Assert.That(userDataPlugin.GetUserByUUID(userId).SurName, Is.EqualTo(newLastName));

View File

@ -206,11 +206,11 @@ namespace OpenSim.Grid.GridServer.Modules
{ {
if (existingSim == null) if (existingSim == null)
{ {
insertResponse = plugin.AddProfile(sim); insertResponse = plugin.StoreProfile(sim);
} }
else else
{ {
insertResponse = plugin.UpdateProfile(sim); insertResponse = plugin.StoreProfile(sim);
} }
} }
catch (Exception e) catch (Exception e)
@ -259,7 +259,7 @@ namespace OpenSim.Grid.GridServer.Modules
if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) ||
(reserveData == null && authkeynode.InnerText != 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 + ")"); m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")");
logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5, logToDB(theSim.ToString(), "RestSetSimMethod", String.Empty, 5,
"Region successfully updated and connected to grid."); "Region successfully updated and connected to grid.");

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
@ -46,6 +47,18 @@ namespace OpenSim.Tests.Common.Mock
public void Initialise(string connect) {} public void Initialise(string connect) {}
public void Dispose() {} public void Dispose() {}
private readonly List<AssetBase> assets = new List<AssetBase>();
public AssetBase GetAsset(UUID uuid)
{
return assets.Find(x=>x.FullID == uuid);
}
public void StoreAsset(AssetBase asset)
{
assets.Add(asset);
}
public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); } public List<AssetMetadata> FetchAssetMetadataSet(int start, int count) { return new List<AssetMetadata>(count); }
} }
} }