public class AccountsUpdate extends Object
The account updates are written to NoteDb.
In NoteDb accounts are represented as user branches in the All-Users repository. Optionally a
user branch can contain a 'account.config' file that stores account properties, such as full
name, preferred email, status and the active flag. The timestamp of the first commit on a user
branch denotes the registration date. The initial commit on the user branch may be empty (since
having an 'account.config' is optional). See AccountConfig
for details of the
'account.config' file format.
On updating accounts the accounts are evicted from the account cache and thus reindexed. The
eviction from the account cache is done by the ReindexAfterRefUpdate
class which receives
the event about updating the user branch that is triggered by this class.
Modifier and Type | Class and Description |
---|---|
static class |
AccountsUpdate.Server
Factory to create an AccountsUpdate instance for updating accounts by the Gerrit server.
|
static class |
AccountsUpdate.User
Factory to create an AccountsUpdate instance for updating accounts by the current user.
|
Modifier and Type | Method and Description |
---|---|
void |
delete(Account account)
Deletes the account.
|
void |
deleteByKey(Account.Id accountId)
Deletes the account.
|
static void |
deleteUserBranch(org.eclipse.jgit.lib.Repository repo,
Project.NameKey project,
GitReferenceUpdated gitRefUpdated,
IdentifiedUser user,
org.eclipse.jgit.lib.PersonIdent refLogIdent,
Account.Id accountId) |
Account |
insert(Account.Id accountId,
Consumer<Account> init)
Inserts a new account.
|
void |
replace(Account account)
Replaces the account.
|
Account |
update(Account.Id accountId,
Consumer<Account> consumer)
Gets the account and updates it atomically.
|
Account |
update(Account.Id accountId,
List<Consumer<Account>> consumers)
Gets the account and updates it atomically.
|
public Account insert(Account.Id accountId, Consumer<Account> init) throws com.google.gwtorm.server.OrmDuplicateKeyException, IOException, org.eclipse.jgit.errors.ConfigInvalidException
accountId
- ID of the new accountinit
- consumer to populate the new accountcom.google.gwtorm.server.OrmDuplicateKeyException
- if the account already existsIOException
- if updating the user branch failsorg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid valuepublic Account update(Account.Id accountId, Consumer<Account> consumer) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
Changing the registration date of an account is not supported.
accountId
- ID of the accountconsumer
- consumer to update the account, only invoked if the account existsnull
if the account doesn't existIOException
- if updating the user branch failsorg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid valuepublic Account update(Account.Id accountId, List<Consumer<Account>> consumers) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
Changing the registration date of an account is not supported.
accountId
- ID of the accountconsumers
- consumers to update the account, only invoked if the account existsnull
if the account doesn't existIOException
- if updating the user branch failsorg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid valuepublic void replace(Account account) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
The existing account with the same account ID is overwritten by the given account. Choosing
to overwrite an account means that any updates that were done to the account by a racing
request after the account was read are lost. Updates are also lost if the account was read from
a stale account index. This is why using update(com.google.gerrit.reviewdb.client.Account.Id, Consumer)
to do an atomic update is
always preferred.
Changing the registration date of an account is not supported.
account
- the new accountIOException
- if updating the user branch failsorg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid valueupdate(com.google.gerrit.reviewdb.client.Account.Id, Consumer)
public void delete(Account account) throws IOException
account
- the account that should be deletedIOException
- if updating the user branch failspublic void deleteByKey(Account.Id accountId) throws IOException
accountId
- the ID of the account that should be deletedIOException
- if updating the user branch failspublic static void deleteUserBranch(org.eclipse.jgit.lib.Repository repo, Project.NameKey project, GitReferenceUpdated gitRefUpdated, IdentifiedUser user, org.eclipse.jgit.lib.PersonIdent refLogIdent, Account.Id accountId) throws IOException
IOException