diff options
Diffstat (limited to 'gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java')
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java index cdbb0e49bc..f7e06344d2 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupBackends.java @@ -16,6 +16,8 @@ package com.google.gerrit.server.account; import com.google.common.collect.Iterables; import com.google.gerrit.common.data.GroupReference; +import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.server.project.ProjectControl; import java.util.Collection; import java.util.Comparator; @@ -36,7 +38,7 @@ public class GroupBackends { }; /** - * Runs {@link GroupBackend#suggest(String)} and filters the result to return + * Runs {@link GroupBackend#suggest(String, Project)} and filters the result to return * the best suggestion, or null if one does not exist. * * @param groupBackend the group backend @@ -44,9 +46,23 @@ public class GroupBackends { * @return the best single GroupReference suggestion */ @Nullable - public static GroupReference findBestSuggestion( - GroupBackend groupBackend, String name) { - Collection<GroupReference> refs = groupBackend.suggest(name); + public static GroupReference findBestSuggestion(GroupBackend groupBackend, + String name) { + return findBestSuggestion(groupBackend, name, null); + } + /** + * Runs {@link GroupBackend#suggest(String, Project)} and filters the result to return + * the best suggestion, or null if one does not exist. + * + * @param groupBackend the group backend + * @param name the name for which to suggest groups + * @param project the project for which to suggest groups + * @return the best single GroupReference suggestion + */ + @Nullable + public static GroupReference findBestSuggestion(GroupBackend groupBackend, + String name, @Nullable ProjectControl project) { + Collection<GroupReference> refs = groupBackend.suggest(name, project); if (refs.size() == 1) { return Iterables.getOnlyElement(refs); } @@ -60,7 +76,7 @@ public class GroupBackends { } /** - * Runs {@link GroupBackend#suggest(String)} and filters the result to return + * Runs {@link GroupBackend#suggest(String, Project)} and filters the result to return * the exact suggestion, or null if one does not exist. * * @param groupBackend the group backend @@ -70,7 +86,22 @@ public class GroupBackends { @Nullable public static GroupReference findExactSuggestion( GroupBackend groupBackend, String name) { - Collection<GroupReference> refs = groupBackend.suggest(name); + return findExactSuggestion(groupBackend, name, null); + } + + /** + * Runs {@link GroupBackend#suggest(String, Project)} and filters the result to return + * the exact suggestion, or null if one does not exist. + * + * @param groupBackend the group backend + * @param name the name for which to suggest groups + * @param project the project for which to suggest groups + * @return the exact single GroupReference suggestion + */ + @Nullable + public static GroupReference findExactSuggestion( + GroupBackend groupBackend, String name, ProjectControl project) { + Collection<GroupReference> refs = groupBackend.suggest(name, project); for (GroupReference ref : refs) { if (isExactSuggestion(ref, name)) { return ref; |