From a99ad2186058fdbd69c54fb303721a02a386c12c Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Wed, 20 Nov 2024 10:46:28 +0100 Subject: [PATCH] fix : user synchronizer if only reviewer and not both --- .../external/integration/UserSynchronizer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/UserSynchronizer.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/UserSynchronizer.java index f5e8680cf3..d006fdc8a1 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/UserSynchronizer.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/UserSynchronizer.java @@ -147,12 +147,22 @@ private void synchronizeUserGroups(User user, List privileges) { } private List resolveNewPrivileges(User user, List actual) { - List editors = actual.stream().filter(privilege -> privilege.getProfile() == Profile.Reviewer)// - .map(privilege -> { + + List 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()//