aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs14
-rw-r--r--OpenSim/Data/NHibernate/NHibernateInventoryData.cs46
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs40
3 files changed, 50 insertions, 50 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index e52f633..875f4e5 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -97,14 +97,14 @@ namespace OpenSim.Data.NHibernate
97 string regex = @"no such table: Assets"; 97 string regex = @"no such table: Assets";
98 Regex RE = new Regex(regex, RegexOptions.Multiline); 98 Regex RE = new Regex(regex, RegexOptions.Multiline);
99 try { 99 try {
100 using(ISession session = factory.OpenSession()) { 100 using (ISession session = factory.OpenSession()) {
101 session.Load(typeof(AssetBase), LLUUID.Zero); 101 session.Load(typeof(AssetBase), LLUUID.Zero);
102 } 102 }
103 } catch (ObjectNotFoundException) { 103 } catch (ObjectNotFoundException) {
104 // yes, we know it's not there, but that's ok 104 // yes, we know it's not there, but that's ok
105 } catch (ADOException e) { 105 } catch (ADOException e) {
106 Match m = RE.Match(e.ToString()); 106 Match m = RE.Match(e.ToString());
107 if(m.Success) { 107 if (m.Success) {
108 // We don't have this table, so create it. 108 // We don't have this table, so create it.
109 new SchemaExport(cfg).Create(true, true); 109 new SchemaExport(cfg).Create(true, true);
110 } 110 }
@@ -113,7 +113,7 @@ namespace OpenSim.Data.NHibernate
113 113
114 override public AssetBase FetchAsset(LLUUID uuid) 114 override public AssetBase FetchAsset(LLUUID uuid)
115 { 115 {
116 using(ISession session = factory.OpenSession()) { 116 using (ISession session = factory.OpenSession()) {
117 try { 117 try {
118 return session.Load(typeof(AssetBase), uuid) as AssetBase; 118 return session.Load(typeof(AssetBase), uuid) as AssetBase;
119 } catch { 119 } catch {
@@ -125,8 +125,8 @@ namespace OpenSim.Data.NHibernate
125 override public void CreateAsset(AssetBase asset) 125 override public void CreateAsset(AssetBase asset)
126 { 126 {
127 if (!ExistsAsset(asset.FullID)) { 127 if (!ExistsAsset(asset.FullID)) {
128 using(ISession session = factory.OpenSession()) { 128 using (ISession session = factory.OpenSession()) {
129 using(ITransaction transaction = session.BeginTransaction()) { 129 using (ITransaction transaction = session.BeginTransaction()) {
130 session.Save(asset); 130 session.Save(asset);
131 transaction.Commit(); 131 transaction.Commit();
132 } 132 }
@@ -137,8 +137,8 @@ namespace OpenSim.Data.NHibernate
137 override public void UpdateAsset(AssetBase asset) 137 override public void UpdateAsset(AssetBase asset)
138 { 138 {
139 if (ExistsAsset(asset.FullID)) { 139 if (ExistsAsset(asset.FullID)) {
140 using(ISession session = factory.OpenSession()) { 140 using (ISession session = factory.OpenSession()) {
141 using(ITransaction transaction = session.BeginTransaction()) { 141 using (ITransaction transaction = session.BeginTransaction()) {
142 session.Update(asset); 142 session.Update(asset);
143 transaction.Commit(); 143 transaction.Commit();
144 } 144 }
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index f8e3655..6ee1b4a 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -95,14 +95,14 @@ namespace OpenSim.Data.NHibernate
95 string regex = @"no such table: Inventory"; 95 string regex = @"no such table: Inventory";
96 Regex RE = new Regex(regex, RegexOptions.Multiline); 96 Regex RE = new Regex(regex, RegexOptions.Multiline);
97 try { 97 try {
98 using(ISession session = factory.OpenSession()) { 98 using (ISession session = factory.OpenSession()) {
99 session.Load(typeof(InventoryItemBase), LLUUID.Zero); 99 session.Load(typeof(InventoryItemBase), LLUUID.Zero);
100 } 100 }
101 } catch (ObjectNotFoundException) { 101 } catch (ObjectNotFoundException) {
102 // yes, we know it's not there, but that's ok 102 // yes, we know it's not there, but that's ok
103 } catch (ADOException e) { 103 } catch (ADOException e) {
104 Match m = RE.Match(e.ToString()); 104 Match m = RE.Match(e.ToString());
105 if(m.Success) { 105 if (m.Success) {
106 // We don't have this table, so create it. 106 // We don't have this table, so create it.
107 new SchemaExport(cfg).Create(true, true); 107 new SchemaExport(cfg).Create(true, true);
108 } 108 }
@@ -125,7 +125,7 @@ namespace OpenSim.Data.NHibernate
125 /// <returns>A class containing item information</returns> 125 /// <returns>A class containing item information</returns>
126 public InventoryItemBase getInventoryItem(LLUUID item) 126 public InventoryItemBase getInventoryItem(LLUUID item)
127 { 127 {
128 using(ISession session = factory.OpenSession()) { 128 using (ISession session = factory.OpenSession()) {
129 try { 129 try {
130 return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase; 130 return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase;
131 } catch { 131 } catch {
@@ -142,8 +142,8 @@ namespace OpenSim.Data.NHibernate
142 public void addInventoryItem(InventoryItemBase item) 142 public void addInventoryItem(InventoryItemBase item)
143 { 143 {
144 if (!ExistsItem(item.ID)) { 144 if (!ExistsItem(item.ID)) {
145 using(ISession session = factory.OpenSession()) { 145 using (ISession session = factory.OpenSession()) {
146 using(ITransaction transaction = session.BeginTransaction()) { 146 using (ITransaction transaction = session.BeginTransaction()) {
147 session.Save(item); 147 session.Save(item);
148 transaction.Commit(); 148 transaction.Commit();
149 } 149 }
@@ -161,8 +161,8 @@ namespace OpenSim.Data.NHibernate
161 public void updateInventoryItem(InventoryItemBase item) 161 public void updateInventoryItem(InventoryItemBase item)
162 { 162 {
163 if (ExistsItem(item.ID)) { 163 if (ExistsItem(item.ID)) {
164 using(ISession session = factory.OpenSession()) { 164 using (ISession session = factory.OpenSession()) {
165 using(ITransaction transaction = session.BeginTransaction()) { 165 using (ITransaction transaction = session.BeginTransaction()) {
166 session.Update(item); 166 session.Update(item);
167 transaction.Commit(); 167 transaction.Commit();
168 } 168 }
@@ -178,8 +178,8 @@ namespace OpenSim.Data.NHibernate
178 /// <param name="item"></param> 178 /// <param name="item"></param>
179 public void deleteInventoryItem(LLUUID itemID) 179 public void deleteInventoryItem(LLUUID itemID)
180 { 180 {
181 using(ISession session = factory.OpenSession()) { 181 using (ISession session = factory.OpenSession()) {
182 using(ITransaction transaction = session.BeginTransaction()) { 182 using (ITransaction transaction = session.BeginTransaction()) {
183 session.Delete(itemID); 183 session.Delete(itemID);
184 transaction.Commit(); 184 transaction.Commit();
185 } 185 }
@@ -194,7 +194,7 @@ namespace OpenSim.Data.NHibernate
194 /// <returns>A class containing folder information</returns> 194 /// <returns>A class containing folder information</returns>
195 public InventoryFolderBase getInventoryFolder(LLUUID folder) 195 public InventoryFolderBase getInventoryFolder(LLUUID folder)
196 { 196 {
197 using(ISession session = factory.OpenSession()) { 197 using (ISession session = factory.OpenSession()) {
198 try { 198 try {
199 return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase; 199 return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase;
200 } catch { 200 } catch {
@@ -211,8 +211,8 @@ namespace OpenSim.Data.NHibernate
211 public void addInventoryFolder(InventoryFolderBase folder) 211 public void addInventoryFolder(InventoryFolderBase folder)
212 { 212 {
213 if (!ExistsFolder(folder.ID)) { 213 if (!ExistsFolder(folder.ID)) {
214 using(ISession session = factory.OpenSession()) { 214 using (ISession session = factory.OpenSession()) {
215 using(ITransaction transaction = session.BeginTransaction()) { 215 using (ITransaction transaction = session.BeginTransaction()) {
216 session.Save(folder); 216 session.Save(folder);
217 transaction.Commit(); 217 transaction.Commit();
218 } 218 }
@@ -230,8 +230,8 @@ namespace OpenSim.Data.NHibernate
230 public void updateInventoryFolder(InventoryFolderBase folder) 230 public void updateInventoryFolder(InventoryFolderBase folder)
231 { 231 {
232 if (ExistsFolder(folder.ID)) { 232 if (ExistsFolder(folder.ID)) {
233 using(ISession session = factory.OpenSession()) { 233 using (ISession session = factory.OpenSession()) {
234 using(ITransaction transaction = session.BeginTransaction()) { 234 using (ITransaction transaction = session.BeginTransaction()) {
235 session.Update(folder); 235 session.Update(folder);
236 transaction.Commit(); 236 transaction.Commit();
237 } 237 }
@@ -247,8 +247,8 @@ namespace OpenSim.Data.NHibernate
247 /// <param name="folder"></param> 247 /// <param name="folder"></param>
248 public void deleteInventoryFolder(LLUUID folderID) 248 public void deleteInventoryFolder(LLUUID folderID)
249 { 249 {
250 using(ISession session = factory.OpenSession()) { 250 using (ISession session = factory.OpenSession()) {
251 using(ITransaction transaction = session.BeginTransaction()) { 251 using (ITransaction transaction = session.BeginTransaction()) {
252 session.Delete(folderID.ToString()); 252 session.Delete(folderID.ToString());
253 transaction.Commit(); 253 transaction.Commit();
254 } 254 }
@@ -324,10 +324,10 @@ namespace OpenSim.Data.NHibernate
324 /// <returns>A List of InventoryItemBase items</returns> 324 /// <returns>A List of InventoryItemBase items</returns>
325 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) 325 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
326 { 326 {
327 using(ISession session = factory.OpenSession()) { 327 using (ISession session = factory.OpenSession()) {
328 // try { 328 // try {
329 ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase)); 329 ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
330 criteria.Add(Expression.Eq("Folder", folderID) ); 330 criteria.Add(Expression.Eq("Folder", folderID));
331 List<InventoryItemBase> list = new List<InventoryItemBase>(); 331 List<InventoryItemBase> list = new List<InventoryItemBase>();
332 foreach (InventoryItemBase item in criteria.List()) 332 foreach (InventoryItemBase item in criteria.List())
333 { 333 {
@@ -348,11 +348,11 @@ namespace OpenSim.Data.NHibernate
348 // see InventoryItemBase.getUserRootFolder 348 // see InventoryItemBase.getUserRootFolder
349 public InventoryFolderBase getUserRootFolder(LLUUID user) 349 public InventoryFolderBase getUserRootFolder(LLUUID user)
350 { 350 {
351 using(ISession session = factory.OpenSession()) { 351 using (ISession session = factory.OpenSession()) {
352 // try { 352 // try {
353 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase)); 353 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
354 criteria.Add(Expression.Eq("ParentID", LLUUID.Zero) ); 354 criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
355 criteria.Add(Expression.Eq("Owner", user) ); 355 criteria.Add(Expression.Eq("Owner", user));
356 foreach (InventoryFolderBase folder in criteria.List()) 356 foreach (InventoryFolderBase folder in criteria.List())
357 { 357 {
358 return folder; 358 return folder;
@@ -372,10 +372,10 @@ namespace OpenSim.Data.NHibernate
372 /// <param name="parentID">ID of parent</param> 372 /// <param name="parentID">ID of parent</param>
373 private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID) 373 private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
374 { 374 {
375 using(ISession session = factory.OpenSession()) { 375 using (ISession session = factory.OpenSession()) {
376 // try { 376 // try {
377 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase)); 377 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
378 criteria.Add(Expression.Eq("ParentID", parentID) ); 378 criteria.Add(Expression.Eq("ParentID", parentID));
379 foreach (InventoryFolderBase item in criteria.List()) 379 foreach (InventoryFolderBase item in criteria.List())
380 { 380 {
381 folders.Add(item); 381 folders.Add(item);
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index e680840..2c84ef9 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -88,14 +88,14 @@ namespace OpenSim.Data.NHibernate
88 string regex = @"no such table: UserProfiles"; 88 string regex = @"no such table: UserProfiles";
89 Regex RE = new Regex(regex, RegexOptions.Multiline); 89 Regex RE = new Regex(regex, RegexOptions.Multiline);
90 try { 90 try {
91 using(ISession session = factory.OpenSession()) { 91 using (ISession session = factory.OpenSession()) {
92 session.Load(typeof(UserProfileData), LLUUID.Zero); 92 session.Load(typeof(UserProfileData), LLUUID.Zero);
93 } 93 }
94 } catch (ObjectNotFoundException) { 94 } catch (ObjectNotFoundException) {
95 // yes, we know it's not there, but that's ok 95 // yes, we know it's not there, but that's ok
96 } catch (ADOException e) { 96 } catch (ADOException e) {
97 Match m = RE.Match(e.ToString()); 97 Match m = RE.Match(e.ToString());
98 if(m.Success) { 98 if (m.Success) {
99 // We don't have this table, so create it. 99 // We don't have this table, so create it.
100 new SchemaExport(cfg).Create(true, true); 100 new SchemaExport(cfg).Create(true, true);
101 } 101 }
@@ -106,7 +106,7 @@ namespace OpenSim.Data.NHibernate
106 { 106 {
107 UserProfileData user = null; 107 UserProfileData user = null;
108 try { 108 try {
109 using(ISession session = factory.OpenSession()) { 109 using (ISession session = factory.OpenSession()) {
110 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; 110 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
111 } 111 }
112 // BUG: CATCHALL IS BAD. 112 // BUG: CATCHALL IS BAD.
@@ -119,7 +119,7 @@ namespace OpenSim.Data.NHibernate
119 { 119 {
120 UserProfileData user; 120 UserProfileData user;
121 // TODO: I'm sure I'll have to do something silly here 121 // TODO: I'm sure I'll have to do something silly here
122 using(ISession session = factory.OpenSession()) { 122 using (ISession session = factory.OpenSession()) {
123 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; 123 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
124 user.CurrentAgent = GetAgentByUUID(uuid); 124 user.CurrentAgent = GetAgentByUUID(uuid);
125 } 125 }
@@ -129,8 +129,8 @@ namespace OpenSim.Data.NHibernate
129 override public void AddNewUserProfile(UserProfileData profile) 129 override public void AddNewUserProfile(UserProfileData profile)
130 { 130 {
131 if (!ExistsUser(profile.ID)) { 131 if (!ExistsUser(profile.ID)) {
132 using(ISession session = factory.OpenSession()) { 132 using (ISession session = factory.OpenSession()) {
133 using(ITransaction transaction = session.BeginTransaction()) { 133 using (ITransaction transaction = session.BeginTransaction()) {
134 session.Save(profile); 134 session.Save(profile);
135 SetAgentData(profile.ID, profile.CurrentAgent, session); 135 SetAgentData(profile.ID, profile.CurrentAgent, session);
136 // TODO: save agent 136 // TODO: save agent
@@ -166,8 +166,8 @@ namespace OpenSim.Data.NHibernate
166 override public bool UpdateUserProfile(UserProfileData profile) 166 override public bool UpdateUserProfile(UserProfileData profile)
167 { 167 {
168 if (ExistsUser(profile.ID)) { 168 if (ExistsUser(profile.ID)) {
169 using(ISession session = factory.OpenSession()) { 169 using (ISession session = factory.OpenSession()) {
170 using(ITransaction transaction = session.BeginTransaction()) { 170 using (ITransaction transaction = session.BeginTransaction()) {
171 session.Update(profile); 171 session.Update(profile);
172 SetAgentData(profile.ID, profile.CurrentAgent, session); 172 SetAgentData(profile.ID, profile.CurrentAgent, session);
173 transaction.Commit(); 173 transaction.Commit();
@@ -183,8 +183,8 @@ namespace OpenSim.Data.NHibernate
183 183
184 override public void AddNewUserAgent(UserAgentData agent) 184 override public void AddNewUserAgent(UserAgentData agent)
185 { 185 {
186 using(ISession session = factory.OpenSession()) { 186 using (ISession session = factory.OpenSession()) {
187 using(ITransaction transaction = session.BeginTransaction()) { 187 using (ITransaction transaction = session.BeginTransaction()) {
188 session.Save(agent); 188 session.Save(agent);
189 transaction.Commit(); 189 transaction.Commit();
190 } 190 }
@@ -193,8 +193,8 @@ namespace OpenSim.Data.NHibernate
193 193
194 public void UpdateUserAgent(UserAgentData agent) 194 public void UpdateUserAgent(UserAgentData agent)
195 { 195 {
196 using(ISession session = factory.OpenSession()) { 196 using (ISession session = factory.OpenSession()) {
197 using(ITransaction transaction = session.BeginTransaction()) { 197 using (ITransaction transaction = session.BeginTransaction()) {
198 session.Update(agent); 198 session.Update(agent);
199 transaction.Commit(); 199 transaction.Commit();
200 } 200 }
@@ -206,7 +206,7 @@ namespace OpenSim.Data.NHibernate
206 override public UserAgentData GetAgentByUUID(LLUUID uuid) 206 override public UserAgentData GetAgentByUUID(LLUUID uuid)
207 { 207 {
208 try { 208 try {
209 using(ISession session = factory.OpenSession()) { 209 using (ISession session = factory.OpenSession()) {
210 return session.Load(typeof(UserAgentData), uuid) as UserAgentData; 210 return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
211 } 211 }
212 } catch { 212 } catch {
@@ -216,7 +216,7 @@ namespace OpenSim.Data.NHibernate
216 216
217 override public UserProfileData GetUserByName(string fname, string lname) 217 override public UserProfileData GetUserByName(string fname, string lname)
218 { 218 {
219 using(ISession session = factory.OpenSession()) { 219 using (ISession session = factory.OpenSession()) {
220 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); 220 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
221 criteria.Add(Expression.Eq("FirstName", fname)); 221 criteria.Add(Expression.Eq("FirstName", fname));
222 criteria.Add(Expression.Eq("SurName", lname)); 222 criteria.Add(Expression.Eq("SurName", lname));
@@ -247,11 +247,11 @@ namespace OpenSim.Data.NHibernate
247 247
248 if (querysplit.Length == 2) 248 if (querysplit.Length == 2)
249 { 249 {
250 using(ISession session = factory.OpenSession()) { 250 using (ISession session = factory.OpenSession()) {
251 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); 251 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
252 criteria.Add(Expression.Like("FirstName", querysplit[0])); 252 criteria.Add(Expression.Like("FirstName", querysplit[0]));
253 criteria.Add(Expression.Like("SurName", querysplit[1])); 253 criteria.Add(Expression.Like("SurName", querysplit[1]));
254 foreach(UserProfileData profile in criteria.List()) 254 foreach (UserProfileData profile in criteria.List())
255 { 255 {
256 AvatarPickerAvatar user = new AvatarPickerAvatar(); 256 AvatarPickerAvatar user = new AvatarPickerAvatar();
257 user.AvatarID = profile.ID; 257 user.AvatarID = profile.ID;
@@ -280,7 +280,7 @@ namespace OpenSim.Data.NHibernate
280 { 280 {
281 UserAppearance appearance; 281 UserAppearance appearance;
282 // TODO: I'm sure I'll have to do something silly here 282 // TODO: I'm sure I'll have to do something silly here
283 using(ISession session = factory.OpenSession()) { 283 using (ISession session = factory.OpenSession()) {
284 appearance = session.Load(typeof(UserAppearance), user) as UserAppearance; 284 appearance = session.Load(typeof(UserAppearance), user) as UserAppearance;
285 } 285 }
286 return appearance; 286 return appearance;
@@ -289,7 +289,7 @@ namespace OpenSim.Data.NHibernate
289 private bool ExistsAppearance(LLUUID uuid) 289 private bool ExistsAppearance(LLUUID uuid)
290 { 290 {
291 UserAppearance appearance; 291 UserAppearance appearance;
292 using(ISession session = factory.OpenSession()) { 292 using (ISession session = factory.OpenSession()) {
293 appearance = session.Load(typeof(UserAppearance), uuid) as UserAppearance; 293 appearance = session.Load(typeof(UserAppearance), uuid) as UserAppearance;
294 } 294 }
295 return (appearance == null) ? false : true; 295 return (appearance == null) ? false : true;
@@ -299,8 +299,8 @@ namespace OpenSim.Data.NHibernate
299 override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance) 299 override public void UpdateUserAppearance(LLUUID user, UserAppearance appearance)
300 { 300 {
301 bool exists = ExistsAppearance(user); 301 bool exists = ExistsAppearance(user);
302 using(ISession session = factory.OpenSession()) { 302 using (ISession session = factory.OpenSession()) {
303 using(ITransaction transaction = session.BeginTransaction()) { 303 using (ITransaction transaction = session.BeginTransaction()) {
304 if (exists) { 304 if (exists) {
305 session.Update(appearance); 305 session.Update(appearance);
306 } else { 306 } else {