aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateUserData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs72
1 files changed, 40 insertions, 32 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index 3b67d6e..bb11e59 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -91,8 +91,9 @@ namespace OpenSim.Data.NHibernate
91 { 91 {
92 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; 92 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
93 } 93 }
94 catch (Exception) 94 catch (ObjectNotFoundException e)
95 { 95 {
96 user = null;
96 } 97 }
97 98
98 return (user != null); 99 return (user != null);
@@ -102,8 +103,15 @@ namespace OpenSim.Data.NHibernate
102 { 103 {
103 UserProfileData user; 104 UserProfileData user;
104 // TODO: I'm sure I'll have to do something silly here 105 // TODO: I'm sure I'll have to do something silly here
105 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; 106 try
106 user.CurrentAgent = GetAgentByUUID(uuid); 107 {
108 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
109 user.CurrentAgent = GetAgentByUUID(uuid);
110 }
111 catch (ObjectNotFoundException e)
112 {
113 user = null;
114 }
107 115
108 return user; 116 return user;
109 } 117 }
@@ -114,8 +122,6 @@ namespace OpenSim.Data.NHibernate
114 { 122 {
115 session.Save(profile); 123 session.Save(profile);
116 SetAgentData(profile.ID, profile.CurrentAgent); 124 SetAgentData(profile.ID, profile.CurrentAgent);
117 // TODO: save agent
118 session.Transaction.Commit();
119 } 125 }
120 else 126 else
121 { 127 {
@@ -132,12 +138,14 @@ namespace OpenSim.Data.NHibernate
132 } 138 }
133 else 139 else
134 { 140 {
135 UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData; 141 try
136 if (old != null)
137 { 142 {
143 UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData;
138 session.Delete(old); 144 session.Delete(old);
139 } 145 }
140 146 catch (ObjectNotFoundException e)
147 {
148 }
141 session.Save(agent); 149 session.Save(agent);
142 } 150 }
143 151
@@ -148,7 +156,6 @@ namespace OpenSim.Data.NHibernate
148 { 156 {
149 session.Update(profile); 157 session.Update(profile);
150 SetAgentData(profile.ID, profile.CurrentAgent); 158 SetAgentData(profile.ID, profile.CurrentAgent);
151 session.Transaction.Commit();
152 return true; 159 return true;
153 } 160 }
154 else 161 else
@@ -161,23 +168,20 @@ namespace OpenSim.Data.NHibernate
161 168
162 override public void AddNewUserAgent(UserAgentData agent) 169 override public void AddNewUserAgent(UserAgentData agent)
163 { 170 {
164 UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData; 171 try
165
166 if (old == null)
167 { 172 {
168 session.Save(agent); 173 UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData;
169 session.Transaction.Commit(); 174 session.Delete(old);
170 } 175 }
171 else 176 catch (ObjectNotFoundException e)
172 { 177 {
173 UpdateUserAgent(agent);
174 } 178 }
179 session.Save(agent);
175 } 180 }
176 181
177 public void UpdateUserAgent(UserAgentData agent) 182 public void UpdateUserAgent(UserAgentData agent)
178 { 183 {
179 session.Update(agent); 184 session.Update(agent);
180 session.Transaction.Commit();
181 } 185 }
182 186
183 override public UserAgentData GetAgentByUUID(LLUUID uuid) 187 override public UserAgentData GetAgentByUUID(LLUUID uuid)
@@ -254,16 +258,22 @@ namespace OpenSim.Data.NHibernate
254 { 258 {
255 AvatarAppearance appearance; 259 AvatarAppearance appearance;
256 // TODO: I'm sure I'll have to do something silly here 260 // TODO: I'm sure I'll have to do something silly here
257 appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance; 261 try {
258 262 appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
263 } catch (ObjectNotFoundException e) {
264 appearance = null;
265 }
259 return appearance; 266 return appearance;
260 } 267 }
261 268
262 private bool ExistsAppearance(LLUUID uuid) 269 private bool ExistsAppearance(LLUUID uuid)
263 { 270 {
264 AvatarAppearance appearance; 271 AvatarAppearance appearance;
265 272 try {
266 appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance; 273 appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance;
274 } catch (ObjectNotFoundException e) {
275 appearance = null;
276 }
267 277
268 return (appearance == null) ? false : true; 278 return (appearance == null) ? false : true;
269 } 279 }
@@ -271,19 +281,17 @@ namespace OpenSim.Data.NHibernate
271 281
272 public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) 282 public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
273 { 283 {
284 if (appearance == null)
285 return;
286
274 bool exists = ExistsAppearance(user); 287 bool exists = ExistsAppearance(user);
275 288 if (exists)
276 using (ITransaction transaction = session.BeginTransaction())
277 { 289 {
278 if (exists) 290 session.Update(appearance);
279 { 291 }
280 session.Update(appearance); 292 else
281 } 293 {
282 else 294 session.Save(appearance);
283 {
284 session.Save(appearance);
285 }
286 transaction.Commit();
287 } 295 }
288 } 296 }
289 297