From 468d1cf03e284d60ad92da4a62190d47845a77da Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 15 Nov 2012 04:01:30 +0000 Subject: [PATCH] refactor: move common inventory folder version update code to parent class in mysql, mssql and sqlite database plugins --- OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 47 ++++------------- OpenSim/Data/MySQL/MySQLXInventoryData.cs | 51 ++++--------------- OpenSim/Data/SQLite/SQLiteSimulationData.cs | 3 -- OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 42 ++++----------- .../World/Land/LandManagementModule.cs | 1 - .../Shared/Api/Implementation/LSL_Api.cs | 3 +- 6 files changed, 30 insertions(+), 117 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index 97970af325..9164ffe4e3 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MSSQL } } - public class MSSQLItemHandler : MSSQLGenericTableHandler + public class MSSQLItemHandler : MSSQLInventoryHandler { public MSSQLItemHandler(string c, string t, string m) : base(c, t, m) @@ -213,43 +213,9 @@ namespace OpenSim.Data.MSSQL return true; } - - private bool IncrementFolderVersion(UUID folderID) - { - return IncrementFolderVersion(folderID.ToString()); - } - - private bool IncrementFolderVersion(string folderID) - { -// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); -// Util.PrintCallStack(); - - string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID"; - - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - { - using (SqlCommand cmd = new SqlCommand(sql, conn)) - { - conn.Open(); - - cmd.Parameters.AddWithValue("@folderID", folderID); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - return false; - } - } - } - - return true; - } } - public class MSSQLFolderHandler : MSSQLGenericTableHandler + public class MSSQLFolderHandler : MSSQLInventoryHandler { public MSSQLFolderHandler(string c, string t, string m) : base(c, t, m) @@ -296,13 +262,18 @@ namespace OpenSim.Data.MSSQL return true; } + } - private bool IncrementFolderVersion(UUID folderID) + public class MSSQLInventoryHandler : MSSQLGenericTableHandler where T: class, new() + { + public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) { return IncrementFolderVersion(folderID.ToString()); } - private bool IncrementFolderVersion(string folderID) + protected bool IncrementFolderVersion(string folderID) { // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); // Util.PrintCallStack(); diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index 8901bdd4de..c74033eefc 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL } } - public class MySqlItemHandler : MySQLGenericTableHandler + public class MySqlItemHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -241,47 +241,9 @@ namespace OpenSim.Data.MySQL return true; } - - private bool IncrementFolderVersion(UUID folderID) - { - return IncrementFolderVersion(folderID.ToString()); - } - - private bool IncrementFolderVersion(string folderID) - { -// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); -// Util.PrintCallStack(); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - using (MySqlCommand cmd = new MySqlCommand()) - { - cmd.Connection = dbcon; - - cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", folderID); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - return false; - } - cmd.Dispose(); - } - - dbcon.Close(); - } - - return true; - } } - public class MySqlFolderHandler : MySQLGenericTableHandler + public class MySqlFolderHandler : MySqlInventoryHandler { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -326,13 +288,18 @@ namespace OpenSim.Data.MySQL return true; } + } - private bool IncrementFolderVersion(UUID folderID) + public class MySqlInventoryHandler : MySQLGenericTableHandler where T: class, new() + { + public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) { return IncrementFolderVersion(folderID.ToString()); } - private bool IncrementFolderVersion(string folderID) + protected bool IncrementFolderVersion(string folderID) { // m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); // Util.PrintCallStack(); diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 38a81929f3..9b6970c1ed 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -1366,7 +1366,6 @@ namespace OpenSim.Data.SQLite createCol(land, "UserLookAtZ", typeof(Double)); createCol(land, "AuthbuyerID", typeof(String)); createCol(land, "OtherCleanTime", typeof(Int32)); - createCol(land, "Dwell", typeof(Int32)); createCol(land, "MediaType", typeof(String)); createCol(land, "MediaDescription", typeof(String)); createCol(land, "MediaSize", typeof(String)); @@ -1788,7 +1787,6 @@ namespace OpenSim.Data.SQLite newData.PassHours = Convert.ToSingle(row["PassHours"]); newData.PassPrice = Convert.ToInt32(row["PassPrice"]); newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; - newData.Dwell = Convert.ToInt32(row["Dwell"]); newData.MediaType = (String)row["MediaType"]; newData.MediaDescription = (String)row["MediaDescription"]; newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]); @@ -2209,7 +2207,6 @@ namespace OpenSim.Data.SQLite row["UserLookAtZ"] = land.UserLookAt.Z; row["AuthbuyerID"] = land.AuthBuyerID.ToString(); row["OtherCleanTime"] = land.OtherCleanTime; - row["Dwell"] = land.Dwell; row["MediaType"] = land.MediaType; row["MediaDescription"] = land.MediaDescription; row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight); diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 87eb31eb0f..2a0a8f6cc9 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs @@ -130,7 +130,7 @@ namespace OpenSim.Data.SQLite } } - public class SqliteItemHandler : SQLiteGenericTableHandler + public class SqliteItemHandler : SqliteInventoryHandler { public SqliteItemHandler(string c, string t, string m) : base(c, t, m) @@ -243,37 +243,9 @@ namespace OpenSim.Data.SQLite return perms; } - - private bool IncrementFolderVersion(UUID folderID) - { - return IncrementFolderVersion(folderID.ToString()); - } - - private bool IncrementFolderVersion(string folderID) - { -// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); -// Util.PrintCallStack(); - - using (SqliteCommand cmd = new SqliteCommand()) - { - cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; - cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - return false; - } - } - - return true; - } } - public class SqliteFolderHandler : SQLiteGenericTableHandler + public class SqliteFolderHandler : SqliteInventoryHandler { public SqliteFolderHandler(string c, string t, string m) : base(c, t, m) @@ -315,12 +287,18 @@ namespace OpenSim.Data.SQLite return true; } - private bool IncrementFolderVersion(UUID folderID) + } + + public class SqliteInventoryHandler : SQLiteGenericTableHandler where T: class, new() + { + public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) { return IncrementFolderVersion(folderID.ToString()); } - private bool IncrementFolderVersion(string folderID) + protected bool IncrementFolderVersion(string folderID) { // m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); // Util.PrintCallStack(); diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index e93546258d..8b7406d7db 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -950,7 +950,6 @@ namespace OpenSim.Region.CoreModules.World.Land ILandObject newLand = startLandObject.Copy(); newLand.LandData.Name = newLand.LandData.Name; newLand.LandData.GlobalID = UUID.Random(); - newLand.LandData.Dwell = 0; newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 628496a388..0a0e68fca7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2062,7 +2062,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetPos() { m_host.AddScriptLPS(1); - return m_host.GetWorldPosition(); + Vector3 pos = m_host.GetWorldPosition(); + return new LSL_Vector(pos.X, pos.Y, pos.Z); } public LSL_Vector llGetLocalPos()