Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ private boolean hasAccessToCancerStudy(
Arrays.stream(cancerStudy.getGroups().split(";"))
.filter(g -> !g.isEmpty())
.collect(Collectors.toSet());
if (!Collections.disjoint(groups, grantedAuthorities)) {
if (!caseInsensitiveDisjoint(groups, grantedAuthorities)) {
if (log.isDebugEnabled()) {
log.debug("hasAccessToCancerStudy(), user has access by groups return true");
}
Expand All @@ -393,6 +393,12 @@ private boolean hasAccessToCancerStudy(
return toReturn;
}

private static boolean caseInsensitiveDisjoint(Collection<String> c1, Collection<String> c2) {
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should include null safety checks for the input collections to prevent NullPointerException if either c1 or c2 is null.

Suggested change
private static boolean caseInsensitiveDisjoint(Collection<String> c1, Collection<String> c2) {
private static boolean caseInsensitiveDisjoint(Collection<String> c1, Collection<String> c2) {
if (c1 == null || c2 == null) {
return true; // If either collection is null, they are considered disjoint.
}

Copilot uses AI. Check for mistakes.

Set<String> upperC1 = c1.stream().map(String::toUpperCase).collect(Collectors.toSet());
Set<String> upperC2 = c2.stream().map(String::toUpperCase).collect(Collectors.toSet());
Comment on lines +397 to +398
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stream operations should handle null elements within the collections to prevent NullPointerException when calling toUpperCase() on null strings.

Suggested change
Set<String> upperC1 = c1.stream().map(String::toUpperCase).collect(Collectors.toSet());
Set<String> upperC2 = c2.stream().map(String::toUpperCase).collect(Collectors.toSet());
Set<String> upperC1 = c1.stream()
.filter(Objects::nonNull)
.map(String::toUpperCase)
.collect(Collectors.toSet());
Set<String> upperC2 = c2.stream()
.filter(Objects::nonNull)
.map(String::toUpperCase)
.collect(Collectors.toSet());

Copilot uses AI. Check for mistakes.

Comment on lines +397 to +398
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stream operations should handle null elements within the collections to prevent NullPointerException when calling toUpperCase() on null strings.

Suggested change
Set<String> upperC1 = c1.stream().map(String::toUpperCase).collect(Collectors.toSet());
Set<String> upperC2 = c2.stream().map(String::toUpperCase).collect(Collectors.toSet());
Set<String> upperC1 = c1.stream()
.filter(Objects::nonNull)
.map(String::toUpperCase)
.collect(Collectors.toSet());
Set<String> upperC2 = c2.stream()
.filter(Objects::nonNull)
.map(String::toUpperCase)
.collect(Collectors.toSet());

Copilot uses AI. Check for mistakes.

return Collections.disjoint(upperC1, upperC2);
}

private boolean hasAccessToCancerStudy(
Authentication authentication, String cancerStudyId, Object permission) {
// everybody has access the 'all' cancer study
Expand Down
Loading