Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor group not set when reviewer #305

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading