From 8cdb4cc2190d7b33244fd96dcfdecfe00354b057 Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Wed, 13 Nov 2024 16:49:09 +0100 Subject: [PATCH] fix: editor group not set (cherry picked from commit 02ed30f710b4693326fb39636ce85005e054751f) --- .../AbstractGroupSynchronizer.java | 2 +- .../integration/UserSynchronizer.java | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java index 852178064f..d816bdbbcb 100644 --- a/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java +++ b/georchestra-integration/externalized-accounts/src/main/java/org/geonetwork/security/external/integration/AbstractGroupSynchronizer.java @@ -203,7 +203,7 @@ private Map getExistingGroupLinksById() { private void deleteGoneGroups(final Map currentLinks, final Set canonicalGroupIds) { final Set deleteCandidateIds = Sets.difference(currentLinks.keySet(), canonicalGroupIds); if (deleteCandidateIds.isEmpty()) { - log.info("No organizations were deleted."); + log.debug("No organizations were deleted."); return; } for (String groupId : deleteCandidateIds) { 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 44a2b79e07..f5e8680cf3 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 @@ -20,12 +20,7 @@ import static java.util.Objects.requireNonNull; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -99,7 +94,7 @@ public void synchronizeAll() { log.debug("Fetching canonical user definitions..."); List canonicalUsers = findCanonicalUsers(); synchronizeAll(canonicalUsers); - log.info("Users synchronization complete."); + log.debug("Users synchronization complete."); } @Transactional @@ -108,7 +103,7 @@ public void synchronizeAll(List canonical) { requireNonNull(canonical); canonical.forEach(u -> requireNonNull(u, "null references not accepted in user's list")); - log.debug("Syncrhonizing {} canonical user definitions...", canonical.size()); + log.debug("Synchronizing {} canonical user definitions...", canonical.size()); try { final Set canonicalIds = canonical.stream().map(CanonicalUser::getId).collect(Collectors.toSet()); final Map currentLinks = getExistingUserLinksById(); @@ -125,7 +120,7 @@ public void synchronizeAll(List canonical) { * Ensures a GeoNetwork {@link User} exists matching the {@code canonical} * (externally defined) user properties and authorization settings. *

- * + * */ @Transactional public UserLink synchronize(CanonicalUser canonical) { @@ -152,8 +147,15 @@ private void synchronizeUserGroups(User user, List privileges) { } private List resolveNewPrivileges(User user, List actual) { - - return actual.stream()// + List editors = actual.stream().filter(privilege -> privilege.getProfile() == Profile.Reviewer)// + .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()); + editors.addAll(actual); + + return editors.stream()// .map(privilege -> newUserGroup(user, privilege))// .collect(Collectors.toList()); }