Changeset 9232
- Timestamp:
- 02/19/13 15:47:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs
r9219 r9232 263 263 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 264 264 author.AuthorizeForJob(id, Permission.Read); 265 var job = dao.GetJobs(x => 266 x.JobId == id 267 && (x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0) 268 ).FirstOrDefault(); 269 if (job != null) { 270 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 271 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 272 } 273 return job; 265 return trans.UseTransaction(() => { 266 var job = dao.GetJobs(x => 267 x.JobId == id 268 && (x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0) 269 ).FirstOrDefault(); 270 if (job != null) { 271 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 272 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 273 } 274 return job; 275 }); 274 276 } 275 277 276 278 public IEnumerable<Job> GetJobs() { 277 279 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 278 var jobs = dao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0); 279 foreach (var job in jobs) { 280 author.AuthorizeForJob(job.Id, Permission.Read); 281 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 282 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 283 } 284 return jobs; 280 return trans.UseTransaction(() => { 281 var jobs = dao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0); 282 foreach (var job in jobs) { 283 author.AuthorizeForJob(job.Id, Permission.Read); 284 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 285 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 286 } 287 return jobs; 288 }); 285 289 } 286 290 287 291 public IEnumerable<Job> GetAllJobs() { 288 292 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 289 var jobs = dao.GetJobs(x => true); 290 foreach (var job in jobs) { // no authorization here, since this method is admin-only! (admin is allowed to read all task) 291 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 292 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 293 } 294 return jobs; 293 return trans.UseTransaction(() => { 294 var jobs = dao.GetJobs(x => true); 295 foreach (var job in jobs) { // no authorization here, since this method is admin-only! (admin is allowed to read all task) 296 job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId)); 297 job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName; 298 } 299 return jobs; 300 }); 295 301 } 296 302
Note: See TracChangeset
for help on using the changeset viewer.