- Timestamp:
- 07/02/18 15:51:17 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15969 r15978 43 43 private const string NOT_AUTHORIZED_PROJECTRESOURCE = "Selected project is not authorized to access the requested resource"; 44 44 private const string NOT_AUTHORIZED_USERPROJECT = "Current user is not authorized to access the requested project"; 45 private const string NO_JOB_UPDATE_POSSIBLE = "This job has already been flagged for deletion, thus, it can not be updated anymore."; 45 46 46 47 private static readonly DA.TaskState[] CompletedStates = { DA.TaskState.Finished, DA.TaskState.Aborted, DA.TaskState.Failed }; … … 465 466 exists = false; 466 467 job = new DA.Job(); 467 } 468 } else if(job.State != DA.JobState.Online) { 469 throw new InvalidOperationException(NO_JOB_UPDATE_POSSIBLE); 470 } 471 472 468 473 jobDto.CopyToEntity(job); 469 474 … … 539 544 540 545 var pm = PersistenceManager; 541 using (new PerformanceLogger("UpdateJob sState")) {546 using (new PerformanceLogger("UpdateJobStates")) { 542 547 var jobDao = pm.JobDao; 543 548 var projectDao = pm.ProjectDao; … … 802 807 pm.UseTransaction(() => { 803 808 var project = projectDao.GetById(projectDto.Id); 804 if (project != null) { // update existent 809 if (project != null) { // update existent project 805 810 var formerOwnerId = project.OwnerUserId; 806 811 projectDto.CopyToEntity(project); … … 808 813 // if owner has changed... 809 814 if(formerOwnerId != projectDto.OwnerUserId) { 810 var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault(); 811 if (formerPermissionItem != null) { 812 // remove permissions 813 project.ProjectPermissions.Remove(formerPermissionItem); 814 // remove jobs if former owner is no member of a still permitted group 815 var ugt = GetUserGroupTree(); 816 var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids 817 // get all member-Guids of all still permitted groups 818 foreach (var item in project.ProjectPermissions) { 819 permittedGuids.Add(item.GrantedUserId); 820 if(ugt.ContainsKey(item.GrantedUserId)) { 821 ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x)); 822 } 823 824 // check if former owner Guid is in Member-Guids 825 // if yes: do nothing, if not do: 826 if (!permittedGuids.Contains(formerOwnerId)) { 827 assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId }); 828 } 829 } 815 // OBSOLETE: former owner looses permission and project-related jobs 816 //var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault(); 817 //if (formerPermissionItem != null) { 818 // // remove permissions 819 // project.ProjectPermissions.Remove(formerPermissionItem); 820 // // remove jobs if former owner is no member of a still permitted group 821 // var ugt = GetUserGroupTree(); 822 // var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids 823 // // get all member-Guids of all still permitted groups 824 // foreach (var item in project.ProjectPermissions) { 825 // permittedGuids.Add(item.GrantedUserId); 826 // if(ugt.ContainsKey(item.GrantedUserId)) { 827 // ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x)); 828 // } 829 830 // // check if former owner Guid is in Member-Guids 831 // // if yes: do nothing, if not do: 832 // if (!permittedGuids.Contains(formerOwnerId)) { 833 // assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId }); 834 // } 835 // } 836 //} 837 // Add permission for new owner if not already done 838 if(!project.ProjectPermissions 839 .Select(pp => pp.GrantedUserId) 840 .Contains(projectDto.OwnerUserId)) { 841 project.ProjectPermissions.Add(new DA.ProjectPermission { 842 GrantedUserId = projectDto.OwnerUserId, 843 GrantedByUserId = UserManager.CurrentUserId 844 }); 830 845 } 831 project.ProjectPermissions.Add(new DA.ProjectPermission {832 GrantedUserId = projectDto.OwnerUserId,833 GrantedByUserId = UserManager.CurrentUserId834 });835 846 } 836 847 837 } else { // save new 848 } else { // save new project 838 849 var newProject = projectDao.Save(projectDto.ToEntity()); 839 850 newProject.ProjectPermissions.Clear(); … … 953 964 } 954 965 return projectAncestors; 966 }); 967 } 968 } 969 970 public IDictionary<Guid, string> GetProjectNames() { 971 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 972 var pm = PersistenceManager; 973 using (new PerformanceLogger("GetProjectNames")) { 974 var projectDao = pm.ProjectDao; 975 var projectNames = new Dictionary<Guid, string>(); 976 return pm.UseTransaction(() => { 977 projectDao 978 .GetAll().ToList() 979 .ForEach(p=> projectNames.Add(p.ProjectId, p.Name)); 980 return projectNames; 955 981 }); 956 982 } -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r15969 r15978 166 166 [OperationContract] 167 167 IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy(); 168 169 [OperationContract] 170 IDictionary<Guid, string> GetProjectNames(); 168 171 #endregion 169 172
Note: See TracChangeset
for help on using the changeset viewer.