Package org.gitlab4j.api.webhook
Class WebHookManager
java.lang.Object
org.gitlab4j.api.webhook.WebHookManager
- All Implemented Interfaces:
HookManager
This class provides a handler for processing GitLab WebHook callouts.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a HookManager to handle GitLab webhook events.WebHookManager(String secretToken) Create a HookManager to handle GitLab webhook events which will be verified against the specified secretToken. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(WebHookListener listener) Adds a WebHook event listener.protected voidfireBuildEvent(BuildEvent buildEvent) protected voidfireDeploymentEvent(DeploymentEvent deploymentEvent) voidFire the event to the registered listeners.protected voidfireIssueEvent(IssueEvent issueEvent) protected voidfireJobEvent(JobEvent jobEvent) protected voidfireMergeRequestEvent(MergeRequestEvent mergeRequestEvent) protected voidfireNoteEvent(NoteEvent noteEvent) protected voidfirePipelineEvent(PipelineEvent pipelineEvent) protected voidfirePushEvent(PushEvent pushEvent) protected voidfireReleaseEvent(ReleaseEvent releaseEvent) protected voidfireTagPushEvent(TagPushEvent tagPushEvent) protected voidfireWikiPageEvent(WikiPageEvent wikiPageEvent) Get the secret token that received hook events should be validated against.voidhandleEvent(jakarta.servlet.http.HttpServletRequest request) Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.voidhandleEvent(Event event) Verifies the provided Event and fires it off to the registered listeners.handleRequest(jakarta.servlet.http.HttpServletRequest request) Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.voidremoveListener(WebHookListener listener) Removes a WebHook event listener.voidsetSecretToken(String secretToken) Set the secret token that received hook events should be validated against.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gitlab4j.api.HookManager
isValidSecretToken, isValidSecretToken
-
Constructor Details
-
WebHookManager
public WebHookManager()Create a HookManager to handle GitLab webhook events. -
WebHookManager
Create a HookManager to handle GitLab webhook events which will be verified against the specified secretToken.- Parameters:
secretToken- the secret token to verify against
-
-
Method Details
-
getSecretToken
Get the secret token that received hook events should be validated against.- Specified by:
getSecretTokenin interfaceHookManager- Returns:
- the secret token that received hook events should be validated against
-
setSecretToken
Set the secret token that received hook events should be validated against.- Specified by:
setSecretTokenin interfaceHookManager- Parameters:
secretToken- the secret token to verify against
-
handleEvent
Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.- Specified by:
handleEventin interfaceHookManager- Parameters:
request- the HttpServletRequest to read the Event instance from- Throws:
GitLabApiException- if the parsed event is not supported
-
handleRequest
public Event handleRequest(jakarta.servlet.http.HttpServletRequest request) throws GitLabApiException Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.- Parameters:
request- the HttpServletRequest to read the Event instance from- Returns:
- the Event instance that was read from the request body, null if the request not contain a webhook event
- Throws:
GitLabApiException- if the parsed event is not supported
-
handleEvent
Verifies the provided Event and fires it off to the registered listeners.- Parameters:
event- the Event instance to handle- Throws:
GitLabApiException- if the event is not supported
-
addListener
Adds a WebHook event listener.- Parameters:
listener- the SystemHookListener to add
-
removeListener
Removes a WebHook event listener.- Parameters:
listener- the SystemHookListener to remove
-
fireEvent
Fire the event to the registered listeners.- Parameters:
event- the Event instance to fire to the registered event listeners- Throws:
GitLabApiException- if the event is not supported
-
fireBuildEvent
-
fireIssueEvent
-
fireJobEvent
-
fireMergeRequestEvent
-
fireNoteEvent
-
firePipelineEvent
-
firePushEvent
-
fireTagPushEvent
-
fireWikiPageEvent
-
fireDeploymentEvent
-
fireReleaseEvent
-