Class AbstractGitWorkTreeRepositoryHookInvoker<T extends com.atlassian.bitbucket.hook.repository.RepositoryHookRequest>

java.lang.Object
com.atlassian.bitbucket.scm.git.worktree.AbstractGitWorkTreeRepositoryHookInvoker<T>
Type Parameters:
T - the RepositoryHookRequest type
All Implemented Interfaces:
GitWorkTreeRepositoryHookInvoker

public abstract class AbstractGitWorkTreeRepositoryHookInvoker<T extends com.atlassian.bitbucket.hook.repository.RepositoryHookRequest> extends Object implements GitWorkTreeRepositoryHookInvoker
Convenience base class for implementing GitWorkTreeRepositoryHookInvoker
Since:
7.14
  • Field Details

    • eventPublisher

      protected final com.atlassian.event.api.EventPublisher eventPublisher
  • Constructor Details

    • AbstractGitWorkTreeRepositoryHookInvoker

      public AbstractGitWorkTreeRepositoryHookInvoker(@Nonnull com.atlassian.event.api.EventPublisher eventPublisher, @Nonnull com.atlassian.bitbucket.hook.repository.RepositoryHookService repositoryHookService)
  • Method Details

    • preUpdate

      public boolean preUpdate(@Nonnull GitWorkTree workTree, @Nonnull List<com.atlassian.bitbucket.repository.RefChange> refChanges)
      Description copied from interface: GitWorkTreeRepositoryHookInvoker
      Called by GitWorkTree.publish(PublishGitWorkTreeParameters) before the work tree ref is published. Implementors should call RepositoryHookService.preUpdate(RepositoryHookRequest) with an appropriate RepositoryHookRequest.
      Specified by:
      preUpdate in interface GitWorkTreeRepositoryHookInvoker
      Parameters:
      workTree - the work tree for which a refChange are about to be published
      refChanges - the ref changes about to be published
      Returns:
      true if the pre-update hooks accepted the change, otherwise false
      See Also:
      • RepositoryHookService.preUpdate(RepositoryHookRequest)
    • postUpdate

      public void postUpdate(@Nonnull GitWorkTree workTree, @Nonnull List<com.atlassian.bitbucket.repository.RefChange> refChanges)
      Description copied from interface: GitWorkTreeRepositoryHookInvoker
      Called by GitWorkTree.publish(PublishGitWorkTreeParameters) after the work tree ref has been published. Implementors should call RepositoryHookService.postUpdate(RepositoryHookRequest) with an appropriate RepositoryHookRequest.
      Specified by:
      postUpdate in interface GitWorkTreeRepositoryHookInvoker
      Parameters:
      workTree - the work tree for which a refChange has been published
      refChanges - the ref changes that have been published
      See Also:
      • RepositoryHookService.postUpdate(RepositoryHookRequest)
    • createHookRequest

      @Nonnull protected abstract T createHookRequest(@Nonnull GitWorkTree workTree, @Nonnull List<com.atlassian.bitbucket.repository.RefChange> refChanges)
    • createPostUpdateEvent

      @Nonnull protected abstract com.atlassian.bitbucket.event.ApplicationEvent createPostUpdateEvent(@Nonnull T hookRequest)
    • onAccepted

      protected void onAccepted(@Nonnull T hookRequest, @Nonnull com.atlassian.bitbucket.hook.repository.RepositoryHookResult result)
      Called from preUpdate(GitWorkTree, List) after the repository hooks have been called and the change has been accepted (but not applied yet). Most implementations won't need to do anything here, but the callback exists just in case.
      Parameters:
      hookRequest - the hook request that was approved by the repository hooks
      result - the repository hook result
    • onRejected

      protected void onRejected(@Nonnull T hookRequest, @Nonnull com.atlassian.bitbucket.hook.repository.RepositoryHookResult result)
      Called from preUpdate(GitWorkTree, List) after the repository hooks have been called and the change has been rejected. Most implementations will want to throw an exception here. If an event should be raised notifying other parts of the system that the operation has been rejected, this is the place to do it.
      Parameters:
      hookRequest - the hook request that was rejected by the repository hooks
      result - the repository hook result, which includes all vetoes