Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/07/17 14:41:47 (7 years ago)
Author:
jzenisek
Message:

#2839 worked on resource permission checks (v2 = accelerated verison)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15497 r15500  
    7575        var resourceDao = pm.ResourceDao;
    7676        var resourcePermissionDao = pm.ResourcePermissionDao;
    77 
    7877        var currentUserId = UserManager.CurrentUserId;
    7978
    80         // V1 (without child check; with resourcePermission-oriented check for user grants)
    81         // granted (parent) resources
    82         var userGrantedResources = resourcePermissionDao.GetAll().ToList()
    83           .Where(x => x.GrantedUserId == currentUserId
    84           || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId })
    85           )
    86           .Select(x => x.Resource)
    87           .ToList();
    88 
    89         //// children
    90         //var userGrantedResourceChildren = userGrantedResources
    91         //  .SelectMany(x => resourceDao.GetResourcesByParentId(x.ResourceId));
    92         //// join parent and child resources
    93         //userGrantedResources.AddRange(userGrantedResourceChildren);
    94 
    95         var userGrantedResourceIds = resourceIds
    96           .Where(x => userGrantedResources
    97             .Select(y => y.ResourceId)
    98             .Contains(x))
    99           .Distinct().ToList();
     79        //// V1 user grant check
     80        //// get granted (parent) resources
     81        //var userGrantedResourceIds = pm.UseTransaction(() => {
     82        //  return resourcePermissionDao.GetAll().ToList()
     83        //    .Where(x => x.GrantedUserId == currentUserId
     84        //      || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId }))
     85        //    .Select(y => y.ResourceId)
     86        //    .ToList();
     87        //});
     88
     89        //// get children of granted parent resources
     90        //var userGrantedChildResourceIds = pm.UseTransaction(() => {
     91        //  return userGrantedResourceIds
     92        //  .SelectMany(x => resourceDao.GetResourcesByParentId(x))
     93        //  .Select(y => y.ResourceId);
     94        //});
     95
     96        //// join list of parent and child resources
     97        //userGrantedResourceIds.AddRange(userGrantedChildResourceIds);
     98
     99        //// filter initial resourceId list with the list of the granted ones
     100        //var allUserGrantedResourceIds = resourceIds
     101        //  .Where(x => userGrantedResourceIds.Contains(x))
     102        //  .Distinct().ToList();
     103
     104        // V2 user grant check
     105        var allUserGrantedResourceIds = pm.UseTransaction(() => {
     106          var groupAndGroupIds = new List<Guid> { currentUserId };
     107          groupAndGroupIds.AddRange(UserManager.GetUserGroupIdsOfUser(currentUserId));
     108          return resourcePermissionDao.GetByUserAndGroupIds(groupAndGroupIds);
     109        });
    100110
    101111        var newTask = task.ToEntity();
    102112        newTask.JobData = taskData.ToEntity();
    103113        newTask.JobData.LastUpdate = DateTime.Now;
    104         newTask.AssignedTaskResources.AddRange(resourceIds.Select(
     114        newTask.AssignedTaskResources.AddRange(allUserGrantedResourceIds.Select(
    105115          x => new DA.AssignedTaskResource {
    106116            ResourceId = x
Note: See TracChangeset for help on using the changeset viewer.