Class AbstractGitWorkTreeRepositoryHookInvoker<T extends com.atlassian.bitbucket.hook.repository.RepositoryHookRequest>
java.lang.Object
com.atlassian.bitbucket.scm.git.worktree.AbstractGitWorkTreeRepositoryHookInvoker<T>
- Type Parameters:
T- theRepositoryHookRequesttype
- 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 Summary
FieldsModifier and TypeFieldDescriptionprotected final com.atlassian.event.api.EventPublisher -
Constructor Summary
ConstructorsConstructorDescriptionAbstractGitWorkTreeRepositoryHookInvoker(com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.bitbucket.hook.repository.RepositoryHookService repositoryHookService) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TcreateHookRequest(GitWorkTree workTree, List<com.atlassian.bitbucket.repository.RefChange> refChanges) protected abstract com.atlassian.bitbucket.event.ApplicationEventcreatePostUpdateEvent(T hookRequest) protected voidonAccepted(T hookRequest, com.atlassian.bitbucket.hook.repository.RepositoryHookResult result) Called frompreUpdate(GitWorkTree, List)after the repository hooks have been called and the change has been accepted (but not applied yet).protected voidonRejected(T hookRequest, com.atlassian.bitbucket.hook.repository.RepositoryHookResult result) Called frompreUpdate(GitWorkTree, List)after the repository hooks have been called and the change has been rejected.voidpostUpdate(GitWorkTree workTree, List<com.atlassian.bitbucket.repository.RefChange> refChanges) Called byGitWorkTree.publish(PublishGitWorkTreeParameters)after the work tree ref has been published.booleanpreUpdate(GitWorkTree workTree, List<com.atlassian.bitbucket.repository.RefChange> refChanges) Called byGitWorkTree.publish(PublishGitWorkTreeParameters)before the work tree ref is published.
-
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:GitWorkTreeRepositoryHookInvokerCalled byGitWorkTree.publish(PublishGitWorkTreeParameters)before the work tree ref is published. Implementors should callRepositoryHookService.preUpdate(RepositoryHookRequest)with an appropriateRepositoryHookRequest.- Specified by:
preUpdatein interfaceGitWorkTreeRepositoryHookInvoker- Parameters:
workTree- the work tree for which arefChangeare about to be publishedrefChanges- theref changesabout to be published- Returns:
trueif the pre-update hooks accepted the change, otherwisefalse- See Also:
-
RepositoryHookService.preUpdate(RepositoryHookRequest)
-
postUpdate
public void postUpdate(@Nonnull GitWorkTree workTree, @Nonnull List<com.atlassian.bitbucket.repository.RefChange> refChanges) Description copied from interface:GitWorkTreeRepositoryHookInvokerCalled byGitWorkTree.publish(PublishGitWorkTreeParameters)after the work tree ref has been published. Implementors should callRepositoryHookService.postUpdate(RepositoryHookRequest)with an appropriateRepositoryHookRequest.- Specified by:
postUpdatein interfaceGitWorkTreeRepositoryHookInvoker- Parameters:
workTree- the work tree for which arefChangehas been publishedrefChanges- theref changesthat 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 frompreUpdate(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 hooksresult- the repository hook result
-
onRejected
protected void onRejected(@Nonnull T hookRequest, @Nonnull com.atlassian.bitbucket.hook.repository.RepositoryHookResult result) Called frompreUpdate(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 hooksresult- the repository hook result, which includes all vetoes
-