Skip to content

Commit

Permalink
Refactor role creation in FENCEAuthenticationService
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed May 27, 2024
1 parent cdb7a5b commit dd7ff13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
Expand All @@ -20,7 +20,7 @@ protected RoleRepository() {
super(Role.class);
}

public void persistAll(ArrayList<Role> newRoles) {
public void persistAll(List<Role> newRoles) {
newRoles.forEach(this::persist);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ public Response getFENCEProfile(String callback_url, Map<String, String> authReq
Set<String> roleNames = new HashSet<>();
project_access_names.forEachRemaining(roleNames::add);

ArrayList<Role> newRoles = new ArrayList<>();
roleNames.parallelStream().forEach(roleName -> {
newRoles.add(createRole(roleName, "FENCE role "+roleName));
});
List<Role> newRoles = roleNames.parallelStream()
.map(roleName -> createRole(roleName, "FENCE role " + roleName))
.filter(Objects::nonNull)
.collect(Collectors.toList());

roleRepo.persistAll(newRoles);

if (current_user.getRoles() == null) {
Expand Down

0 comments on commit dd7ff13

Please sign in to comment.