Class 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:

    1. For each recognized format in the order listed in the method Javadoc, check whether the input matches that format.
    2. If so, resolve accounts according to that format.
    3. Filter out invisible and inactive accounts.
    4. If the result list is non-empty, return.
    5. If the format is listed above as being short-circuiting, return.
    6. 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.

    • Method Detail

      • 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 an IdentifiedUser. 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.
      • 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.