Skip to content

Commit

Permalink
fix : user synchronizer if only reviewer and not both
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Nov 20, 2024
1 parent 195790a commit a99ad21
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,22 @@ private void synchronizeUserGroups(User user, List<Privilege> privileges) {
}

private List<UserGroup> resolveNewPrivileges(User user, List<Privilege> actual) {
List<Privilege> editors = actual.stream().filter(privilege -> privilege.getProfile() == Profile.Reviewer)//
.map(privilege -> {

List<Privilege> editors = actual.stream().filter(privilege -> privilege.getProfile() == Profile.Reviewer || privilege.getProfile() == Profile.Editor)
// group by geonetwork group
.collect(Collectors.groupingBy(Privilege::getGroup))//
.values().stream()//
// check if both reviewer and editor are present for the same group and profile is only reviewer
.filter(privileges -> privileges.size() == 1 && privileges.get(0).getProfile() == Profile.Reviewer)
// get first privilege (reviewer)
.map(privileges -> privileges.get(0))
// create a new privilege with editor profile
.map(privilege -> {
log.debug("User {} is a reviewer of group {}", user.getUsername(),
privilege.getGroup().getName());
return new Privilege(privilege.getGroup(), Profile.Editor);
}).collect(Collectors.toList());
//Combine all the privileges
editors.addAll(actual);

return editors.stream()//
Expand Down

0 comments on commit a99ad21

Please sign in to comment.