Package com.google.gerrit.server.account
Class AccountResolver
- java.lang.Object
-
- com.google.gerrit.server.account.AccountResolver
-
public class AccountResolver extends Object
Helper for resolving accounts given arbitrary user-provided input.The
resolve*
methods each define a list of accepted formats for account resolution. The algorithm for resolving accounts from a list of formats is as follows:- For each recognized format in the order listed in the method Javadoc, check whether the input matches that format.
- If so, resolve accounts according to that format.
- Filter out invisible and inactive accounts.
- If the result list is non-empty, return.
- If the format is listed above as being short-circuiting, return.
- Otherwise, return to step 1 with the next format.
The result never includes accounts that are not visible to the calling user. It also never includes inactive accounts, with a small number of specific exceptions noted in method Javadoc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AccountResolver.Result
static class
AccountResolver.UnresolvableAccountException
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
exceptionMessage(AccountResolver.Result result)
static boolean
isSelf(String input)
AccountResolver.Result
resolve(String input)
Resolves all accounts matching the input string.AccountResolver.Result
resolve(String input, Predicate<AccountState> accountActivityPredicate)
AccountResolver.Result
resolveByNameOrEmail(String input)
Deprecated.for use only by MailUtil for parsing commit footers; that class needs to be reevaluated.
-
-
-
Method Detail
-
exceptionMessage
public static String exceptionMessage(AccountResolver.Result result)
-
isSelf
public static boolean isSelf(String input)
-
resolve
public AccountResolver.Result resolve(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException
Resolves all accounts matching the input string.The following input formats are recognized:
- The strings
"self"
and"me"
, if the current user is anIdentifiedUser
. In this case, may return exactly one inactive account. - A bare account ID (
"18419"
). In this case, may return exactly one inactive account. This case short-circuits if the input matches. - An account ID in parentheses following a full name (
"Full Name (18419)"
). This case short-circuits if the input matches. - A username (
"username"
). - A full name and email address (
"Full Name <email@example>"
). This case short-circuits if the input matches. - An email address (
"email@example"
. This case short-circuits if the input matches. - An account name recognized by the configured
Realm.lookup(String)
Realm}. - A full name (
"Full Name"
). - As a fallback, a
default search
against the account index.
- Parameters:
input
- input string.- Returns:
- a result describing matching accounts. Never null even if the result set is empty.
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
- if an error occurs.IOException
- if an error occurs.
- The strings
-
resolve
public AccountResolver.Result resolve(String input, Predicate<AccountState> accountActivityPredicate) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveByNameOrEmail
@Deprecated public AccountResolver.Result resolveByNameOrEmail(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException
Deprecated.for use only by MailUtil for parsing commit footers; that class needs to be reevaluated.Resolves all accounts matching the input string by name or email.The following input formats are recognized:
- A full name and email address (
"Full Name <email@example>"
). This case short-circuits if the input matches. - An email address (
"email@example"
. This case short-circuits if the input matches. - An account name recognized by the configured
Realm.lookup(String)
Realm}. - A full name (
"Full Name"
). - As a fallback, a
default search
against the account index.
- Parameters:
input
- input string.- Returns:
- a result describing matching accounts. Never null even if the result set is empty.
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
- if an error occurs.IOException
- if an error occurs.
- A full name and email address (
-
-