aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorlbsa712008-04-11 09:56:22 +0000
committerlbsa712008-04-11 09:56:22 +0000
commitcbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c (patch)
treef2172eccc3652e6f5bccc2be3cf71ec838801f47 /OpenSim/Data
parent* Added a "regionload_regionsdir" option to OpenSim.ini which determines wher... (diff)
downloadopensim-SC-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.zip
opensim-SC-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.gz
opensim-SC-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.bz2
opensim-SC-cbf9fcfac591bd8c8fcbccaa562c7a5fa05c4d9c.tar.xz
* Discerned between AddProfile and UpdateProfile in region registration
:: Believe it or not, but INSERT/UPDATE is actually a better pattern than REPLACE, since, with INSERT/UPDATE you can catch erroneous UPDATES to non-INSERTed items as well as catch erroneous re-INSERTS. in 95% of the cases, you SHOULD have a clear INSERT context, and a clear and separate UPDATE context. If you think your case falls within the 5%, maybe you should re-evaluate your code. ::
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/DB4o/DB4oGridData.cs5
-rw-r--r--OpenSim/Data/GridDataBase.cs1
-rw-r--r--OpenSim/Data/IGridData.cs2
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGridData.cs81
-rw-r--r--OpenSim/Data/MySQL/MySQLGridData.cs5
-rw-r--r--OpenSim/Data/SQLite/SQLiteGridData.cs5
6 files changed, 91 insertions, 8 deletions
diff --git a/OpenSim/Data/DB4o/DB4oGridData.cs b/OpenSim/Data/DB4o/DB4oGridData.cs
index 797fdd4..c388cb6 100644
--- a/OpenSim/Data/DB4o/DB4oGridData.cs
+++ b/OpenSim/Data/DB4o/DB4oGridData.cs
@@ -125,6 +125,11 @@ namespace OpenSim.Data.DB4o
125 } 125 }
126 } 126 }
127 127
128 override public DataResponse UpdateProfile(RegionProfileData profile)
129 {
130 return AddProfile(profile);
131 }
132
128 /// <summary> 133 /// <summary>
129 /// Authenticates a new region using the shared secrets. NOT SECURE. 134 /// Authenticates a new region using the shared secrets. NOT SECURE.
130 /// </summary> 135 /// </summary>
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs
index 004ec9b..5648c34 100644
--- a/OpenSim/Data/GridDataBase.cs
+++ b/OpenSim/Data/GridDataBase.cs
@@ -18,5 +18,6 @@ namespace OpenSim.Data
18 public abstract string getVersion(); 18 public abstract string getVersion();
19 public abstract DataResponse AddProfile(RegionProfileData profile); 19 public abstract DataResponse AddProfile(RegionProfileData profile);
20 public abstract ReservationData GetReservationAtPoint(uint x, uint y); 20 public abstract ReservationData GetReservationAtPoint(uint x, uint y);
21 public abstract DataResponse UpdateProfile(RegionProfileData profile);
21 } 22 }
22} 23}
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs
index feb372e..c924031 100644
--- a/OpenSim/Data/IGridData.cs
+++ b/OpenSim/Data/IGridData.cs
@@ -113,6 +113,8 @@ namespace OpenSim.Data
113 /// <returns>RESPONSE_OK if successful, error if not.</returns> 113 /// <returns>RESPONSE_OK if successful, error if not.</returns>
114 DataResponse AddProfile(RegionProfileData profile); 114 DataResponse AddProfile(RegionProfileData profile);
115 115
116 DataResponse UpdateProfile(RegionProfileData profile);
117
116 ReservationData GetReservationAtPoint(uint x, uint y); 118 ReservationData GetReservationAtPoint(uint x, uint y);
117 } 119 }
118} 120}
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs
index 03af53c..5617900 100644
--- a/OpenSim/Data/MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs
@@ -228,19 +228,19 @@ namespace OpenSim.Data.MSSQL
228 /// <returns>A dataresponse enum indicating success</returns> 228 /// <returns>A dataresponse enum indicating success</returns>
229 override public DataResponse AddProfile(RegionProfileData profile) 229 override public DataResponse AddProfile(RegionProfileData profile)
230 { 230 {
231 try 231 if (insertRegionRow(profile))
232 { 232 {
233 if (GetProfileByLLUUID(profile.UUID) != null) 233 return DataResponse.RESPONSE_OK;
234 {
235 return DataResponse.RESPONSE_OK;
236 }
237 } 234 }
238 catch (Exception) 235 else
239 { 236 {
240 System.Console.WriteLine("No regions found. Create new one."); 237 return DataResponse.RESPONSE_ERROR;
241 } 238 }
239 }
242 240
243 if (insertRegionRow(profile)) 241 public override DataResponse UpdateProfile(RegionProfileData profile)
242 {
243 if (updateRegionRow(profile))
244 { 244 {
245 return DataResponse.RESPONSE_OK; 245 return DataResponse.RESPONSE_OK;
246 } 246 }
@@ -250,6 +250,71 @@ namespace OpenSim.Data.MSSQL
250 } 250 }
251 } 251 }
252 252
253 public bool updateRegionRow(RegionProfileData profile)
254 {
255 //Insert new region
256 string sql =
257 "UPDATE " + m_regionsTableName + @" SET
258 [regionHandle]=@regionHandle, [regionName]=@regionName,
259 [regionRecvKey]=@regionRecvKey, [regionSecret]=@regionSecret, [regionSendKey]=@regionSendKey,
260 [regionDataURI]=@regionDataURI, [serverIP]=@serverIP, [serverPort]=@serverPort, [serverURI]=@serverURI,
261 [locX]=@locX, [locY]=@locY, [locZ]=@locZ, [eastOverrideHandle]=@eastOverrideHandle,
262 [westOverrideHandle]=@westOverrideHandle, [southOverrideHandle]=@southOverrideHandle,
263 [northOverrideHandle]=@northOverrideHandle, [regionAssetURI]=@regionAssetURI,
264 [regionAssetRecvKey]=@regionAssetRecvKey, [regionAssetSendKey]=@regionAssetSendKey,
265 [regionUserURI]=@regionUserURI, [regionUserRecvKey]=@regionUserRecvKey, [regionUserSendKey]=@regionUserSendKey,
266 [regionMapTexture]=@regionMapTexture, [serverHttpPort]=@serverHttpPort,
267 [serverRemotingPort]=@serverRemotingPort, [owner_uuid]=@owner_uuid
268 where [uuid]=@uuid";
269
270 Dictionary<string, string> parameters = new Dictionary<string, string>();
271
272 parameters["regionHandle"] = profile.regionHandle.ToString();
273 parameters["regionName"] = profile.regionName;
274 parameters["uuid"] = profile.UUID.ToString();
275 parameters["regionRecvKey"] = profile.regionRecvKey;
276 parameters["regionSecret"] = profile.regionSecret;
277 parameters["regionSendKey"] = profile.regionSendKey;
278 parameters["regionDataURI"] = profile.regionDataURI;
279 parameters["serverIP"] = profile.serverIP;
280 parameters["serverPort"] = profile.serverPort.ToString();
281 parameters["serverURI"] = profile.serverURI;
282 parameters["locX"] = profile.regionLocX.ToString();
283 parameters["locY"] = profile.regionLocY.ToString();
284 parameters["locZ"] = profile.regionLocZ.ToString();
285 parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString();
286 parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString();
287 parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString();
288 parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString();
289 parameters["regionAssetURI"] = profile.regionAssetURI;
290 parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey;
291 parameters["regionAssetSendKey"] = profile.regionAssetSendKey;
292 parameters["regionUserURI"] = profile.regionUserURI;
293 parameters["regionUserRecvKey"] = profile.regionUserRecvKey;
294 parameters["regionUserSendKey"] = profile.regionUserSendKey;
295 parameters["regionMapTexture"] = profile.regionMapTextureID.ToString();
296 parameters["serverHttpPort"] = profile.httpPort.ToString();
297 parameters["serverRemotingPort"] = profile.remotingPort.ToString();
298 parameters["owner_uuid"] = profile.owner_uuid.ToString();
299
300 bool returnval = false;
301
302 try
303 {
304 IDbCommand result = database.Query(sql, parameters);
305
306 if (result.ExecuteNonQuery() == 1)
307 returnval = true;
308
309 result.Dispose();
310 }
311 catch (Exception e)
312 {
313 m_log.Error("MSSQLManager : " + e.ToString());
314 }
315
316 return returnval;
317 }
253 /// <summary> 318 /// <summary>
254 /// Creates a new region in the database 319 /// Creates a new region in the database
255 /// </summary> 320 /// </summary>
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs
index 610dfaf..639f899 100644
--- a/OpenSim/Data/MySQL/MySQLGridData.cs
+++ b/OpenSim/Data/MySQL/MySQLGridData.cs
@@ -309,6 +309,11 @@ namespace OpenSim.Data.MySQL
309 } 309 }
310 } 310 }
311 311
312 override public DataResponse UpdateProfile(RegionProfileData profile)
313 {
314 return AddProfile(profile);
315 }
316
312 /// <summary> 317 /// <summary>
313 /// Deletes a profile from the database 318 /// Deletes a profile from the database
314 /// </summary> 319 /// </summary>
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs
index c52eb29..f07b98f 100644
--- a/OpenSim/Data/SQLite/SQLiteGridData.cs
+++ b/OpenSim/Data/SQLite/SQLiteGridData.cs
@@ -188,6 +188,11 @@ namespace OpenSim.Data.SQLite
188 } 188 }
189 } 189 }
190 190
191 override public DataResponse UpdateProfile(RegionProfileData profile)
192 {
193 return AddProfile(profile);
194 }
195
191 /// <summary> 196 /// <summary>
192 /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret. 197 /// DEPRECATED. Attempts to authenticate a region by comparing a shared secret.
193 /// </summary> 198 /// </summary>