From 70b0e07d1ea99f8bd88f2be12bf9b53a39187f60 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 22 Mar 2010 18:49:56 +0000
Subject: Remove the reading of estate_settings.xml and the associated
processing of defaults. Adding code to facilitate estate creation /
managemment as part of first time start up
---
OpenSim/Data/MSSQL/MSSQLEstateData.cs | 23 ++---------------------
OpenSim/Data/MySQL/MySQLEstateData.cs | 18 +++++-------------
OpenSim/Data/SQLite/SQLiteEstateData.cs | 20 ++------------------
OpenSim/Data/Tests/BasicEstateTest.cs | 24 ++++++++++++------------
4 files changed, 21 insertions(+), 64 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
index 6f6f076..1624f56 100644
--- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Data.MSSQL
///
/// region ID.
///
- public EstateSettings LoadEstateSettings(UUID regionID)
+ public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
@@ -127,7 +127,7 @@ namespace OpenSim.Data.MSSQL
}
- if (insertEstate)
+ if (insertEstate && create)
{
List names = new List(FieldList);
@@ -173,25 +173,6 @@ namespace OpenSim.Data.MSSQL
}
}
- // Munge and transfer the ban list
-
- sql = string.Format("insert into estateban select {0}, bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID", es.EstateID);
- using (SqlConnection conn = new SqlConnection(m_connectionString))
- using (SqlCommand cmd = new SqlCommand(sql, conn))
- {
-
- cmd.Parameters.Add(_Database.CreateParameter("@UUID", regionID));
- try
- {
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception)
- {
- _Log.Debug("[ESTATE DB]: Error setting up estateban from regionban");
- }
- }
-
//TODO check if this is needed??
es.Save();
}
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index 2eae2d8..e94dcda 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -121,7 +121,7 @@ namespace OpenSim.Data.MySQL
}
}
- public EstateSettings LoadEstateSettings(UUID regionID)
+ public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
@@ -129,12 +129,12 @@ namespace OpenSim.Data.MySQL
string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) +
" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
- bool migration = true;
-
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
+ bool found = false;
+
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = sql;
@@ -144,7 +144,7 @@ namespace OpenSim.Data.MySQL
{
if (r.Read())
{
- migration = false;
+ found = true;
foreach (string name in FieldList)
{
@@ -172,7 +172,7 @@ namespace OpenSim.Data.MySQL
}
}
- if (migration)
+ if (!found && create)
{
// Migration case
List names = new List(FieldList);
@@ -220,14 +220,6 @@ namespace OpenSim.Data.MySQL
try { cmd.ExecuteNonQuery(); }
catch (Exception) { }
- // Munge and transfer the ban list
- cmd.Parameters.Clear();
- cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
- cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
-
- try { cmd.ExecuteNonQuery(); }
- catch (Exception) { }
-
es.Save();
}
}
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index 1be99ee..4a447d2 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Data.SQLite
get { return new List(m_FieldMap.Keys).ToArray(); }
}
- public EstateSettings LoadEstateSettings(UUID regionID)
+ public EstateSettings LoadEstateSettings(UUID regionID, bool create)
{
EstateSettings es = new EstateSettings();
es.OnSave += StoreEstateSettings;
@@ -120,10 +120,8 @@ namespace OpenSim.Data.SQLite
}
r.Close();
}
- else
+ else if (create)
{
- // Migration case
- //
r.Close();
List names = new List(FieldList);
@@ -176,20 +174,6 @@ namespace OpenSim.Data.SQLite
{
}
- // Munge and transfer the ban list
- //
- cmd.Parameters.Clear();
- cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
- cmd.Parameters.Add(":UUID", regionID.ToString());
-
- try
- {
- cmd.ExecuteNonQuery();
- }
- catch (Exception)
- {
- }
-
es.Save();
}
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
index 907bb38..d14d405 100644
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -158,7 +158,7 @@ namespace OpenSim.Data.Tests
public void T012_EstateSettingsRandomStorage()
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
new PropertyScrambler()
.DontScramble(x=>x.EstateID)
.Scramble(originalSettings);
@@ -167,7 +167,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
// Checking that loaded values are correct.
Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
@@ -177,7 +177,7 @@ namespace OpenSim.Data.Tests
public void T020_EstateSettingsManagerList()
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
@@ -185,7 +185,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
@@ -196,7 +196,7 @@ namespace OpenSim.Data.Tests
public void T021_EstateSettingsUserList()
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
@@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
@@ -215,7 +215,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsGroupList()
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
@@ -223,7 +223,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
@@ -234,7 +234,7 @@ namespace OpenSim.Data.Tests
public void T022_EstateSettingsBanList()
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
EstateBan estateBan1 = new EstateBan();
estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
@@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
+ EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
Assert.AreEqual(2, loadedSettings.EstateBans.Length);
Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
@@ -290,7 +290,7 @@ namespace OpenSim.Data.Tests
{
// Letting estate store generate rows to database for us
- EstateSettings originalSettings = db.LoadEstateSettings(regionId);
+ EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
SetEstateSettings(
originalSettings,
@@ -347,7 +347,7 @@ namespace OpenSim.Data.Tests
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
- EstateSettings loadedSettings = db.LoadEstateSettings(regionId);
+ EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
// Checking that loaded values are correct.
ValidateEstateSettings(
--
cgit v1.1