aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/IXGroupData.cs71
-rw-r--r--OpenSim/Data/IXInventoryData.cs17
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs175
-rw-r--r--OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs138
-rw-r--r--OpenSim/Data/MySQL/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/Null/NullGenericDataHandler.cs67
-rw-r--r--OpenSim/Data/Null/NullXGroupData.cs (renamed from OpenSim/Services/InventoryService/InventoryServiceBase.cs)78
-rw-r--r--OpenSim/Data/Null/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/SQLite/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs14
-rw-r--r--OpenSim/Data/SQLite/SQLiteAuthenticationData.cs145
-rw-r--r--OpenSim/Data/SQLite/SQLiteAvatarData.cs22
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs206
-rw-r--r--OpenSim/Data/SQLite/SQLiteFramework.cs9
-rw-r--r--OpenSim/Data/SQLite/SQLiteFriendsData.cs25
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs116
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs25
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserAccountData.cs25
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs182
-rw-r--r--OpenSim/Data/Tests/AssetTests.cs2
-rw-r--r--OpenSim/Data/Tests/BasicDataServiceTest.cs3
-rw-r--r--OpenSim/Data/Tests/PropertyCompareConstraint.cs3
-rw-r--r--OpenSim/Data/Tests/PropertyScrambler.cs3
26 files changed, 948 insertions, 394 deletions
diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs
new file mode 100644
index 0000000..2965e8c
--- /dev/null
+++ b/OpenSim/Data/IXGroupData.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
35 public class XGroup
36 {
37 public UUID groupID;
38 public UUID ownerRoleID;
39 public string name;
40 public string charter;
41 public bool showInList;
42 public UUID insigniaID;
43 public int membershipFee;
44 public bool openEnrollment;
45 public bool allowPublish;
46 public bool maturePublish;
47 public UUID founderID;
48 public ulong everyonePowers;
49 public ulong ownersPowers;
50
51 public XGroup Clone()
52 {
53 return (XGroup)MemberwiseClone();
54 }
55 }
56
57 /// <summary>
58 /// Early stub interface for groups data, not final.
59 /// </summary>
60 /// <remarks>
61 /// Currently in-use only for regression test purposes. Needs to be filled out over time.
62 /// </remarks>
63 public interface IXGroupData
64 {
65 bool StoreGroup(XGroup group);
66 XGroup[] GetGroups(string field, string val);
67 XGroup[] GetGroups(string[] fields, string[] vals);
68 bool DeleteGroups(string field, string val);
69 bool DeleteGroups(string[] fields, string[] vals);
70 }
71} \ No newline at end of file
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index e64a828..ca47506 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -116,7 +116,22 @@ namespace OpenSim.Data
116 /// <returns>true if the delete was successful, false if it was not</returns> 116 /// <returns>true if the delete was successful, false if it was not</returns>
117 bool DeleteItems(string[] fields, string[] vals); 117 bool DeleteItems(string[] fields, string[] vals);
118 118
119 bool MoveItem(string id, string newParent); 119 /// <summary>
120 /// Move an item to another folder.
121 /// </summary>
122 /// <returns>/returns>
123 /// <param name='id'>UUID of the item</param>
124 /// <param name='newParent'>UUID of the new parent folder.</param>
125 bool MoveItem(string id, string newParentFolderID);
126
127 /// <summary>
128 /// Move a folder to another folder.
129 /// </summary>
130 /// <returns>/returns>
131 /// <param name='id'>UUID of the item</param>
132 /// <param name='newParent'>UUID of the new parent folder.</param>
133 bool MoveFolder(string id, string newParentFolderID);
134
120 XInventoryItem[] GetActiveGestures(UUID principalID); 135 XInventoryItem[] GetActiveGestures(UUID principalID);
121 int GetAssetPermissions(UUID principalID, UUID assetID); 136 int GetAssetPermissions(UUID principalID, UUID assetID);
122 } 137 }
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index b19a0da..9164ffe 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -43,12 +43,12 @@ namespace OpenSim.Data.MSSQL
43// private static readonly ILog m_log = LogManager.GetLogger( 43// private static readonly ILog m_log = LogManager.GetLogger(
44// MethodBase.GetCurrentMethod().DeclaringType); 44// MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private MSSQLGenericTableHandler<XInventoryFolder> m_Folders; 46 private MSSQLFolderHandler m_Folders;
47 private MSSQLItemHandler m_Items; 47 private MSSQLItemHandler m_Items;
48 48
49 public MSSQLXInventoryData(string conn, string realm) 49 public MSSQLXInventoryData(string conn, string realm)
50 { 50 {
51 m_Folders = new MSSQLGenericTableHandler<XInventoryFolder>( 51 m_Folders = new MSSQLFolderHandler(
52 conn, "inventoryfolders", "InventoryStore"); 52 conn, "inventoryfolders", "InventoryStore");
53 m_Items = new MSSQLItemHandler( 53 m_Items = new MSSQLItemHandler(
54 conn, "inventoryitems", String.Empty); 54 conn, "inventoryitems", String.Empty);
@@ -85,6 +85,7 @@ namespace OpenSim.Data.MSSQL
85 { 85 {
86 return m_Folders.Delete(field, val); 86 return m_Folders.Delete(field, val);
87 } 87 }
88
88 public bool DeleteFolders(string[] fields, string[] vals) 89 public bool DeleteFolders(string[] fields, string[] vals)
89 { 90 {
90 return m_Folders.Delete(fields, vals); 91 return m_Folders.Delete(fields, vals);
@@ -94,15 +95,22 @@ namespace OpenSim.Data.MSSQL
94 { 95 {
95 return m_Items.Delete(field, val); 96 return m_Items.Delete(field, val);
96 } 97 }
98
97 public bool DeleteItems(string[] fields, string[] vals) 99 public bool DeleteItems(string[] fields, string[] vals)
98 { 100 {
99 return m_Items.Delete(fields, vals); 101 return m_Items.Delete(fields, vals);
100 } 102 }
103
101 public bool MoveItem(string id, string newParent) 104 public bool MoveItem(string id, string newParent)
102 { 105 {
103 return m_Items.MoveItem(id, newParent); 106 return m_Items.MoveItem(id, newParent);
104 } 107 }
105 108
109 public bool MoveFolder(string id, string newParent)
110 {
111 return m_Folders.MoveFolder(id, newParent);
112 }
113
106 public XInventoryItem[] GetActiveGestures(UUID principalID) 114 public XInventoryItem[] GetActiveGestures(UUID principalID)
107 { 115 {
108 return m_Items.GetActiveGestures(principalID); 116 return m_Items.GetActiveGestures(principalID);
@@ -114,7 +122,7 @@ namespace OpenSim.Data.MSSQL
114 } 122 }
115 } 123 }
116 124
117 public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem> 125 public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem>
118 { 126 {
119 public MSSQLItemHandler(string c, string t, string m) : 127 public MSSQLItemHandler(string c, string t, string m) :
120 base(c, t, m) 128 base(c, t, m)
@@ -123,70 +131,163 @@ namespace OpenSim.Data.MSSQL
123 131
124 public bool MoveItem(string id, string newParent) 132 public bool MoveItem(string id, string newParent)
125 { 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
126 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 140 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
127 using (SqlCommand cmd = new SqlCommand())
128 { 141 {
142 using (SqlCommand cmd = new SqlCommand())
143 {
144
145 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm);
146 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent));
147 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id));
148 cmd.Connection = conn;
149 conn.Open();
129 150
130 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); 151 if (cmd.ExecuteNonQuery() == 0)
131 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); 152 return false;
132 cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); 153 }
133 cmd.Connection = conn;
134 conn.Open();
135 return cmd.ExecuteNonQuery() == 0 ? false : true;
136 } 154 }
155
156 IncrementFolderVersion(oldParent);
157 IncrementFolderVersion(newParent);
158
159 return true;
137 } 160 }
138 161
139 public XInventoryItem[] GetActiveGestures(UUID principalID) 162 public XInventoryItem[] GetActiveGestures(UUID principalID)
140 { 163 {
141 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 164 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
142 using (SqlCommand cmd = new SqlCommand())
143 { 165 {
144 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); 166 using (SqlCommand cmd = new SqlCommand())
167 {
168 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm);
145 169
146 cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); 170 cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString()));
147 cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); 171 cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture));
148 cmd.Connection = conn; 172 cmd.Connection = conn;
149 conn.Open(); 173 conn.Open();
150 return DoQuery(cmd); 174 return DoQuery(cmd);
175 }
151 } 176 }
152 } 177 }
153 178
154 public int GetAssetPermissions(UUID principalID, UUID assetID) 179 public int GetAssetPermissions(UUID principalID, UUID assetID)
155 { 180 {
156 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 181 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
157 using (SqlCommand cmd = new SqlCommand())
158 { 182 {
159 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); 183 using (SqlCommand cmd = new SqlCommand())
160 cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
161 cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
162 cmd.Connection = conn;
163 conn.Open();
164 using (SqlDataReader reader = cmd.ExecuteReader())
165 { 184 {
185 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm);
186 cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString()));
187 cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString()));
188 cmd.Connection = conn;
189 conn.Open();
190 using (SqlDataReader reader = cmd.ExecuteReader())
191 {
166 192
167 int perms = 0; 193 int perms = 0;
168 194
169 if (reader.Read()) 195 if (reader.Read())
170 { 196 {
171 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); 197 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
198 }
199
200 return perms;
172 } 201 }
173 202
174 return perms;
175 } 203 }
176
177 } 204 }
178 } 205 }
206
179 public override bool Store(XInventoryItem item) 207 public override bool Store(XInventoryItem item)
180 { 208 {
181 if (!base.Store(item)) 209 if (!base.Store(item))
182 return false; 210 return false;
183 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; 211
212 IncrementFolderVersion(item.parentFolderID);
213
214 return true;
215 }
216 }
217
218 public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder>
219 {
220 public MSSQLFolderHandler(string c, string t, string m) :
221 base(c, t, m)
222 {
223 }
224
225 public bool MoveFolder(string id, string newParentFolderID)
226 {
227 XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
228
229 if (folders.Length == 0)
230 return false;
231
232 UUID oldParentFolderUUID = folders[0].parentFolderID;
233
234 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
235 {
236 using (SqlCommand cmd = new SqlCommand())
237 {
238
239 cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm);
240 cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID));
241 cmd.Parameters.Add(m_database.CreateParameter("@folderID", id));
242 cmd.Connection = conn;
243 conn.Open();
244
245 if (cmd.ExecuteNonQuery() == 0)
246 return false;
247 }
248 }
249
250 IncrementFolderVersion(oldParentFolderUUID);
251 IncrementFolderVersion(newParentFolderID);
252
253 return true;
254 }
255
256 public override bool Store(XInventoryFolder folder)
257 {
258 if (!base.Store(folder))
259 return false;
260
261 IncrementFolderVersion(folder.parentFolderID);
262
263 return true;
264 }
265 }
266
267 public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new()
268 {
269 public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
270
271 protected bool IncrementFolderVersion(UUID folderID)
272 {
273 return IncrementFolderVersion(folderID.ToString());
274 }
275
276 protected bool IncrementFolderVersion(string folderID)
277 {
278// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
279// Util.PrintCallStack();
280
281 string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
282
184 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 283 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
185 using (SqlCommand cmd = new SqlCommand(sql, conn))
186 { 284 {
187 conn.Open(); 285 using (SqlCommand cmd = new SqlCommand(sql, conn))
286 {
287 conn.Open();
288
289 cmd.Parameters.AddWithValue("@folderID", folderID);
188 290
189 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
190 try 291 try
191 { 292 {
192 cmd.ExecuteNonQuery(); 293 cmd.ExecuteNonQuery();
@@ -194,9 +295,11 @@ namespace OpenSim.Data.MSSQL
194 catch (Exception) 295 catch (Exception)
195 { 296 {
196 return false; 297 return false;
197 } 298 }
299 }
198 } 300 }
301
199 return true; 302 return true;
200 } 303 }
201 } 304 }
202} 305} \ No newline at end of file
diff --git a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs
index e045d75..1a67e70 100644
--- a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index da8e958..995c6a5 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL
219 219
220 public virtual bool Store(T row) 220 public virtual bool Store(T row)
221 { 221 {
222// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked");
223
222 using (MySqlCommand cmd = new MySqlCommand()) 224 using (MySqlCommand cmd = new MySqlCommand())
223 { 225 {
224 string query = ""; 226 string query = "";
@@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL
273 275
274 public virtual bool Delete(string[] fields, string[] keys) 276 public virtual bool Delete(string[] fields, string[] keys)
275 { 277 {
278// m_log.DebugFormat(
279// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}",
280// string.Join(",", fields), string.Join(",", keys));
281
276 if (fields.Length != keys.Length) 282 if (fields.Length != keys.Length)
277 return false; 283 return false;
278 284
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index caf18a4..c74033e 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -26,9 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Data; 30using System.Data;
31using System.Linq;
30using System.Reflection; 32using System.Reflection;
31using System.Collections.Generic;
32using log4net; 33using log4net;
33using MySql.Data.MySqlClient; 34using MySql.Data.MySqlClient;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -41,12 +42,12 @@ namespace OpenSim.Data.MySQL
41 /// </summary> 42 /// </summary>
42 public class MySQLXInventoryData : IXInventoryData 43 public class MySQLXInventoryData : IXInventoryData
43 { 44 {
44 private MySQLGenericTableHandler<XInventoryFolder> m_Folders; 45 private MySqlFolderHandler m_Folders;
45 private MySqlItemHandler m_Items; 46 private MySqlItemHandler m_Items;
46 47
47 public MySQLXInventoryData(string conn, string realm) 48 public MySQLXInventoryData(string conn, string realm)
48 { 49 {
49 m_Folders = new MySQLGenericTableHandler<XInventoryFolder>( 50 m_Folders = new MySqlFolderHandler(
50 conn, "inventoryfolders", "InventoryStore"); 51 conn, "inventoryfolders", "InventoryStore");
51 m_Items = new MySqlItemHandler( 52 m_Items = new MySqlItemHandler(
52 conn, "inventoryitems", String.Empty); 53 conn, "inventoryitems", String.Empty);
@@ -105,6 +106,11 @@ namespace OpenSim.Data.MySQL
105 return m_Items.MoveItem(id, newParent); 106 return m_Items.MoveItem(id, newParent);
106 } 107 }
107 108
109 public bool MoveFolder(string id, string newParent)
110 {
111 return m_Folders.MoveFolder(id, newParent);
112 }
113
108 public XInventoryItem[] GetActiveGestures(UUID principalID) 114 public XInventoryItem[] GetActiveGestures(UUID principalID)
109 { 115 {
110 return m_Items.GetActiveGestures(principalID); 116 return m_Items.GetActiveGestures(principalID);
@@ -116,24 +122,71 @@ namespace OpenSim.Data.MySQL
116 } 122 }
117 } 123 }
118 124
119 public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem> 125 public class MySqlItemHandler : MySqlInventoryHandler<XInventoryItem>
120 { 126 {
127// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
128
121 public MySqlItemHandler(string c, string t, string m) : 129 public MySqlItemHandler(string c, string t, string m) :
122 base(c, t, m) 130 base(c, t, m)
123 { 131 {
124 } 132 }
125 133
134 public override bool Delete(string field, string val)
135 {
136 XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val });
137 if (retrievedItems.Length == 0)
138 return false;
139
140 if (!base.Delete(field, val))
141 return false;
142
143 // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[])
144// IncrementFolderVersion(retrievedItems[0].parentFolderID);
145
146 return true;
147 }
148
149 public override bool Delete(string[] fields, string[] vals)
150 {
151 XInventoryItem[] retrievedItems = Get(fields, vals);
152 if (retrievedItems.Length == 0)
153 return false;
154
155 if (!base.Delete(fields, vals))
156 return false;
157
158 HashSet<UUID> deletedItemFolderUUIDs = new HashSet<UUID>();
159
160 Array.ForEach<XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
161
162 foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs)
163 IncrementFolderVersion(deletedItemFolderUUID);
164
165 return true;
166 }
167
126 public bool MoveItem(string id, string newParent) 168 public bool MoveItem(string id, string newParent)
127 { 169 {
170 XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
171 if (retrievedItems.Length == 0)
172 return false;
173
174 UUID oldParent = retrievedItems[0].parentFolderID;
175
128 using (MySqlCommand cmd = new MySqlCommand()) 176 using (MySqlCommand cmd = new MySqlCommand())
129 { 177 {
130
131 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); 178 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
132 cmd.Parameters.AddWithValue("?ParentFolderID", newParent); 179 cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
133 cmd.Parameters.AddWithValue("?InventoryID", id); 180 cmd.Parameters.AddWithValue("?InventoryID", id);
134 181
135 return ExecuteNonQuery(cmd) == 0 ? false : true; 182 if (ExecuteNonQuery(cmd) == 0)
183 return false;
136 } 184 }
185
186 IncrementFolderVersion(oldParent);
187 IncrementFolderVersion(newParent);
188
189 return true;
137 } 190 }
138 191
139 public XInventoryItem[] GetActiveGestures(UUID principalID) 192 public XInventoryItem[] GetActiveGestures(UUID principalID)
@@ -184,6 +237,73 @@ namespace OpenSim.Data.MySQL
184 if (!base.Store(item)) 237 if (!base.Store(item))
185 return false; 238 return false;
186 239
240 IncrementFolderVersion(item.parentFolderID);
241
242 return true;
243 }
244 }
245
246 public class MySqlFolderHandler : MySqlInventoryHandler<XInventoryFolder>
247 {
248// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
249
250 public MySqlFolderHandler(string c, string t, string m) :
251 base(c, t, m)
252 {
253 }
254
255 public bool MoveFolder(string id, string newParentFolderID)
256 {
257 XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
258
259 if (folders.Length == 0)
260 return false;
261
262 UUID oldParentFolderUUID = folders[0].parentFolderID;
263
264 using (MySqlCommand cmd = new MySqlCommand())
265 {
266 cmd.CommandText
267 = String.Format(
268 "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm);
269 cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID);
270 cmd.Parameters.AddWithValue("?folderID", id);
271
272 if (ExecuteNonQuery(cmd) == 0)
273 return false;
274 }
275
276 IncrementFolderVersion(oldParentFolderUUID);
277 IncrementFolderVersion(newParentFolderID);
278
279 return true;
280 }
281
282 public override bool Store(XInventoryFolder folder)
283 {
284 if (!base.Store(folder))
285 return false;
286
287 IncrementFolderVersion(folder.parentFolderID);
288
289 return true;
290 }
291 }
292
293 public class MySqlInventoryHandler<T> : MySQLGenericTableHandler<T> where T: class, new()
294 {
295 public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {}
296
297 protected bool IncrementFolderVersion(UUID folderID)
298 {
299 return IncrementFolderVersion(folderID.ToString());
300 }
301
302 protected bool IncrementFolderVersion(string folderID)
303 {
304// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID);
305// Util.PrintCallStack();
306
187 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 307 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
188 { 308 {
189 dbcon.Open(); 309 dbcon.Open();
@@ -193,7 +313,7 @@ namespace OpenSim.Data.MySQL
193 cmd.Connection = dbcon; 313 cmd.Connection = dbcon;
194 314
195 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); 315 cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
196 cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); 316 cmd.Parameters.AddWithValue("?folderID", folderID);
197 317
198 try 318 try
199 { 319 {
@@ -205,9 +325,11 @@ namespace OpenSim.Data.MySQL
205 } 325 }
206 cmd.Dispose(); 326 cmd.Dispose();
207 } 327 }
328
208 dbcon.Close(); 329 dbcon.Close();
209 } 330 }
331
210 return true; 332 return true;
211 } 333 }
212 } 334 }
213} 335} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs
index c28829c..ab3fe36 100644
--- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Data/Null/NullGenericDataHandler.cs b/OpenSim/Data/Null/NullGenericDataHandler.cs
new file mode 100644
index 0000000..dd9d190
--- /dev/null
+++ b/OpenSim/Data/Null/NullGenericDataHandler.cs
@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Data;
36
37namespace OpenSim.Data.Null
38{
39 /// <summary>
40 /// Not a proper generic data handler yet - probably needs to actually store the data as well instead of relying
41 /// on descendent classes
42 /// </summary>
43 public class NullGenericDataHandler
44 {
45 protected List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities)
46 {
47 List<T> entities = inputEntities;
48
49 for (int i = 0; i < fields.Length; i++)
50 {
51 entities
52 = entities.Where(
53 e =>
54 {
55 FieldInfo fi = typeof(T).GetField(fields[i]);
56 if (fi == null)
57 throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i]));
58
59 return fi.GetValue(e).ToString() == vals[i];
60 }
61 ).ToList();
62 }
63
64 return entities;
65 }
66 }
67} \ No newline at end of file
diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Data/Null/NullXGroupData.cs
index 456e455..7a86b9f 100644
--- a/OpenSim/Services/InventoryService/InventoryServiceBase.cs
+++ b/OpenSim/Data/Null/NullXGroupData.cs
@@ -26,57 +26,65 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
30using System.Reflection; 32using System.Reflection;
31using Nini.Config; 33using System.Threading;
34using log4net;
35using OpenMetaverse;
32using OpenSim.Framework; 36using OpenSim.Framework;
33using OpenSim.Data; 37using OpenSim.Data;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Base;
36 38
37namespace OpenSim.Services.InventoryService 39namespace OpenSim.Data.Null
38{ 40{
39 public class InventoryServiceBase : ServiceBase 41 public class NullXGroupData : NullGenericDataHandler, IXGroupData
40 { 42 {
41 protected IInventoryDataPlugin m_Database = null; 43// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 44
43 public InventoryServiceBase(IConfigSource config) : base(config) 45 private Dictionary<UUID, XGroup> m_groups = new Dictionary<UUID, XGroup>();
44 { 46
45 string dllName = String.Empty; 47 public NullXGroupData(string connectionString, string realm) {}
46 string connString = String.Empty;
47 48
48 // 49 public bool StoreGroup(XGroup group)
49 // Try reading the [DatabaseService] section first, if it exists 50 {
50 // 51 lock (m_groups)
51 IConfig dbConfig = config.Configs["DatabaseService"];
52 if (dbConfig != null)
53 { 52 {
54 dllName = dbConfig.GetString("StorageProvider", String.Empty); 53 m_groups[group.groupID] = group.Clone();
55 connString = dbConfig.GetString("ConnectionString", String.Empty);
56 } 54 }
57 55
58 // 56 return true;
59 // Try reading the more specific [InventoryService] section, if it exists 57 }
60 // 58
61 IConfig inventoryConfig = config.Configs["InventoryService"]; 59 public XGroup[] GetGroups(string field, string val)
62 if (inventoryConfig != null) 60 {
61 return GetGroups(new string[] { field }, new string[] { val });
62 }
63
64 public XGroup[] GetGroups(string[] fields, string[] vals)
65 {
66 lock (m_groups)
63 { 67 {
64 dllName = inventoryConfig.GetString("StorageProvider", dllName); 68 List<XGroup> origGroups = Get<XGroup>(fields, vals, m_groups.Values.ToList());
65 connString = inventoryConfig.GetString("ConnectionString", connString); 69
70 return origGroups.Select(g => g.Clone()).ToArray();
66 } 71 }
72 }
67 73
68 // 74 public bool DeleteGroups(string field, string val)
69 // We tried, but this doesn't exist. We can't proceed. 75 {
70 // 76 return DeleteGroups(new string[] { field }, new string[] { val });
71 if (dllName.Equals(String.Empty)) 77 }
72 throw new Exception("No InventoryService configuration");
73 78
74 m_Database = LoadPlugin<IInventoryDataPlugin>(dllName); 79 public bool DeleteGroups(string[] fields, string[] vals)
75 if (m_Database == null) 80 {
76 throw new Exception("Could not find a storage interface in the given module"); 81 lock (m_groups)
82 {
83 XGroup[] groupsToDelete = GetGroups(fields, vals);
84 Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID));
85 }
77 86
78 m_Database.Initialise(connString); 87 return true;
79 } 88 }
80
81 } 89 }
82} 90} \ No newline at end of file
diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs
index 4b64436..43b0bb3 100644
--- a/OpenSim/Data/Null/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/Null/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs
index 6940d25..0da1a6b 100644
--- a/OpenSim/Data/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs
index d45ab50..c9a8553 100644
--- a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs
+++ b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
61// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below: 62// by using the '*' as shown below:
63 63
64[assembly : AssemblyVersion("0.6.5.*")] 64[assembly : AssemblyVersion("0.7.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")] 65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index d0e24c3..61e7aaf 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -202,7 +202,8 @@ namespace OpenSim.Data.SQLite
202 /// <returns>True if exist, or false.</returns> 202 /// <returns>True if exist, or false.</returns>
203 override public bool ExistsAsset(UUID uuid) 203 override public bool ExistsAsset(UUID uuid)
204 { 204 {
205 lock (this) { 205 lock (this)
206 {
206 using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) 207 using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
207 { 208 {
208 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); 209 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
@@ -353,12 +354,13 @@ namespace OpenSim.Data.SQLite
353 { 354 {
354 lock (this) 355 lock (this)
355 { 356 {
356 using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) 357 using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
357 { 358 {
358 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); 359 cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString()));
359 cmd.ExecuteNonQuery(); 360 cmd.ExecuteNonQuery();
360 } 361 }
361 } 362 }
363
362 return true; 364 return true;
363 } 365 }
364 366
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
index 5120453..0428c11 100644
--- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
@@ -82,11 +82,14 @@ namespace OpenSim.Data.SQLite
82 { 82 {
83 AuthenticationData ret = new AuthenticationData(); 83 AuthenticationData ret = new AuthenticationData();
84 ret.Data = new Dictionary<string, object>(); 84 ret.Data = new Dictionary<string, object>();
85 IDataReader result;
85 86
86 SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); 87 using (SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"))
87 cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); 88 {
89 cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
88 90
89 IDataReader result = ExecuteReader(cmd, m_Connection); 91 result = ExecuteReader(cmd, m_Connection);
92 }
90 93
91 try 94 try
92 { 95 {
@@ -121,10 +124,6 @@ namespace OpenSim.Data.SQLite
121 catch 124 catch
122 { 125 {
123 } 126 }
124 finally
125 {
126 //CloseCommand(cmd);
127 }
128 127
129 return null; 128 return null;
130 } 129 }
@@ -140,84 +139,81 @@ namespace OpenSim.Data.SQLite
140 foreach (object o in data.Data.Values) 139 foreach (object o in data.Data.Values)
141 values[i++] = o.ToString(); 140 values[i++] = o.ToString();
142 141
143 SqliteCommand cmd = new SqliteCommand(); 142 using (SqliteCommand cmd = new SqliteCommand())
144
145 if (Get(data.PrincipalID) != null)
146 { 143 {
144 if (Get(data.PrincipalID) != null)
145 {
147 146
148 147
149 string update = "update `" + m_Realm + "` set "; 148 string update = "update `" + m_Realm + "` set ";
150 bool first = true; 149 bool first = true;
151 foreach (string field in fields) 150 foreach (string field in fields)
152 { 151 {
153 if (!first) 152 if (!first)
154 update += ", "; 153 update += ", ";
155 update += "`" + field + "` = :" + field; 154 update += "`" + field + "` = :" + field;
156 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); 155 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
157 156
158 first = false; 157 first = false;
159 } 158 }
160 159
161 update += " where UUID = :UUID"; 160 update += " where UUID = :UUID";
162 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); 161 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
163 162
164 cmd.CommandText = update; 163 cmd.CommandText = update;
165 try 164 try
166 { 165 {
167 if (ExecuteNonQuery(cmd, m_Connection) < 1) 166 if (ExecuteNonQuery(cmd, m_Connection) < 1)
167 {
168 //CloseCommand(cmd);
169 return false;
170 }
171 }
172 catch (Exception e)
168 { 173 {
174 m_log.Error("[SQLITE]: Exception storing authentication data", e);
169 //CloseCommand(cmd); 175 //CloseCommand(cmd);
170 return false; 176 return false;
171 } 177 }
172 } 178 }
173 catch (Exception e) 179 else
174 { 180 {
175 m_log.Error("[SQLITE]: Exception storing authentication data", e); 181 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
176 //CloseCommand(cmd); 182 String.Join("`, `", fields) +
177 return false; 183 "`) values (:UUID, :" + String.Join(", :", fields) + ")";
178 }
179 }
180 184
181 else 185 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
182 { 186 foreach (string field in fields)
183 string insert = "insert into `" + m_Realm + "` (`UUID`, `" + 187 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
184 String.Join("`, `", fields) +
185 "`) values (:UUID, :" + String.Join(", :", fields) + ")";
186
187 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
188 foreach (string field in fields)
189 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
190 188
191 cmd.CommandText = insert; 189 cmd.CommandText = insert;
192 190
193 try 191 try
194 {
195 if (ExecuteNonQuery(cmd, m_Connection) < 1)
196 { 192 {
197 //CloseCommand(cmd); 193 if (ExecuteNonQuery(cmd, m_Connection) < 1)
194 {
195 return false;
196 }
197 }
198 catch (Exception e)
199 {
200 Console.WriteLine(e.ToString());
198 return false; 201 return false;
199 } 202 }
200 } 203 }
201 catch (Exception e)
202 {
203 Console.WriteLine(e.ToString());
204 //CloseCommand(cmd);
205 return false;
206 }
207 } 204 }
208 205
209 //CloseCommand(cmd);
210
211 return true; 206 return true;
212 } 207 }
213 208
214 public bool SetDataItem(UUID principalID, string item, string value) 209 public bool SetDataItem(UUID principalID, string item, string value)
215 { 210 {
216 SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + 211 using (SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
217 "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); 212 "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"))
218 213 {
219 if (ExecuteNonQuery(cmd, m_Connection) > 0) 214 if (ExecuteNonQuery(cmd, m_Connection) > 0)
220 return true; 215 return true;
216 }
221 217
222 return false; 218 return false;
223 } 219 }
@@ -227,16 +223,13 @@ namespace OpenSim.Data.SQLite
227 if (System.Environment.TickCount - m_LastExpire > 30000) 223 if (System.Environment.TickCount - m_LastExpire > 30000)
228 DoExpire(); 224 DoExpire();
229 225
230 SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + 226 using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
231 "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); 227 "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"))
232
233 if (ExecuteNonQuery(cmd, m_Connection) > 0)
234 { 228 {
235 cmd.Dispose(); 229 if (ExecuteNonQuery(cmd, m_Connection) > 0)
236 return true; 230 return true;
237 } 231 }
238 232
239 cmd.Dispose();
240 return false; 233 return false;
241 } 234 }
242 235
@@ -245,28 +238,22 @@ namespace OpenSim.Data.SQLite
245 if (System.Environment.TickCount - m_LastExpire > 30000) 238 if (System.Environment.TickCount - m_LastExpire > 30000)
246 DoExpire(); 239 DoExpire();
247 240
248 SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + 241 using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
249 " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); 242 " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"))
250
251 if (ExecuteNonQuery(cmd, m_Connection) > 0)
252 { 243 {
253 cmd.Dispose(); 244 if (ExecuteNonQuery(cmd, m_Connection) > 0)
254 return true; 245 return true;
255 } 246 }
256 247
257 cmd.Dispose();
258
259 return false; 248 return false;
260 } 249 }
261 250
262 private void DoExpire() 251 private void DoExpire()
263 { 252 {
264 SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); 253 using (SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"))
265 ExecuteNonQuery(cmd, m_Connection); 254 ExecuteNonQuery(cmd, m_Connection);
266
267 cmd.Dispose();
268 255
269 m_LastExpire = System.Environment.TickCount; 256 m_LastExpire = System.Environment.TickCount;
270 } 257 }
271 } 258 }
272} 259} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteAvatarData.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs
index faf34da..c6d615b 100644
--- a/OpenSim/Data/SQLite/SQLiteAvatarData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs
@@ -56,23 +56,17 @@ namespace OpenSim.Data.SQLite
56 56
57 public bool Delete(UUID principalID, string name) 57 public bool Delete(UUID principalID, string name)
58 { 58 {
59 SqliteCommand cmd = new SqliteCommand(); 59 using (SqliteCommand cmd = new SqliteCommand())
60
61 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
62 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
63 cmd.Parameters.AddWithValue(":Name", name);
64
65 try
66 { 60 {
61 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
62 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
63 cmd.Parameters.AddWithValue(":Name", name);
64
67 if (ExecuteNonQuery(cmd, m_Connection) > 0) 65 if (ExecuteNonQuery(cmd, m_Connection) > 0)
68 return true; 66 return true;
69
70 return false;
71 }
72 finally
73 {
74 //CloseCommand(cmd);
75 } 67 }
68
69 return false;
76 } 70 }
77 } 71 }
78} 72} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index c042ba2..d51f2d4 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -104,12 +104,13 @@ namespace OpenSim.Data.SQLite
104 { 104 {
105 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"; 105 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";
106 106
107 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 107 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
108 108 {
109 cmd.CommandText = sql; 109 cmd.CommandText = sql;
110 cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); 110 cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
111 111
112 return DoLoad(cmd, regionID, create); 112 return DoLoad(cmd, regionID, create);
113 }
113 } 114 }
114 115
115 private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) 116 private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
@@ -186,37 +187,39 @@ namespace OpenSim.Data.SQLite
186 { 187 {
187 List<string> names = new List<string>(FieldList); 188 List<string> names = new List<string>(FieldList);
188 189
189 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
190 IDataReader r = null; 190 IDataReader r = null;
191 191
192 names.Remove("EstateID"); 192 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
193 {
194 names.Remove("EstateID");
193 195
194 string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; 196 string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
195 197
196 cmd.CommandText = sql; 198 cmd.CommandText = sql;
197 cmd.Parameters.Clear(); 199 cmd.Parameters.Clear();
198 200
199 foreach (string name in FieldList) 201 foreach (string name in FieldList)
200 {
201 if (m_FieldMap[name].GetValue(es) is bool)
202 { 202 {
203 if ((bool)m_FieldMap[name].GetValue(es)) 203 if (m_FieldMap[name].GetValue(es) is bool)
204 cmd.Parameters.AddWithValue(":"+name, "1"); 204 {
205 if ((bool)m_FieldMap[name].GetValue(es))
206 cmd.Parameters.AddWithValue(":"+name, "1");
207 else
208 cmd.Parameters.AddWithValue(":"+name, "0");
209 }
205 else 210 else
206 cmd.Parameters.AddWithValue(":"+name, "0"); 211 {
207 } 212 cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
208 else 213 }
209 {
210 cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
211 } 214 }
212 }
213 215
214 cmd.ExecuteNonQuery(); 216 cmd.ExecuteNonQuery();
215 217
216 cmd.CommandText = "select LAST_INSERT_ROWID() as id"; 218 cmd.CommandText = "select LAST_INSERT_ROWID() as id";
217 cmd.Parameters.Clear(); 219 cmd.Parameters.Clear();
218 220
219 r = cmd.ExecuteReader(); 221 r = cmd.ExecuteReader();
222 }
220 223
221 r.Read(); 224 r.Read();
222 225
@@ -239,26 +242,27 @@ namespace OpenSim.Data.SQLite
239 242
240 string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; 243 string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID";
241 244
242 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 245 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
243
244 cmd.CommandText = sql;
245
246 foreach (string name in FieldList)
247 { 246 {
248 if (m_FieldMap[name].GetValue(es) is bool) 247 cmd.CommandText = sql;
248
249 foreach (string name in FieldList)
249 { 250 {
250 if ((bool)m_FieldMap[name].GetValue(es)) 251 if (m_FieldMap[name].GetValue(es) is bool)
251 cmd.Parameters.AddWithValue(":"+name, "1"); 252 {
253 if ((bool)m_FieldMap[name].GetValue(es))
254 cmd.Parameters.AddWithValue(":"+name, "1");
255 else
256 cmd.Parameters.AddWithValue(":"+name, "0");
257 }
252 else 258 else
253 cmd.Parameters.AddWithValue(":"+name, "0"); 259 {
254 } 260 cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
255 else 261 }
256 {
257 cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
258 } 262 }
259 }
260 263
261 cmd.ExecuteNonQuery(); 264 cmd.ExecuteNonQuery();
265 }
262 266
263 SaveBanList(es); 267 SaveBanList(es);
264 SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); 268 SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
@@ -270,12 +274,15 @@ namespace OpenSim.Data.SQLite
270 { 274 {
271 es.ClearBans(); 275 es.ClearBans();
272 276
273 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 277 IDataReader r;
274 278
275 cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; 279 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
276 cmd.Parameters.AddWithValue(":EstateID", es.EstateID); 280 {
281 cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID";
282 cmd.Parameters.AddWithValue(":EstateID", es.EstateID);
277 283
278 IDataReader r = cmd.ExecuteReader(); 284 r = cmd.ExecuteReader();
285 }
279 286
280 while (r.Read()) 287 while (r.Read())
281 { 288 {
@@ -294,60 +301,64 @@ namespace OpenSim.Data.SQLite
294 301
295 private void SaveBanList(EstateSettings es) 302 private void SaveBanList(EstateSettings es)
296 { 303 {
297 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 304 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
298
299 cmd.CommandText = "delete from estateban where EstateID = :EstateID";
300 cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
301
302 cmd.ExecuteNonQuery();
303
304 cmd.Parameters.Clear();
305
306 cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )";
307
308 foreach (EstateBan b in es.EstateBans)
309 { 305 {
306 cmd.CommandText = "delete from estateban where EstateID = :EstateID";
310 cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); 307 cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
311 cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
312 308
313 cmd.ExecuteNonQuery(); 309 cmd.ExecuteNonQuery();
310
314 cmd.Parameters.Clear(); 311 cmd.Parameters.Clear();
312
313 cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )";
314
315 foreach (EstateBan b in es.EstateBans)
316 {
317 cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());
318 cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString());
319
320 cmd.ExecuteNonQuery();
321 cmd.Parameters.Clear();
322 }
315 } 323 }
316 } 324 }
317 325
318 void SaveUUIDList(uint EstateID, string table, UUID[] data) 326 void SaveUUIDList(uint EstateID, string table, UUID[] data)
319 { 327 {
320 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 328 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
321
322 cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
323 cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
324
325 cmd.ExecuteNonQuery();
326
327 cmd.Parameters.Clear();
328
329 cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )";
330
331 foreach (UUID uuid in data)
332 { 329 {
330 cmd.CommandText = "delete from "+table+" where EstateID = :EstateID";
333 cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); 331 cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
334 cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
335 332
336 cmd.ExecuteNonQuery(); 333 cmd.ExecuteNonQuery();
334
337 cmd.Parameters.Clear(); 335 cmd.Parameters.Clear();
336
337 cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )";
338
339 foreach (UUID uuid in data)
340 {
341 cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString());
342 cmd.Parameters.AddWithValue(":uuid", uuid.ToString());
343
344 cmd.ExecuteNonQuery();
345 cmd.Parameters.Clear();
346 }
338 } 347 }
339 } 348 }
340 349
341 UUID[] LoadUUIDList(uint EstateID, string table) 350 UUID[] LoadUUIDList(uint EstateID, string table)
342 { 351 {
343 List<UUID> uuids = new List<UUID>(); 352 List<UUID> uuids = new List<UUID>();
353 IDataReader r;
344 354
345 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 355 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
346 356 {
347 cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; 357 cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID";
348 cmd.Parameters.AddWithValue(":EstateID", EstateID); 358 cmd.Parameters.AddWithValue(":EstateID", EstateID);
349 359
350 IDataReader r = cmd.ExecuteReader(); 360 r = cmd.ExecuteReader();
361 }
351 362
352 while (r.Read()) 363 while (r.Read())
353 { 364 {
@@ -367,12 +378,13 @@ namespace OpenSim.Data.SQLite
367 { 378 {
368 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; 379 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID";
369 380
370 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 381 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
371 382 {
372 cmd.CommandText = sql; 383 cmd.CommandText = sql;
373 cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); 384 cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
374 385
375 return DoLoad(cmd, UUID.Zero, false); 386 return DoLoad(cmd, UUID.Zero, false);
387 }
376 } 388 }
377 389
378 public List<EstateSettings> LoadEstateSettingsAll() 390 public List<EstateSettings> LoadEstateSettingsAll()
@@ -391,13 +403,15 @@ namespace OpenSim.Data.SQLite
391 List<int> result = new List<int>(); 403 List<int> result = new List<int>();
392 404
393 string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; 405 string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName";
406 IDataReader r;
394 407
395 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 408 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
396 409 {
397 cmd.CommandText = sql; 410 cmd.CommandText = sql;
398 cmd.Parameters.AddWithValue(":EstateName", search); 411 cmd.Parameters.AddWithValue(":EstateName", search);
399 412
400 IDataReader r = cmd.ExecuteReader(); 413 r = cmd.ExecuteReader();
414 }
401 415
402 while (r.Read()) 416 while (r.Read())
403 { 417 {
@@ -413,12 +427,14 @@ namespace OpenSim.Data.SQLite
413 List<int> result = new List<int>(); 427 List<int> result = new List<int>();
414 428
415 string sql = "select EstateID from estate_settings"; 429 string sql = "select EstateID from estate_settings";
430 IDataReader r;
416 431
417 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 432 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
418 433 {
419 cmd.CommandText = sql; 434 cmd.CommandText = sql;
420 435
421 IDataReader r = cmd.ExecuteReader(); 436 r = cmd.ExecuteReader();
437 }
422 438
423 while (r.Read()) 439 while (r.Read())
424 { 440 {
@@ -434,13 +450,15 @@ namespace OpenSim.Data.SQLite
434 List<int> result = new List<int>(); 450 List<int> result = new List<int>();
435 451
436 string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; 452 string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner";
453 IDataReader r;
437 454
438 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 455 using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand())
439 456 {
440 cmd.CommandText = sql; 457 cmd.CommandText = sql;
441 cmd.Parameters.AddWithValue(":EstateOwner", ownerID); 458 cmd.Parameters.AddWithValue(":EstateOwner", ownerID);
442 459
443 IDataReader r = cmd.ExecuteReader(); 460 r = cmd.ExecuteReader();
461 }
444 462
445 while (r.Read()) 463 while (r.Read())
446 { 464 {
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs
index 1594717..35b9a2f 100644
--- a/OpenSim/Data/SQLite/SQLiteFramework.cs
+++ b/OpenSim/Data/SQLite/SQLiteFramework.cs
@@ -90,12 +90,5 @@ namespace OpenSim.Data.SQLite
90 return cmd.ExecuteReader(); 90 return cmd.ExecuteReader();
91 } 91 }
92 } 92 }
93
94 protected void CloseCommand(SqliteCommand cmd)
95 {
96 cmd.Connection.Close();
97 cmd.Connection.Dispose();
98 cmd.Dispose();
99 }
100 } 93 }
101} 94} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs
index 5f68977..cab85eb 100644
--- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs
+++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs
@@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite
53 53
54 public FriendsData[] GetFriends(string userID) 54 public FriendsData[] GetFriends(string userID)
55 { 55 {
56 SqliteCommand cmd = new SqliteCommand(); 56 using (SqliteCommand cmd = new SqliteCommand())
57 57 {
58 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); 58 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
59 cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); 59 cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString());
60
61 return DoQuery(cmd);
62 60
61 return DoQuery(cmd);
62 }
63 } 63 }
64 64
65 public bool Delete(UUID principalID, string friend) 65 public bool Delete(UUID principalID, string friend)
@@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite
69 69
70 public bool Delete(string principalID, string friend) 70 public bool Delete(string principalID, string friend)
71 { 71 {
72 SqliteCommand cmd = new SqliteCommand(); 72 using (SqliteCommand cmd = new SqliteCommand())
73 73 {
74 cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); 74 cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
75 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); 75 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
76 cmd.Parameters.AddWithValue(":Friend", friend); 76 cmd.Parameters.AddWithValue(":Friend", friend);
77 77
78 ExecuteNonQuery(cmd, m_Connection); 78 ExecuteNonQuery(cmd, m_Connection);
79 }
79 80
80 return true; 81 return true;
81 } 82 }
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 4f977a8..9fbeb10 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -120,34 +120,35 @@ 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];
132 132
133 List<string> terms = new List<string>(); 133 List<string> terms = new List<string>();
134 134
135 SqliteCommand cmd = new SqliteCommand(); 135 using (SqliteCommand cmd = new SqliteCommand())
136
137 for (int i = 0 ; i < fields.Length ; i++)
138 { 136 {
139 cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); 137 for (int i = 0 ; i < fields.Length ; i++)
140 terms.Add("`" + fields[i] + "` = :" + fields[i]); 138 {
141 } 139 cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
140 terms.Add("`" + fields[i] + "` = :" + fields[i]);
141 }
142 142
143 string where = String.Join(" and ", terms.ToArray()); 143 string where = String.Join(" and ", terms.ToArray());
144 144
145 string query = String.Format("select * from {0} where {1}", 145 string query = String.Format("select * from {0} where {1}",
146 m_Realm, where); 146 m_Realm, where);
147 147
148 cmd.CommandText = query; 148 cmd.CommandText = query;
149 149
150 return DoQuery(cmd); 150 return DoQuery(cmd);
151 }
151 } 152 }
152 153
153 protected T[] DoQuery(SqliteCommand cmd) 154 protected T[] DoQuery(SqliteCommand cmd)
@@ -212,52 +213,54 @@ namespace OpenSim.Data.SQLite
212 return result.ToArray(); 213 return result.ToArray();
213 } 214 }
214 215
215 public T[] Get(string where) 216 public virtual T[] Get(string where)
216 { 217 {
217 SqliteCommand cmd = new SqliteCommand(); 218 using (SqliteCommand cmd = new SqliteCommand())
218 219 {
219 string query = String.Format("select * from {0} where {1}", 220 string query = String.Format("select * from {0} where {1}",
220 m_Realm, where); 221 m_Realm, where);
221 222
222 cmd.CommandText = query; 223 cmd.CommandText = query;
223 224
224 return DoQuery(cmd); 225 return DoQuery(cmd);
226 }
225 } 227 }
226 228
227 public bool Store(T row) 229 public virtual bool Store(T row)
228 { 230 {
229 SqliteCommand cmd = new SqliteCommand(); 231 using (SqliteCommand cmd = new SqliteCommand())
230
231 string query = "";
232 List<String> names = new List<String>();
233 List<String> values = new List<String>();
234
235 foreach (FieldInfo fi in m_Fields.Values)
236 { 232 {
237 names.Add(fi.Name); 233 string query = "";
238 values.Add(":" + fi.Name); 234 List<String> names = new List<String>();
239 cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); 235 List<String> values = new List<String>();
240 }
241 236
242 if (m_DataField != null) 237 foreach (FieldInfo fi in m_Fields.Values)
243 { 238 {
244 Dictionary<string, string> data = 239 names.Add(fi.Name);
245 (Dictionary<string, string>)m_DataField.GetValue(row); 240 values.Add(":" + fi.Name);
241 cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString()));
242 }
246 243
247 foreach (KeyValuePair<string, string> kvp in data) 244 if (m_DataField != null)
248 { 245 {
249 names.Add(kvp.Key); 246 Dictionary<string, string> data =
250 values.Add(":" + kvp.Key); 247 (Dictionary<string, string>)m_DataField.GetValue(row);
251 cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); 248
249 foreach (KeyValuePair<string, string> kvp in data)
250 {
251 names.Add(kvp.Key);
252 values.Add(":" + kvp.Key);
253 cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value));
254 }
252 } 255 }
253 }
254 256
255 query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; 257 query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")";
256 258
257 cmd.CommandText = query; 259 cmd.CommandText = query;
258 260
259 if (ExecuteNonQuery(cmd, m_Connection) > 0) 261 if (ExecuteNonQuery(cmd, m_Connection) > 0)
260 return true; 262 return true;
263 }
261 264
262 return false; 265 return false;
263 } 266 }
@@ -267,28 +270,29 @@ namespace OpenSim.Data.SQLite
267 return Delete(new string[] { field }, new string[] { key }); 270 return Delete(new string[] { field }, new string[] { key });
268 } 271 }
269 272
270 public bool Delete(string[] fields, string[] keys) 273 public virtual bool Delete(string[] fields, string[] keys)
271 { 274 {
272 if (fields.Length != keys.Length) 275 if (fields.Length != keys.Length)
273 return false; 276 return false;
274 277
275 List<string> terms = new List<string>(); 278 List<string> terms = new List<string>();
276 279
277 SqliteCommand cmd = new SqliteCommand(); 280 using (SqliteCommand cmd = new SqliteCommand())
278
279 for (int i = 0 ; i < fields.Length ; i++)
280 { 281 {
281 cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); 282 for (int i = 0 ; i < fields.Length ; i++)
282 terms.Add("`" + fields[i] + "` = :" + fields[i]); 283 {
283 } 284 cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
285 terms.Add("`" + fields[i] + "` = :" + fields[i]);
286 }
284 287
285 string where = String.Join(" and ", terms.ToArray()); 288 string where = String.Join(" and ", terms.ToArray());
286 289
287 string query = String.Format("delete from {0} where {1}", m_Realm, where); 290 string query = String.Format("delete from {0} where {1}", m_Realm, where);
288 291
289 cmd.CommandText = query; 292 cmd.CommandText = query;
290 293
291 return ExecuteNonQuery(cmd, m_Connection) > 0; 294 return ExecuteNonQuery(cmd, m_Connection) > 0;
295 }
292 } 296 }
293 } 297 }
294} 298}
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 56df3cb..29cac3c 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -1366,6 +1366,13 @@ namespace OpenSim.Data.SQLite
1366 createCol(land, "UserLookAtZ", typeof(Double)); 1366 createCol(land, "UserLookAtZ", typeof(Double));
1367 createCol(land, "AuthbuyerID", typeof(String)); 1367 createCol(land, "AuthbuyerID", typeof(String));
1368 createCol(land, "OtherCleanTime", typeof(Int32)); 1368 createCol(land, "OtherCleanTime", typeof(Int32));
1369 createCol(land, "Dwell", typeof(Int32));
1370 createCol(land, "MediaType", typeof(String));
1371 createCol(land, "MediaDescription", typeof(String));
1372 createCol(land, "MediaSize", typeof(String));
1373 createCol(land, "MediaLoop", typeof(Boolean));
1374 createCol(land, "ObscureMedia", typeof(Boolean));
1375 createCol(land, "ObscureMusic", typeof(Boolean));
1369 1376
1370 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; 1377 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] };
1371 1378
@@ -1781,9 +1788,16 @@ namespace OpenSim.Data.SQLite
1781 newData.PassHours = Convert.ToSingle(row["PassHours"]); 1788 newData.PassHours = Convert.ToSingle(row["PassHours"]);
1782 newData.PassPrice = Convert.ToInt32(row["PassPrice"]); 1789 newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
1783 newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; 1790 newData.SnapshotID = (UUID)(String)row["SnapshotUUID"];
1791 newData.Dwell = Convert.ToInt32(row["Dwell"]);
1792 newData.MediaType = (String)row["MediaType"];
1793 newData.MediaDescription = (String)row["MediaDescription"];
1794 newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]);
1795 newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]);
1796 newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]);
1797 newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
1798 newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
1784 try 1799 try
1785 { 1800 {
1786
1787 newData.UserLocation = 1801 newData.UserLocation =
1788 new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), 1802 new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
1789 Convert.ToSingle(row["UserLocationZ"])); 1803 Convert.ToSingle(row["UserLocationZ"]));
@@ -2195,12 +2209,13 @@ namespace OpenSim.Data.SQLite
2195 row["UserLookAtZ"] = land.UserLookAt.Z; 2209 row["UserLookAtZ"] = land.UserLookAt.Z;
2196 row["AuthbuyerID"] = land.AuthBuyerID.ToString(); 2210 row["AuthbuyerID"] = land.AuthBuyerID.ToString();
2197 row["OtherCleanTime"] = land.OtherCleanTime; 2211 row["OtherCleanTime"] = land.OtherCleanTime;
2212 row["Dwell"] = land.Dwell;
2198 row["MediaType"] = land.MediaType; 2213 row["MediaType"] = land.MediaType;
2199 row["MediaDescription"] = land.MediaDescription; 2214 row["MediaDescription"] = land.MediaDescription;
2200 row["MediaSize"] = land.MediaWidth.ToString() + "," + land.MediaHeight.ToString(); 2215 row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight);
2201 row["MediaLoop"] = land.MediaLoop.ToString(); 2216 row["MediaLoop"] = land.MediaLoop;
2202 row["ObscureMusic"] = land.ObscureMusic.ToString(); 2217 row["ObscureMusic"] = land.ObscureMusic;
2203 row["ObscureMedia"] = land.ObscureMedia.ToString(); 2218 row["ObscureMedia"] = land.ObscureMedia;
2204 } 2219 }
2205 2220
2206 /// <summary> 2221 /// <summary>
diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
index 7a5de50..f98d376 100644
--- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
@@ -66,20 +66,21 @@ namespace OpenSim.Data.SQLite
66 if (words.Length > 2) 66 if (words.Length > 2)
67 return new UserAccountData[0]; 67 return new UserAccountData[0];
68 68
69 SqliteCommand cmd = new SqliteCommand(); 69 using (SqliteCommand cmd = new SqliteCommand())
70
71 if (words.Length == 1)
72 {
73 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
74 m_Realm, scopeID.ToString(), words[0]);
75 }
76 else
77 { 70 {
78 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", 71 if (words.Length == 1)
79 m_Realm, scopeID.ToString(), words[0], words[1]); 72 {
80 } 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
74 m_Realm, scopeID.ToString(), words[0]);
75 }
76 else
77 {
78 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
79 m_Realm, scopeID.ToString(), words[0], words[1]);
80 }
81 81
82 return DoQuery(cmd); 82 return DoQuery(cmd);
83 }
83 } 84 }
84 } 85 }
85} 86}
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 1f36986..2a0a8f6 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite
47 { 47 {
48// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private SQLiteGenericTableHandler<XInventoryFolder> m_Folders; 50 private SqliteFolderHandler m_Folders;
51 private SqliteItemHandler m_Items; 51 private SqliteItemHandler m_Items;
52 52
53 public SQLiteXInventoryData(string conn, string realm) 53 public SQLiteXInventoryData(string conn, string realm)
@@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite
55 if (Util.IsWindows()) 55 if (Util.IsWindows())
56 Util.LoadArchSpecificWindowsDll("sqlite3.dll"); 56 Util.LoadArchSpecificWindowsDll("sqlite3.dll");
57 57
58 m_Folders = new SQLiteGenericTableHandler<XInventoryFolder>( 58 m_Folders = new SqliteFolderHandler(
59 conn, "inventoryfolders", "XInventoryStore"); 59 conn, "inventoryfolders", "XInventoryStore");
60 m_Items = new SqliteItemHandler( 60 m_Items = new SqliteItemHandler(
61 conn, "inventoryitems", String.Empty); 61 conn, "inventoryitems", String.Empty);
@@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite
114 return m_Items.MoveItem(id, newParent); 114 return m_Items.MoveItem(id, newParent);
115 } 115 }
116 116
117 public bool MoveFolder(string id, string newParent)
118 {
119 return m_Folders.MoveFolder(id, newParent);
120 }
121
117 public XInventoryItem[] GetActiveGestures(UUID principalID) 122 public XInventoryItem[] GetActiveGestures(UUID principalID)
118 { 123 {
119 return m_Items.GetActiveGestures(principalID); 124 return m_Items.GetActiveGestures(principalID);
@@ -125,44 +130,106 @@ namespace OpenSim.Data.SQLite
125 } 130 }
126 } 131 }
127 132
128 public class SqliteItemHandler : SQLiteGenericTableHandler<XInventoryItem> 133 public class SqliteItemHandler : SqliteInventoryHandler<XInventoryItem>
129 { 134 {
130 public SqliteItemHandler(string c, string t, string m) : 135 public SqliteItemHandler(string c, string t, string m) :
131 base(c, t, m) 136 base(c, t, m)
132 { 137 {
133 } 138 }
134 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
135 public bool MoveItem(string id, string newParent) 184 public bool MoveItem(string id, string newParent)
136 { 185 {
137 SqliteCommand cmd = new SqliteCommand(); 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
192 using (SqliteCommand cmd = new SqliteCommand())
193 {
194 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
195 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent));
196 cmd.Parameters.Add(new SqliteParameter(":InventoryID", id));
138 197
139 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); 198 if (ExecuteNonQuery(cmd, m_Connection) == 0)
140 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); 199 return false;
141 cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); 200 }
201
202 IncrementFolderVersion(oldParent);
203 IncrementFolderVersion(newParent);
142 204
143 return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; 205 return true;
144 } 206 }
145 207
146 public XInventoryItem[] GetActiveGestures(UUID principalID) 208 public XInventoryItem[] GetActiveGestures(UUID principalID)
147 { 209 {
148 SqliteCommand cmd = new SqliteCommand(); 210 using (SqliteCommand cmd = new SqliteCommand())
149 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); 211 {
212 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm);
150 213
151 cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); 214 cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString()));
152 cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); 215 cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture));
153 216
154 return DoQuery(cmd); 217 return DoQuery(cmd);
218 }
155 } 219 }
156 220
157 public int GetAssetPermissions(UUID principalID, UUID assetID) 221 public int GetAssetPermissions(UUID principalID, UUID assetID)
158 { 222 {
159 SqliteCommand cmd = new SqliteCommand(); 223 IDataReader reader;
160 224
161 cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); 225 using (SqliteCommand cmd = new SqliteCommand())
162 cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); 226 {
163 cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); 227 cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm);
228 cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
229 cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString()));
164 230
165 IDataReader reader = ExecuteReader(cmd, m_Connection); 231 reader = ExecuteReader(cmd, m_Connection);
232 }
166 233
167 int perms = 0; 234 int perms = 0;
168 235
@@ -177,4 +244,81 @@ namespace OpenSim.Data.SQLite
177 return perms; 244 return perms;
178 } 245 }
179 } 246 }
180} 247
248 public class SqliteFolderHandler : SqliteInventoryHandler<XInventoryFolder>
249 {
250 public SqliteFolderHandler(string c, string t, string m) :
251 base(c, t, m)
252 {
253 }
254
255 public override bool Store(XInventoryFolder folder)
256 {
257 if (!base.Store(folder))
258 return false;
259
260 IncrementFolderVersion(folder.parentFolderID);
261
262 return true;
263 }
264
265 public bool MoveFolder(string id, string newParentFolderID)
266 {
267 XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
268
269 if (folders.Length == 0)
270 return false;
271
272 UUID oldParentFolderUUID = folders[0].parentFolderID;
273
274 using (SqliteCommand cmd = new SqliteCommand())
275 {
276 cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm);
277 cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID));
278 cmd.Parameters.Add(new SqliteParameter(":FolderID", id));
279
280 if (ExecuteNonQuery(cmd, m_Connection) == 0)
281 return false;
282 }
283
284 IncrementFolderVersion(oldParentFolderUUID);
285 IncrementFolderVersion(newParentFolderID);
286
287 return true;
288 }
289
290 }
291
292 public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new()
293 {
294 public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {}
295
296 protected bool IncrementFolderVersion(UUID folderID)
297 {
298 return IncrementFolderVersion(folderID.ToString());
299 }
300
301 protected bool IncrementFolderVersion(string folderID)
302 {
303// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
304// Util.PrintCallStack();
305
306 using (SqliteCommand cmd = new SqliteCommand())
307 {
308 cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
309 cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
310
311 try
312 {
313 cmd.ExecuteNonQuery();
314 }
315 catch (Exception)
316 {
317 return false;
318 }
319 }
320
321 return true;
322 }
323 }
324} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs
index 1174e2f..8cb2ee0 100644
--- a/OpenSim/Data/Tests/AssetTests.cs
+++ b/OpenSim/Data/Tests/AssetTests.cs
@@ -49,7 +49,7 @@ using OpenSim.Data.SQLite;
49namespace OpenSim.Data.Tests 49namespace OpenSim.Data.Tests
50{ 50{
51 [TestFixture(Description = "Asset store tests (SQLite)")] 51 [TestFixture(Description = "Asset store tests (SQLite)")]
52 public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData> 52 public class SQLiteAssetTests : AssetTests<SqliteConnection, SQLiteAssetData>
53 { 53 {
54 } 54 }
55 55
diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs
index 7d85f0c..d8019ba 100644
--- a/OpenSim/Data/Tests/BasicDataServiceTest.cs
+++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs
@@ -33,6 +33,7 @@ using NUnit.Framework;
33using NUnit.Framework.Constraints; 33using NUnit.Framework.Constraints;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Tests.Common;
36using log4net; 37using log4net;
37using System.Data; 38using System.Data;
38using System.Data.Common; 39using System.Data.Common;
@@ -45,7 +46,7 @@ namespace OpenSim.Data.Tests
45 /// </summary> 46 /// </summary>
46 /// <typeparam name="TConn"></typeparam> 47 /// <typeparam name="TConn"></typeparam>
47 /// <typeparam name="TService"></typeparam> 48 /// <typeparam name="TService"></typeparam>
48 public class BasicDataServiceTest<TConn, TService> 49 public class BasicDataServiceTest<TConn, TService> : OpenSimTestCase
49 where TConn : DbConnection, new() 50 where TConn : DbConnection, new()
50 where TService : class, new() 51 where TService : class, new()
51 { 52 {
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 6c79bda..b99525a 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -36,6 +36,7 @@ using NUnit.Framework;
36using NUnit.Framework.Constraints; 36using NUnit.Framework.Constraints;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Tests.Common;
39 40
40namespace OpenSim.Data.Tests 41namespace OpenSim.Data.Tests
41{ 42{
@@ -254,7 +255,7 @@ namespace OpenSim.Data.Tests
254 } 255 }
255 256
256 [TestFixture] 257 [TestFixture]
257 public class PropertyCompareConstraintTest 258 public class PropertyCompareConstraintTest : OpenSimTestCase
258 { 259 {
259 public class HasInt 260 public class HasInt
260 { 261 {
diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index c5d40c2..e0f5862 100644
--- a/OpenSim/Data/Tests/PropertyScrambler.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -34,6 +34,7 @@ using System.Text;
34using NUnit.Framework; 34using NUnit.Framework;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Tests.Common;
37 38
38namespace OpenSim.Data.Tests 39namespace OpenSim.Data.Tests
39{ 40{
@@ -158,7 +159,7 @@ namespace OpenSim.Data.Tests
158 } 159 }
159 160
160 [TestFixture] 161 [TestFixture]
161 public class PropertyScramblerTests 162 public class PropertyScramblerTests : OpenSimTestCase
162 { 163 {
163 [Test] 164 [Test]
164 public void TestScramble() 165 public void TestScramble()