Skip to content
Snippets Groups Projects
Commit 4fcb2b10 authored by juanf's avatar juanf
Browse files

SSDM-14261 : Slow user roles filtering

parent 23e59020
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -1553,6 +1553,41 @@ public class UserManager ...@@ -1553,6 +1553,41 @@ public class UserManager
} }
if (roleCreations.isEmpty() == false) if (roleCreations.isEmpty() == false)
{ {
// Filter out already existing roles to not repeat creations
// This is to manage a corner case when a user role has been added manually unnecessarily.
List<RoleAssignmentCreation> filteredRoleCreations = new ArrayList<>();
for (RoleAssignmentCreation roleAssignmentCreationToCheck : roleCreations)
{
PersonPermId userId = (PersonPermId) roleAssignmentCreationToCheck.getUserId();
SpacePermId spaceId = (SpacePermId) roleAssignmentCreationToCheck.getSpaceId();
RoleAssignmentSearchCriteria roleAssignmentSearchCriteria =
new RoleAssignmentSearchCriteria();
roleAssignmentSearchCriteria.withUser().withUserId()
.thatEquals(userId.getPermId());
roleAssignmentSearchCriteria.withSpace().withCode()
.thatEquals(spaceId.getPermId());
SearchResult<RoleAssignment> roleAssignmentSearchResult =
service.searchRoleAssignments(sessionToken,
roleAssignmentSearchCriteria, new RoleAssignmentFetchOptions());
boolean found = false;
if (!roleAssignmentSearchResult.getObjects().isEmpty())
{
Role role = roleAssignmentCreationToCheck.getRole();
for (RoleAssignment roleAssignment : roleAssignmentSearchResult.getObjects())
{
if (roleAssignment.getRole().equals(role))
{
found = true;
}
}
}
if (!found)
{
filteredRoleCreations.add(roleAssignmentCreationToCheck);
}
}
roleCreations = filteredRoleCreations;
operations.add(new CreateRoleAssignmentsOperation(roleCreations)); operations.add(new CreateRoleAssignmentsOperation(roleCreations));
} }
if (roleDeletions.isEmpty() == false) if (roleDeletions.isEmpty() == false)
......
  • juanf @juanf

    mentioned in commit afc7467e

    ·

    mentioned in commit afc7467e

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment