Class AccountsUpdate
- Direct Known Subclasses:
AccountsUpdateNoteDbImpl
This interface should be used for all account updates. See AccountDelta
for what can
be updated.
For creating a new account a new account ID can be retrieved from Sequences.nextAccountId()
.
See the implementing classes for more information.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Loader forAccountsUpdate
s.static interface
Interface for updating the account delta, providing the current state.static interface
Interface for updating the account delta, providing the current state and storage accessors.static interface
The most basic interface for updating the account delta, providing no state nor context.static interface
Storage readers/writers which are accessible throughAccountsUpdate.ConfigureDeltaFromStateAndContext
.static class
Data holder for the set of arguments required to update an account. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.eclipse.jgit.lib.PersonIdent
protected final org.eclipse.jgit.lib.PersonIdent
protected final Optional<IdentifiedUser>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AccountsUpdate
(org.eclipse.jgit.lib.PersonIdent serverIdent, Optional<IdentifiedUser> user, ExternalIds externalIdsReader) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
configureDelta
(AccountsUpdate.ConfigureDeltaFromStateAndContext configureDelta, AccountState accountState, AccountDelta.Builder delta) Intended for internal usage only.abstract void
delete
(String message, Account.Id accountId) Deletes all the account state data.abstract com.google.common.collect.ImmutableList<Optional<AccountState>>
executeUpdates
(List<AccountsUpdate.UpdateArguments> updates) final AccountState
insert
(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromState init) Likeinsert(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureDeltaFromState
instead.abstract AccountState
insert
(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromStateAndContext init) Inserts a new account.final AccountState
insert
(String message, Account.Id accountId, AccountsUpdate.ConfigureStatelessDelta init) Likeinsert(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureStatelessDelta
instead.joinDeltaConfigures
(List<AccountsUpdate.ConfigureStatelessDelta> deltaConfigures) Returns an instance that runs all specified consumers.final Optional<AccountState>
update
(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromState configureDelta) Likeupdate(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureDeltaFromState
instead.final Optional<AccountState>
update
(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromStateAndContext configureDelta) Gets the account and updates it atomically.final Optional<AccountState>
update
(String message, Account.Id accountId, AccountsUpdate.ConfigureStatelessDelta configureDelta) Likeupdate(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureStatelessDelta
instead.final com.google.common.collect.ImmutableList<Optional<AccountState>>
updateBatch
(List<AccountsUpdate.UpdateArguments> updates) Updates multiple different accounts atomically.
-
Field Details
-
committerIdent
protected final org.eclipse.jgit.lib.PersonIdent committerIdent -
authorIdent
protected final org.eclipse.jgit.lib.PersonIdent authorIdent -
currentUser
-
-
Constructor Details
-
AccountsUpdate
protected AccountsUpdate(org.eclipse.jgit.lib.PersonIdent serverIdent, Optional<IdentifiedUser> user, ExternalIds externalIdsReader)
-
-
Method Details
-
joinDeltaConfigures
public static AccountsUpdate.ConfigureStatelessDelta joinDeltaConfigures(List<AccountsUpdate.ConfigureStatelessDelta> deltaConfigures) Returns an instance that runs all specified consumers. -
insert
@CanIgnoreReturnValue public abstract AccountState insert(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromStateAndContext init) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Inserts a new account.If the current account state is not needed, use
insert(String, Account.Id, ConfigureStatelessDelta)
instead.- Parameters:
message
- commit message for the account creation, must not benull or empty
accountId
- ID of the new accountinit
- to populate the new account- Returns:
- the newly created account
- Throws:
com.google.gerrit.exceptions.DuplicateKeyException
- if the account already existsIOException
- if creating the user branch fails due to an IO errororg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid value
-
insert
@CanIgnoreReturnValue public final AccountState insert(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromState init) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Likeinsert(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureDeltaFromState
instead. I.e. the update does not require any extra storage reads/writes, except for the currentAccountState
.If the current account state is not needed as well, use
insert(String, Account.Id, ConfigureStatelessDelta)
instead.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
insert
@CanIgnoreReturnValue public final AccountState insert(String message, Account.Id accountId, AccountsUpdate.ConfigureStatelessDelta init) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Likeinsert(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureStatelessDelta
instead. I.e. the update does not depend on the current account state, nor requires any extra storage reads/writes.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
update
@CanIgnoreReturnValue public final Optional<AccountState> update(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromStateAndContext configureDelta) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Gets the account and updates it atomically.Changing the registration date of an account is not supported.
If the current account state is not needed, use
update(String, Account.Id, ConfigureStatelessDelta)
instead.- Parameters:
message
- commit message for the account update, must not benull or empty
accountId
- ID of the accountconfigureDelta
- deltaBuilder to update the account, only invoked if the account exists- Returns:
- the updated account,
Optional.empty()
if the account doesn't exist - Throws:
IOException
- if updating the user branch fails due to an IO errorcom.google.gerrit.git.LockFailureException
- if updating the user branch still fails due to concurrent updates after the retry timeout exceededorg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid value
-
update
@CanIgnoreReturnValue public final Optional<AccountState> update(String message, Account.Id accountId, AccountsUpdate.ConfigureDeltaFromState configureDelta) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Likeupdate(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureDeltaFromState
instead. I.e. the update does not require any extra storage reads/writes, except for the currentAccountState
.If the current account state is not needed as well, use
update(String, Account.Id, ConfigureStatelessDelta)
instead.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
update
@CanIgnoreReturnValue public final Optional<AccountState> update(String message, Account.Id accountId, AccountsUpdate.ConfigureStatelessDelta configureDelta) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Likeupdate(String, Account.Id, ConfigureDeltaFromStateAndContext)
, but usingAccountsUpdate.ConfigureStatelessDelta
instead. I.e. the update does not depend on the current account state, nor requires any extra storage reads/writes.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updateBatch
@CanIgnoreReturnValue public final com.google.common.collect.ImmutableList<Optional<AccountState>> updateBatch(List<AccountsUpdate.UpdateArguments> updates) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Updates multiple different accounts atomically. This will only store a single new value (aka set of all external IDs of the host) in the external ID cache, which is important for storage economy. Allupdates
must be for different accounts.NOTE on error handling: Since updates are executed in multiple stages, with some stages resulting from the union of all individual updates, we cannot point to the update that caused the error. Callers should be aware that a single "update of death" (or a set of updates that together have this property) will always prevent the entire batch from being executed.
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
delete
public abstract void delete(String message, Account.Id accountId) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Deletes all the account state data.- Parameters:
message
- commit message for the account update, must not benull or empty
accountId
- ID of the account- Throws:
IOException
- if updating the user branch fails due to an IO errororg.eclipse.jgit.errors.ConfigInvalidException
- if any of the account fields has an invalid value
-
executeUpdates
public abstract com.google.common.collect.ImmutableList<Optional<AccountState>> executeUpdates(List<AccountsUpdate.UpdateArguments> updates) throws org.eclipse.jgit.errors.ConfigInvalidException, IOException - Throws:
org.eclipse.jgit.errors.ConfigInvalidException
IOException
-
configureDelta
public final void configureDelta(AccountsUpdate.ConfigureDeltaFromStateAndContext configureDelta, AccountState accountState, AccountDelta.Builder delta) throws IOException Intended for internal usage only. This is public because some implementations are calling this method for other instances.- Throws:
IOException
-