diff options
author | Melanie | 2012-11-09 22:58:42 +0000 |
---|---|---|
committer | Melanie | 2012-11-09 22:58:42 +0000 |
commit | 415b89f434657fe4cbf62a5c99f24c2648a313ac (patch) | |
tree | 48d7e97cc64a4351755942745a9a8f65d52b5322 /OpenSim/Data/MySQL | |
parent | Merge branch 'master' into careminster (diff) | |
parent | llSetLinkCamera implementation (diff) | |
download | opensim-SC-415b89f434657fe4cbf62a5c99f24c2648a313ac.zip opensim-SC-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.gz opensim-SC-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.bz2 opensim-SC-415b89f434657fe4cbf62a5c99f24c2648a313ac.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLXInventoryData.cs | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index cccc500..7a3b5b4 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs | |||
@@ -42,12 +42,12 @@ namespace OpenSim.Data.MySQL | |||
42 | /// </summary> | 42 | /// </summary> |
43 | public class MySQLXInventoryData : IXInventoryData | 43 | public class MySQLXInventoryData : IXInventoryData |
44 | { | 44 | { |
45 | private MySQLGenericTableHandler<XInventoryFolder> m_Folders; | 45 | private MySqlFolderHandler m_Folders; |
46 | private MySqlItemHandler m_Items; | 46 | private MySqlItemHandler m_Items; |
47 | 47 | ||
48 | public MySQLXInventoryData(string conn, string realm) | 48 | public MySQLXInventoryData(string conn, string realm) |
49 | { | 49 | { |
50 | m_Folders = new MySQLGenericTableHandler<XInventoryFolder>( | 50 | m_Folders = new MySqlFolderHandler( |
51 | conn, "inventoryfolders", "InventoryStore"); | 51 | conn, "inventoryfolders", "InventoryStore"); |
52 | m_Items = new MySqlItemHandler( | 52 | m_Items = new MySqlItemHandler( |
53 | conn, "inventoryitems", String.Empty); | 53 | conn, "inventoryitems", String.Empty); |
@@ -106,6 +106,11 @@ namespace OpenSim.Data.MySQL | |||
106 | return m_Items.MoveItem(id, newParent); | 106 | return m_Items.MoveItem(id, newParent); |
107 | } | 107 | } |
108 | 108 | ||
109 | public bool MoveFolder(string id, string newParent) | ||
110 | { | ||
111 | return m_Folders.MoveFolder(id, newParent); | ||
112 | } | ||
113 | |||
109 | public XInventoryItem[] GetActiveGestures(UUID principalID) | 114 | public XInventoryItem[] GetActiveGestures(UUID principalID) |
110 | { | 115 | { |
111 | return m_Items.GetActiveGestures(principalID); | 116 | return m_Items.GetActiveGestures(principalID); |
@@ -275,4 +280,89 @@ namespace OpenSim.Data.MySQL | |||
275 | return true; | 280 | return true; |
276 | } | 281 | } |
277 | } | 282 | } |
283 | |||
284 | public class MySqlFolderHandler : MySQLGenericTableHandler<XInventoryFolder> | ||
285 | { | ||
286 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
287 | |||
288 | public MySqlFolderHandler(string c, string t, string m) : | ||
289 | base(c, t, m) | ||
290 | { | ||
291 | } | ||
292 | |||
293 | public bool MoveFolder(string id, string newParentFolderID) | ||
294 | { | ||
295 | XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); | ||
296 | |||
297 | if (folders.Length == 0) | ||
298 | return false; | ||
299 | |||
300 | UUID oldParentFolderUUID = folders[0].parentFolderID; | ||
301 | |||
302 | using (MySqlCommand cmd = new MySqlCommand()) | ||
303 | { | ||
304 | cmd.CommandText | ||
305 | = String.Format( | ||
306 | "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm); | ||
307 | cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID); | ||
308 | cmd.Parameters.AddWithValue("?folderID", id); | ||
309 | |||
310 | if (ExecuteNonQuery(cmd) == 0) | ||
311 | return false; | ||
312 | } | ||
313 | |||
314 | IncrementFolderVersion(oldParentFolderUUID); | ||
315 | IncrementFolderVersion(newParentFolderID); | ||
316 | |||
317 | return true; | ||
318 | } | ||
319 | |||
320 | public override bool Store(XInventoryFolder folder) | ||
321 | { | ||
322 | if (!base.Store(folder)) | ||
323 | return false; | ||
324 | |||
325 | IncrementFolderVersion(folder.parentFolderID); | ||
326 | |||
327 | return true; | ||
328 | } | ||
329 | |||
330 | private bool IncrementFolderVersion(UUID folderID) | ||
331 | { | ||
332 | return IncrementFolderVersion(folderID.ToString()); | ||
333 | } | ||
334 | |||
335 | private bool IncrementFolderVersion(string folderID) | ||
336 | { | ||
337 | // m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); | ||
338 | // Util.PrintCallStack(); | ||
339 | |||
340 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
341 | { | ||
342 | dbcon.Open(); | ||
343 | |||
344 | using (MySqlCommand cmd = new MySqlCommand()) | ||
345 | { | ||
346 | cmd.Connection = dbcon; | ||
347 | |||
348 | cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); | ||
349 | cmd.Parameters.AddWithValue("?folderID", folderID); | ||
350 | |||
351 | try | ||
352 | { | ||
353 | cmd.ExecuteNonQuery(); | ||
354 | } | ||
355 | catch (Exception) | ||
356 | { | ||
357 | return false; | ||
358 | } | ||
359 | cmd.Dispose(); | ||
360 | } | ||
361 | |||
362 | dbcon.Close(); | ||
363 | } | ||
364 | |||
365 | return true; | ||
366 | } | ||
367 | } | ||
278 | } \ No newline at end of file | 368 | } \ No newline at end of file |