aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs116
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs10
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs139
3 files changed, 244 insertions, 21 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 1bc6e3c..eb636cf 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -131,6 +131,12 @@ namespace OpenSim.Data.MSSQL
131 131
132 public bool MoveItem(string id, string newParent) 132 public bool MoveItem(string id, string newParent)
133 { 133 {
134 XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
135 if (retrievedItems.Length == 0)
136 return false;
137
138 UUID oldParent = retrievedItems[0].parentFolderID;
139
134 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 140 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
135 { 141 {
136 using (SqlCommand cmd = new SqlCommand()) 142 using (SqlCommand cmd = new SqlCommand())
@@ -141,9 +147,16 @@ namespace OpenSim.Data.MSSQL
141 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); 147 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
142 cmd.Connection = conn; 148 cmd.Connection = conn;
143 conn.Open(); 149 conn.Open();
144 return cmd.ExecuteNonQuery() == 0 ? false : true; 150
151 if (cmd.ExecuteNonQuery() == 0)
152 return false;
145 } 153 }
146 } 154 }
155
156 IncrementFolderVersion(oldParent);
157 IncrementFolderVersion(newParent);
158
159 return true;
147 } 160 }
148 161
149 public XInventoryItem[] GetActiveGestures(UUID principalID) 162 public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -196,26 +209,43 @@ namespace OpenSim.Data.MSSQL
196 if (!base.Store(item)) 209 if (!base.Store(item))
197 return false; 210 return false;
198 211
199 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; 212 IncrementFolderVersion(item.parentFolderID);
213
214 return true;
215 }
216
217 private bool IncrementFolderVersion(UUID folderID)
218 {
219 return IncrementFolderVersion(folderID.ToString());
220 }
221
222 private bool IncrementFolderVersion(string folderID)
223 {
224// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
225// Util.PrintCallStack();
226
227 string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
228
200 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 229 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
201 { 230 {
202 using (SqlCommand cmd = new SqlCommand(sql, conn)) 231 using (SqlCommand cmd = new SqlCommand(sql, conn))
203 { 232 {
204 conn.Open(); 233 conn.Open();
205 234
206 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString()); 235 cmd.Parameters.AddWithValue("@folderID", folderID);
207 try
208 {
209 cmd.ExecuteNonQuery();
210 }
211 catch (Exception)
212 {
213 return false;
214 }
215 }
216 236
217 return true; 237 try
238 {
239 cmd.ExecuteNonQuery();
240 }
241 catch (Exception)
242 {
243 return false;
244 }
245 }
218 } 246 }
247
248 return true;
219 } 249 }
220 } 250 }
221 251
@@ -228,6 +258,13 @@ namespace OpenSim.Data.MSSQL
228 258
229 public bool MoveFolder(string id, string newParentFolderID) 259 public bool MoveFolder(string id, string newParentFolderID)
230 { 260 {
261 XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
262
263 if (folders.Length == 0)
264 return false;
265
266 UUID oldParentFolderUUID = folders[0].parentFolderID;
267
231 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 268 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
232 { 269 {
233 using (SqlCommand cmd = new SqlCommand()) 270 using (SqlCommand cmd = new SqlCommand())
@@ -238,9 +275,60 @@ namespace OpenSim.Data.MSSQL
238 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id)); 275 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
239 cmd.Connection = conn; 276 cmd.Connection = conn;
240 conn.Open(); 277 conn.Open();
241 return cmd.ExecuteNonQuery() == 0 ? false : true; 278
279 if (cmd.ExecuteNonQuery() == 0)
280 return false;
242 } 281 }
243 } 282 }
283
284 IncrementFolderVersion(oldParentFolderUUID);
285 IncrementFolderVersion(newParentFolderID);
286
287 return true;
288 }
289
290 public override bool Store(XInventoryFolder folder)
291 {
292 if (!base.Store(folder))
293 return false;
294
295 IncrementFolderVersion(folder.parentFolderID);
296
297 return true;
298 }
299
300 private bool IncrementFolderVersion(UUID folderID)
301 {
302 return IncrementFolderVersion(folderID.ToString());
303 }
304
305 private bool IncrementFolderVersion(string folderID)
306 {
307// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
308// Util.PrintCallStack();
309
310 string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
311
312 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
313 {
314 using (SqlCommand cmd = new SqlCommand(sql, conn))
315 {
316 conn.Open();
317
318 cmd.Parameters.AddWithValue("@folderID", folderID);
319
320 try
321 {
322 cmd.ExecuteNonQuery();
323 }
324 catch (Exception)
325 {
326 return false;
327 }
328 }
329 }
330
331 return true;
244 } 332 }
245 } 333 }
246} \ No newline at end of file 334} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 917a0a1..9fbeb10 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -120,12 +120,12 @@ namespace OpenSim.Data.SQLite
120 } 120 }
121 } 121 }
122 122
123 public T[] Get(string field, string key) 123 public virtual T[] Get(string field, string key)
124 { 124 {
125 return Get(new string[] { field }, new string[] { key }); 125 return Get(new string[] { field }, new string[] { key });
126 } 126 }
127 127
128 public T[] Get(string[] fields, string[] keys) 128 public virtual T[] Get(string[] fields, string[] keys)
129 { 129 {
130 if (fields.Length != keys.Length) 130 if (fields.Length != keys.Length)
131 return new T[0]; 131 return new T[0];
@@ -213,7 +213,7 @@ namespace OpenSim.Data.SQLite
213 return result.ToArray(); 213 return result.ToArray();
214 } 214 }
215 215
216 public T[] Get(string where) 216 public virtual T[] Get(string where)
217 { 217 {
218 using (SqliteCommand cmd = new SqliteCommand()) 218 using (SqliteCommand cmd = new SqliteCommand())
219 { 219 {
@@ -226,7 +226,7 @@ namespace OpenSim.Data.SQLite
226 } 226 }
227 } 227 }
228 228
229 public bool Store(T row) 229 public virtual bool Store(T row)
230 { 230 {
231 using (SqliteCommand cmd = new SqliteCommand()) 231 using (SqliteCommand cmd = new SqliteCommand())
232 { 232 {
@@ -270,7 +270,7 @@ namespace OpenSim.Data.SQLite
270 return Delete(new string[] { field }, new string[] { key }); 270 return Delete(new string[] { field }, new string[] { key });
271 } 271 }
272 272
273 public bool Delete(string[] fields, string[] keys) 273 public virtual bool Delete(string[] fields, string[] keys)
274 { 274 {
275 if (fields.Length != keys.Length) 275 if (fields.Length != keys.Length)
276 return false; 276 return false;
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 8eb1a63..87eb31e 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -137,16 +137,72 @@ namespace OpenSim.Data.SQLite
137 { 137 {
138 } 138 }
139 139
140 public override bool Store(XInventoryItem item)
141 {
142 if (!base.Store(item))
143 return false;
144
145 IncrementFolderVersion(item.parentFolderID);
146
147 return true;
148 }
149
150 public override bool Delete(string field, string val)
151 {
152 XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
153 if (retrievedItems.Length == 0)
154 return false;
155
156 if (!base.Delete(field, val))
157 return false;
158
159 // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
160// IncrementFolderVersion(retrievedItems[0].parentFolderID);
161
162 return true;
163 }
164
165 public override bool Delete(string[] fields, string[] vals)
166 {
167 XInventoryItem[] retrievedItems = Get(fields, vals);
168 if (retrievedItems.Length == 0)
169 return false;
170
171 if (!base.Delete(fields, vals))
172 return false;
173
174 HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>();
175
176 Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
177
178 foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
179 IncrementFolderVersion(deletedItemFolderUUID);
180
181 return true;
182 }
183
140 public bool MoveItem(string id, string newParent) 184 public bool MoveItem(string id, string newParent)
141 { 185 {
186 XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
187 if (retrievedItems.Length == 0)
188 return false;
189
190 UUID oldParent = retrievedItems[0].parentFolderID;
191
142 using (SqliteCommand cmd = new SqliteCommand()) 192 using (SqliteCommand cmd = new SqliteCommand())
143 { 193 {
144 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); 194 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
145 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); 195 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
146 cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); 196 cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
147 197
148 return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; 198 if (ExecuteNonQuery(cmd, m_Connection) == 0)
199 return false;
149 } 200 }
201
202 IncrementFolderVersion(oldParent);
203 IncrementFolderVersion(newParent);
204
205 return true;
150 } 206 }
151 207
152 public XInventoryItem[] GetActiveGestures(UUID principalID) 208 public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -187,6 +243,34 @@ namespace OpenSim.Data.SQLite
187 243
188 return perms; 244 return perms;
189 } 245 }
246
247 private bool IncrementFolderVersion(UUID folderID)
248 {
249 return IncrementFolderVersion(folderID.ToString());
250 }
251
252 private bool IncrementFolderVersion(string folderID)
253 {
254// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
255// Util.PrintCallStack();
256
257 using (SqliteCommand cmd = new SqliteCommand())
258 {
259 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
260 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
261
262 try
263 {
264 cmd.ExecuteNonQuery();
265 }
266 catch (Exception)
267 {
268 return false;
269 }
270 }
271
272 return true;
273 }
190 } 274 }
191 275
192 public class SqliteFolderHandler : SQLiteGenericTableHandler<XInventoryFolder> 276 public class SqliteFolderHandler : SQLiteGenericTableHandler<XInventoryFolder>
@@ -196,16 +280,67 @@ namespace OpenSim.Data.SQLite
196 { 280 {
197 } 281 }
198 282
283 public override bool Store(XInventoryFolder folder)
284 {
285 if (!base.Store(folder))
286 return false;
287
288 IncrementFolderVersion(folder.parentFolderID);
289
290 return true;
291 }
292
199 public bool MoveFolder(string id, string newParentFolderID) 293 public bool MoveFolder(string id, string newParentFolderID)
200 { 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
201 using (SqliteCommand cmd = new SqliteCommand()) 302 using (SqliteCommand cmd = new SqliteCommand())
202 { 303 {
203 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm); 304 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm);
204 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID)); 305 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID));
205 cmd.Parameters.Add(new SqliteParameter(":FolderID", id)); 306 cmd.Parameters.Add(new SqliteParameter(":FolderID", id));
206 307
207 return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; 308 if (ExecuteNonQuery(cmd, m_Connection) == 0)
309 return false;
208 } 310 }
311
312 IncrementFolderVersion(oldParentFolderUUID);
313 IncrementFolderVersion(newParentFolderID);
314
315 return true;
316 }
317
318 private bool IncrementFolderVersion(UUID folderID)
319 {
320 return IncrementFolderVersion(folderID.ToString());
321 }
322
323 private bool IncrementFolderVersion(string folderID)
324 {
325// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
326// Util.PrintCallStack();
327
328 using (SqliteCommand cmd = new SqliteCommand())
329 {
330 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
331 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
332
333 try
334 {
335 cmd.ExecuteNonQuery();
336 }
337 catch (Exception)
338 {
339 return false;
340 }
341 }
342
343 return true;
209 } 344 }
210 } 345 }
211} \ No newline at end of file 346} \ No newline at end of file