Interface ChangeDraftUpdateExecutor

All Known Implementing Classes:
ChangeDraftNotesUpdate.Executor

public interface ChangeDraftUpdateExecutor
An interface for executing updates of multiple ChangeDraftUpdate instances.

Expected usage flow:

  1. Inject an instance of ChangeDraftUpdateExecutor.AbstractFactory.
  2. Create an instance of this interface using the factory.
  3. Call (queueAllDraftUpdates(com.google.common.collect.ListMultimap<java.lang.String, com.google.gerrit.server.ChangeDraftUpdate>) or queueDeletionForChangeDrafts(com.google.gerrit.entities.Change.Id) for all expected updates. The changes are marked to be executed either synchronously or asynchronously, based on canRunAsync(java.util.Collection<? extends com.google.gerrit.server.ChangeDraftUpdate>).
  4. Call both executeAllSyncUpdates(boolean, org.eclipse.jgit.lib.PersonIdent, java.lang.String) and executeAllAsyncUpdates(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.
  • Method Details

    • queueAllDraftUpdates

      void queueAllDraftUpdates(com.google.common.collect.ListMultimap<String,ChangeDraftUpdate> updates) throws IOException
      Queues 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

      void queueDeletionForChangeDrafts(Change.Id id) throws IOException
      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 valid BatchRefUpdate.

      Parameters:
      dryRun - whether this is a dry run - i.e. no updates should be made
      refLogIdent - user to log as the update creator
      refLogMessage - 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 creator
      refLogMessage - message to put in the updates log
      pushCert - 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

      default boolean canRunAsync(Collection<? extends ChangeDraftUpdate> updates)
      Returns whether all provided updates can run asynchronously.