Skip to content

Commit

Permalink
fix: editor group not set
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Nov 13, 2024
1 parent 9c696dd commit 02ed30f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
27 changes: 0 additions & 27 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private Map<String, GroupLink> getExistingGroupLinksById() {
private void deleteGoneGroups(final Map<String, GroupLink> currentLinks, final Set<String> canonicalGroupIds) {
final Set<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -99,7 +94,7 @@ public void synchronizeAll() {
log.debug("Fetching canonical user definitions...");
List<CanonicalUser> canonicalUsers = findCanonicalUsers();
synchronizeAll(canonicalUsers);
log.info("Users synchronization complete.");
log.debug("Users synchronization complete.");
}

@Transactional
Expand All @@ -108,7 +103,7 @@ public void synchronizeAll(List<CanonicalUser> 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<String> canonicalIds = canonical.stream().map(CanonicalUser::getId).collect(Collectors.toSet());
final Map<String, UserLink> currentLinks = getExistingUserLinksById();
Expand All @@ -125,7 +120,7 @@ public void synchronizeAll(List<CanonicalUser> canonical) {
* Ensures a GeoNetwork {@link User} exists matching the {@code canonical}
* (externally defined) user properties and authorization settings.
* <p>
*
*
*/
@Transactional
public UserLink synchronize(CanonicalUser canonical) {
Expand All @@ -152,8 +147,15 @@ private void synchronizeUserGroups(User user, List<Privilege> privileges) {
}

private List<UserGroup> resolveNewPrivileges(User user, List<Privilege> actual) {

return actual.stream()//
List<Privilege> 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());
}
Expand Down

0 comments on commit 02ed30f

Please sign in to comment.