Class AccountResolver
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 ClassesModifier and TypeClassDescriptionclass
static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
static boolean
Resolves all accounts matching the input string, visible to the current user.resolve
(String input, Predicate<AccountState> accountActivityPredicate) resolveAsUser
(CurrentUser asUser, String input) Resolves all accounts matching the input string, visible to the provided user.resolveAsUser
(CurrentUser asUser, String input, Predicate<AccountState> accountActivityPredicate) resolveAsUserIgnoreVisibility
(CurrentUser asUser, String input) resolveAsUserIgnoreVisibility
(CurrentUser asUser, String input, Predicate<AccountState> accountActivityPredicate) resolveByExactNameOrEmail
(String input) Deprecated.for use only by MailUtil for parsing commit footers; that class needs to be reevaluated.resolveByNameOrEmail
(String input) Deprecated.for use only by MailUtil for parsing commit footers; that class needs to be reevaluated.resolveExact
(String input) Resolves accounts using exact searchers.resolveIgnoreVisibility
(String input) resolveIncludeInactive
(String input) As opposed toresolve(java.lang.String)
, the returned result includes all inactive accounts for the input search.
-
Method Details
-
exceptionMessage
-
isSelf
-
resolve
public AccountResolver.Result resolve(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException Resolves all accounts matching the input string, visible to the current user.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
-
resolveExact
public AccountResolver.Result resolveExact(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException Resolves accounts using exact searchers. Similar to the previous method.- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolve
public AccountResolver.Result resolve(String input, Predicate<AccountState> accountActivityPredicate) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveAsUser
public AccountResolver.Result resolveAsUser(CurrentUser asUser, String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException Resolves all accounts matching the input string, visible to the provided user.The following input formats are recognized:
- The strings
"self"
and"me"
, if the provided 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:
asUser
- user to resolve the users by.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
-
resolveAsUser
public AccountResolver.Result resolveAsUser(CurrentUser asUser, String input, Predicate<AccountState> accountActivityPredicate) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveIncludeInactive
public AccountResolver.Result resolveIncludeInactive(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException As opposed toresolve(java.lang.String)
, the returned result includes all inactive accounts for the input search.This can be used to resolve Gerrit Account from email to its
Account.Id
, to make sure that ifAccount
with such email exists in Gerrit (even inactive), user data (email address) won't be recorded as it is, but instead will be stored as a link to the corresponding Gerrit Account.- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveIncludeInactiveIgnoreVisibility
public AccountResolver.Result resolveIncludeInactiveIgnoreVisibility(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveIgnoreVisibility
public AccountResolver.Result resolveIgnoreVisibility(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveExactIgnoreVisibility
public AccountResolver.Result resolveExactIgnoreVisibility(String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveAsUserIgnoreVisibility
public AccountResolver.Result resolveAsUserIgnoreVisibility(CurrentUser asUser, String input) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
resolveAsUserIgnoreVisibility
public AccountResolver.Result resolveAsUserIgnoreVisibility(CurrentUser asUser, 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 (
-
resolveByExactNameOrEmail
@Deprecated public AccountResolver.Result resolveByExactNameOrEmail(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.Same asresolveByNameOrEmail(String)
, but with exact matching for the full name, email and full name.- 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.
-