aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorMelanie2010-03-22 18:49:56 +0000
committerMelanie2010-03-22 18:49:56 +0000
commit70b0e07d1ea99f8bd88f2be12bf9b53a39187f60 (patch)
tree0093de7003392ff5edd246e82fa3fcb2b216cff1 /OpenSim/Data
parentFix a nullref in permissions when returning objects via right-click (diff)
downloadopensim-SC_OLD-70b0e07d1ea99f8bd88f2be12bf9b53a39187f60.zip
opensim-SC_OLD-70b0e07d1ea99f8bd88f2be12bf9b53a39187f60.tar.gz
opensim-SC_OLD-70b0e07d1ea99f8bd88f2be12bf9b53a39187f60.tar.bz2
opensim-SC_OLD-70b0e07d1ea99f8bd88f2be12bf9b53a39187f60.tar.xz
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
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLEstateData.cs23
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs18
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs20
-rw-r--r--OpenSim/Data/Tests/BasicEstateTest.cs24
4 files changed, 21 insertions, 64 deletions
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
83 /// </summary> 83 /// </summary>
84 /// <param name="regionID">region ID.</param> 84 /// <param name="regionID">region ID.</param>
85 /// <returns></returns> 85 /// <returns></returns>
86 public EstateSettings LoadEstateSettings(UUID regionID) 86 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
87 { 87 {
88 EstateSettings es = new EstateSettings(); 88 EstateSettings es = new EstateSettings();
89 89
@@ -127,7 +127,7 @@ namespace OpenSim.Data.MSSQL
127 } 127 }
128 128
129 129
130 if (insertEstate) 130 if (insertEstate && create)
131 { 131 {
132 List<string> names = new List<string>(FieldList); 132 List<string> names = new List<string>(FieldList);
133 133
@@ -173,25 +173,6 @@ namespace OpenSim.Data.MSSQL
173 } 173 }
174 } 174 }
175 175
176 // Munge and transfer the ban list
177
178 sql = string.Format("insert into estateban select {0}, bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID", es.EstateID);
179 using (SqlConnection conn = new SqlConnection(m_connectionString))
180 using (SqlCommand cmd = new SqlCommand(sql, conn))
181 {
182
183 cmd.Parameters.Add(_Database.CreateParameter("@UUID", regionID));
184 try
185 {
186 conn.Open();
187 cmd.ExecuteNonQuery();
188 }
189 catch (Exception)
190 {
191 _Log.Debug("[ESTATE DB]: Error setting up estateban from regionban");
192 }
193 }
194
195 //TODO check if this is needed?? 176 //TODO check if this is needed??
196 es.Save(); 177 es.Save();
197 } 178 }
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
121 } 121 }
122 } 122 }
123 123
124 public EstateSettings LoadEstateSettings(UUID regionID) 124 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
125 { 125 {
126 EstateSettings es = new EstateSettings(); 126 EstateSettings es = new EstateSettings();
127 es.OnSave += StoreEstateSettings; 127 es.OnSave += StoreEstateSettings;
@@ -129,12 +129,12 @@ namespace OpenSim.Data.MySQL
129 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + 129 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) +
130 " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; 130 " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID";
131 131
132 bool migration = true;
133
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 132 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
135 { 133 {
136 dbcon.Open(); 134 dbcon.Open();
137 135
136 bool found = false;
137
138 using (MySqlCommand cmd = dbcon.CreateCommand()) 138 using (MySqlCommand cmd = dbcon.CreateCommand())
139 { 139 {
140 cmd.CommandText = sql; 140 cmd.CommandText = sql;
@@ -144,7 +144,7 @@ namespace OpenSim.Data.MySQL
144 { 144 {
145 if (r.Read()) 145 if (r.Read())
146 { 146 {
147 migration = false; 147 found = true;
148 148
149 foreach (string name in FieldList) 149 foreach (string name in FieldList)
150 { 150 {
@@ -172,7 +172,7 @@ namespace OpenSim.Data.MySQL
172 } 172 }
173 } 173 }
174 174
175 if (migration) 175 if (!found && create)
176 { 176 {
177 // Migration case 177 // Migration case
178 List<string> names = new List<string>(FieldList); 178 List<string> names = new List<string>(FieldList);
@@ -220,14 +220,6 @@ namespace OpenSim.Data.MySQL
220 try { cmd.ExecuteNonQuery(); } 220 try { cmd.ExecuteNonQuery(); }
221 catch (Exception) { } 221 catch (Exception) { }
222 222
223 // Munge and transfer the ban list
224 cmd.Parameters.Clear();
225 cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
226 cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
227
228 try { cmd.ExecuteNonQuery(); }
229 catch (Exception) { }
230
231 es.Save(); 223 es.Save();
232 } 224 }
233 } 225 }
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
80 get { return new List<string>(m_FieldMap.Keys).ToArray(); } 80 get { return new List<string>(m_FieldMap.Keys).ToArray(); }
81 } 81 }
82 82
83 public EstateSettings LoadEstateSettings(UUID regionID) 83 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
84 { 84 {
85 EstateSettings es = new EstateSettings(); 85 EstateSettings es = new EstateSettings();
86 es.OnSave += StoreEstateSettings; 86 es.OnSave += StoreEstateSettings;
@@ -120,10 +120,8 @@ namespace OpenSim.Data.SQLite
120 } 120 }
121 r.Close(); 121 r.Close();
122 } 122 }
123 else 123 else if (create)
124 { 124 {
125 // Migration case
126 //
127 r.Close(); 125 r.Close();
128 126
129 List<string> names = new List<string>(FieldList); 127 List<string> names = new List<string>(FieldList);
@@ -176,20 +174,6 @@ namespace OpenSim.Data.SQLite
176 { 174 {
177 } 175 }
178 176
179 // Munge and transfer the ban list
180 //
181 cmd.Parameters.Clear();
182 cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
183 cmd.Parameters.Add(":UUID", regionID.ToString());
184
185 try
186 {
187 cmd.ExecuteNonQuery();
188 }
189 catch (Exception)
190 {
191 }
192
193 es.Save(); 177 es.Save();
194 } 178 }
195 179
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
158 public void T012_EstateSettingsRandomStorage() 158 public void T012_EstateSettingsRandomStorage()
159 { 159 {
160 // Letting estate store generate rows to database for us 160 // Letting estate store generate rows to database for us
161 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 161 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
162 new PropertyScrambler<EstateSettings>() 162 new PropertyScrambler<EstateSettings>()
163 .DontScramble(x=>x.EstateID) 163 .DontScramble(x=>x.EstateID)
164 .Scramble(originalSettings); 164 .Scramble(originalSettings);
@@ -167,7 +167,7 @@ namespace OpenSim.Data.Tests
167 db.StoreEstateSettings(originalSettings); 167 db.StoreEstateSettings(originalSettings);
168 168
169 // Loading settings to another instance variable. 169 // Loading settings to another instance variable.
170 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); 170 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
171 171
172 // Checking that loaded values are correct. 172 // Checking that loaded values are correct.
173 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings)); 173 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
@@ -177,7 +177,7 @@ namespace OpenSim.Data.Tests
177 public void T020_EstateSettingsManagerList() 177 public void T020_EstateSettingsManagerList()
178 { 178 {
179 // Letting estate store generate rows to database for us 179 // Letting estate store generate rows to database for us
180 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 180 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
181 181
182 originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 }; 182 originalSettings.EstateManagers = new UUID[] { MANAGER_ID_1, MANAGER_ID_2 };
183 183
@@ -185,7 +185,7 @@ namespace OpenSim.Data.Tests
185 db.StoreEstateSettings(originalSettings); 185 db.StoreEstateSettings(originalSettings);
186 186
187 // Loading settings to another instance variable. 187 // Loading settings to another instance variable.
188 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); 188 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
189 189
190 Assert.AreEqual(2, loadedSettings.EstateManagers.Length); 190 Assert.AreEqual(2, loadedSettings.EstateManagers.Length);
191 Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]); 191 Assert.AreEqual(MANAGER_ID_1, loadedSettings.EstateManagers[0]);
@@ -196,7 +196,7 @@ namespace OpenSim.Data.Tests
196 public void T021_EstateSettingsUserList() 196 public void T021_EstateSettingsUserList()
197 { 197 {
198 // Letting estate store generate rows to database for us 198 // Letting estate store generate rows to database for us
199 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 199 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
200 200
201 originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 }; 201 originalSettings.EstateAccess = new UUID[] { USER_ID_1, USER_ID_2 };
202 202
@@ -204,7 +204,7 @@ namespace OpenSim.Data.Tests
204 db.StoreEstateSettings(originalSettings); 204 db.StoreEstateSettings(originalSettings);
205 205
206 // Loading settings to another instance variable. 206 // Loading settings to another instance variable.
207 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); 207 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
208 208
209 Assert.AreEqual(2, loadedSettings.EstateAccess.Length); 209 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
210 Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]); 210 Assert.AreEqual(USER_ID_1, loadedSettings.EstateAccess[0]);
@@ -215,7 +215,7 @@ namespace OpenSim.Data.Tests
215 public void T022_EstateSettingsGroupList() 215 public void T022_EstateSettingsGroupList()
216 { 216 {
217 // Letting estate store generate rows to database for us 217 // Letting estate store generate rows to database for us
218 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 218 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
219 219
220 originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 }; 220 originalSettings.EstateGroups = new UUID[] { GROUP_ID_1, GROUP_ID_2 };
221 221
@@ -223,7 +223,7 @@ namespace OpenSim.Data.Tests
223 db.StoreEstateSettings(originalSettings); 223 db.StoreEstateSettings(originalSettings);
224 224
225 // Loading settings to another instance variable. 225 // Loading settings to another instance variable.
226 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); 226 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
227 227
228 Assert.AreEqual(2, loadedSettings.EstateAccess.Length); 228 Assert.AreEqual(2, loadedSettings.EstateAccess.Length);
229 Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]); 229 Assert.AreEqual(GROUP_ID_1, loadedSettings.EstateGroups[0]);
@@ -234,7 +234,7 @@ namespace OpenSim.Data.Tests
234 public void T022_EstateSettingsBanList() 234 public void T022_EstateSettingsBanList()
235 { 235 {
236 // Letting estate store generate rows to database for us 236 // Letting estate store generate rows to database for us
237 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); 237 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);
238 238
239 EstateBan estateBan1 = new EstateBan(); 239 EstateBan estateBan1 = new EstateBan();
240 estateBan1.BannedUserID = DataTestUtil.UUID_MIN; 240 estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
@@ -248,7 +248,7 @@ namespace OpenSim.Data.Tests
248 db.StoreEstateSettings(originalSettings); 248 db.StoreEstateSettings(originalSettings);
249 249
250 // Loading settings to another instance variable. 250 // Loading settings to another instance variable.
251 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID); 251 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);
252 252
253 Assert.AreEqual(2, loadedSettings.EstateBans.Length); 253 Assert.AreEqual(2, loadedSettings.EstateBans.Length);
254 Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID); 254 Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
@@ -290,7 +290,7 @@ namespace OpenSim.Data.Tests
290 { 290 {
291 291
292 // Letting estate store generate rows to database for us 292 // Letting estate store generate rows to database for us
293 EstateSettings originalSettings = db.LoadEstateSettings(regionId); 293 EstateSettings originalSettings = db.LoadEstateSettings(regionId, true);
294 294
295 SetEstateSettings( 295 SetEstateSettings(
296 originalSettings, 296 originalSettings,
@@ -347,7 +347,7 @@ namespace OpenSim.Data.Tests
347 db.StoreEstateSettings(originalSettings); 347 db.StoreEstateSettings(originalSettings);
348 348
349 // Loading settings to another instance variable. 349 // Loading settings to another instance variable.
350 EstateSettings loadedSettings = db.LoadEstateSettings(regionId); 350 EstateSettings loadedSettings = db.LoadEstateSettings(regionId, true);
351 351
352 // Checking that loaded values are correct. 352 // Checking that loaded values are correct.
353 ValidateEstateSettings( 353 ValidateEstateSettings(