mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
Replace several usages of allMembers() with count methods to avoid performance issues
This commit is contained in:
@@ -305,10 +305,13 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
|
||||
throw new AuthorizeException(
|
||||
"You must be an admin to delete an EPerson");
|
||||
}
|
||||
// Get all workflow-related groups that the current EPerson belongs to
|
||||
Set<Group> workFlowGroups = getAllWorkFlowGroups(context, ePerson);
|
||||
for (Group group: workFlowGroups) {
|
||||
List<EPerson> ePeople = groupService.allMembers(context, group);
|
||||
if (ePeople.size() == 1 && ePeople.contains(ePerson)) {
|
||||
// Get total number of unique EPerson objs who are a member of this group (or subgroup)
|
||||
int totalMembers = groupService.countAllMembers(context, group);
|
||||
// If only one EPerson is a member, then we cannot delete the last member of this group.
|
||||
if (totalMembers == 1) {
|
||||
throw new EmptyWorkflowGroupException(ePerson.getID(), group.getID());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user