Class Emails
- java.lang.Object
-
- com.google.gerrit.server.account.Emails
-
public class Emails extends Object
Class to access accounts by email.
-
-
Constructor Summary
Constructors Constructor Description Emails(ExternalIds externalIds, RetryHelper retryHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableSet<Account.Id>
getAccountFor(String email)
Returns the accounts with the given email.com.google.common.collect.ImmutableSet<Account.Id>
getAccountForExternal(String email)
Returns the accounts with the given email.com.google.common.collect.ImmutableSetMultimap<String,Account.Id>
getAccountsFor(String... emails)
Returns the accounts for the given emails.UserIdentity
toUserIdentity(org.eclipse.jgit.lib.PersonIdent who)
-
-
-
Constructor Detail
-
Emails
@Inject public Emails(ExternalIds externalIds, RetryHelper retryHelper)
-
-
Method Detail
-
getAccountFor
public com.google.common.collect.ImmutableSet<Account.Id> getAccountFor(String email) throws IOException
Returns the accounts with the given email.Each email should belong to a single account only. This means if more than one account is returned there is an inconsistency in the external IDs.
The accounts are retrieved via the external ID cache. Each access to the external ID cache requires reading the SHA1 of the refs/meta/external-ids branch. If accounts for multiple emails are needed it is more efficient to use
getAccountsFor(String...)
as this method reads the SHA1 of the refs/meta/external-ids branch only once (and not once per email).In addition accounts are included that have the given email as preferred email even if they have no external ID for the preferred email. Having accounts with a preferred email that does not exist as external ID is an inconsistency, but existing functionality relies on still getting those accounts, which is why they are included. Accounts by preferred email are fetched from the account index as a fallback for email addresses that could not be resolved using
ExternalIds
.- Throws:
IOException
- See Also:
getAccountsFor(String...)
-
getAccountsFor
public com.google.common.collect.ImmutableSetMultimap<String,Account.Id> getAccountsFor(String... emails) throws IOException
Returns the accounts for the given emails.- Throws:
IOException
- See Also:
getAccountFor(String)
-
getAccountForExternal
public com.google.common.collect.ImmutableSet<Account.Id> getAccountForExternal(String email) throws IOException
Returns the accounts with the given email.This method behaves just like
getAccountFor(String)
, except that accounts are not looked up by their preferred email. Thus, this method does not rely on the accounts index.- Throws:
IOException
-
toUserIdentity
public UserIdentity toUserIdentity(org.eclipse.jgit.lib.PersonIdent who) throws IOException
- Throws:
IOException
-
-