Package com.google.gerrit.server
Interface ChangeDraftUpdateExecutor
- All Known Implementing Classes:
ChangeDraftNotesUpdate.Executor
public interface ChangeDraftUpdateExecutor
An interface for executing updates of multiple
ChangeDraftUpdate
instances.
Expected usage flow:
- Inject an instance of
ChangeDraftUpdateExecutor.AbstractFactory
. - Create an instance of this interface using the factory.
- Call (
queueAllDraftUpdates(com.google.common.collect.ListMultimap<java.lang.String, com.google.gerrit.server.ChangeDraftUpdate>)
orqueueDeletionForChangeDrafts(com.google.gerrit.entities.Change.Id)
for all expected updates. The changes are marked to be executed either synchronously or asynchronously, based oncanRunAsync(java.util.Collection<? extends com.google.gerrit.server.ChangeDraftUpdate>)
. - Call both
executeAllSyncUpdates(boolean, org.eclipse.jgit.lib.PersonIdent, java.lang.String)
andexecuteAllAsyncUpdates(org.eclipse.jgit.lib.PersonIdent, java.lang.String, org.eclipse.jgit.transport.PushCertificate)
methods. Running these methods with no pending updates is a no-op.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
canRunAsync
(Collection<? extends ChangeDraftUpdate> updates) Returns whether all provided updates can run asynchronously.void
executeAllAsyncUpdates
(org.eclipse.jgit.lib.PersonIdent refLogIdent, String refLogMessage, org.eclipse.jgit.transport.PushCertificate pushCert) Execute all previously queued async updates.Optional<org.eclipse.jgit.lib.BatchRefUpdate>
executeAllSyncUpdates
(boolean dryRun, org.eclipse.jgit.lib.PersonIdent refLogIdent, String refLogMessage) Execute all previously queued sync updates.default <UpdateT extends ChangeDraftUpdate>
com.google.common.collect.ListMultimap<String,UpdateT> filterTypedUpdates
(com.google.common.collect.ListMultimap<String, ChangeDraftUpdate> updates, Class<UpdateT> updateType) Returns the given updates that match the provided type.boolean
isEmpty()
Returns whether any updates are queued.void
queueAllDraftUpdates
(com.google.common.collect.ListMultimap<String, ChangeDraftUpdate> updates) Queues all provided updates for later execution.void
Extracts all drafts (of all authors) for the given change and queue their deletion.
-
Method Details
-
queueAllDraftUpdates
void queueAllDraftUpdates(com.google.common.collect.ListMultimap<String, ChangeDraftUpdate> updates) throws IOExceptionQueues all provided updates for later execution.The updates are queued to either run synchronously just after change repositories updates, or to run asynchronously afterwards, based on
canRunAsync(java.util.Collection<? extends com.google.gerrit.server.ChangeDraftUpdate>)
.- Throws:
IOException
-
queueDeletionForChangeDrafts
Extracts all drafts (of all authors) for the given change and queue their deletion.See
canRunAsync(java.util.Collection<? extends com.google.gerrit.server.ChangeDraftUpdate>)
for whether the deletions are scheduled as synchronous or asynchronous.- Throws:
IOException
-
executeAllSyncUpdates
Optional<org.eclipse.jgit.lib.BatchRefUpdate> executeAllSyncUpdates(boolean dryRun, org.eclipse.jgit.lib.PersonIdent refLogIdent, String refLogMessage) throws IOException Execute all previously queued sync updates.NOTE that
BatchUpdateListener.beforeUpdateRefs(org.eclipse.jgit.lib.BatchRefUpdate)
events are not fired by this method. post-update events can be fired by the caller only for implementations that return a validBatchRefUpdate
.- Parameters:
dryRun
- whether this is a dry run - i.e. no updates should be maderefLogIdent
- user to log as the update creatorrefLogMessage
- message to put in the updates log- Returns:
- the executed update, if supported by the implementing class
- Throws:
IOException
- in case of an update failure.
-
executeAllAsyncUpdates
void executeAllAsyncUpdates(org.eclipse.jgit.lib.PersonIdent refLogIdent, String refLogMessage, org.eclipse.jgit.transport.PushCertificate pushCert) Execute all previously queued async updates.- Parameters:
refLogIdent
- user to log as the update creatorrefLogMessage
- message to put in the updates logpushCert
- to use for the update
-
isEmpty
boolean isEmpty()Returns whether any updates are queued. -
filterTypedUpdates
default <UpdateT extends ChangeDraftUpdate> com.google.common.collect.ListMultimap<String,UpdateT> filterTypedUpdates(com.google.common.collect.ListMultimap<String, ChangeDraftUpdate> updates, Class<UpdateT> updateType) Returns the given updates that match the provided type. -
canRunAsync
Returns whether all provided updates can run asynchronously.
-