Class WebHookManager

  • All Implemented Interfaces:
    HookManager

    public class WebHookManager
    extends java.lang.Object
    implements HookManager
    This class provides a handler for processing GitLab WebHook callouts.
    • Constructor Summary

      Constructors 
      Constructor Description
      WebHookManager()
      Create a HookManager to handle GitLab webhook events.
      WebHookManager​(java.lang.String secretToken)
      Create a HookManager to handle GitLab webhook events which will be verified against the specified secretToken.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(org.gitlab4j.api.webhook.WebHookListener listener)
      Adds a WebHook event listener.
      protected void fireBuildEvent​(org.gitlab4j.api.webhook.BuildEvent buildEvent)  
      protected void fireDeploymentEvent​(org.gitlab4j.api.webhook.DeploymentEvent deploymentEvent)  
      void fireEvent​(org.gitlab4j.api.webhook.Event event)
      Fire the event to the registered listeners.
      protected void fireIssueEvent​(org.gitlab4j.api.webhook.IssueEvent issueEvent)  
      protected void fireJobEvent​(org.gitlab4j.api.webhook.JobEvent jobEvent)  
      protected void fireMergeRequestEvent​(org.gitlab4j.api.webhook.MergeRequestEvent mergeRequestEvent)  
      protected void fireNoteEvent​(org.gitlab4j.api.webhook.NoteEvent noteEvent)  
      protected void firePipelineEvent​(org.gitlab4j.api.webhook.PipelineEvent pipelineEvent)  
      protected void firePushEvent​(org.gitlab4j.api.webhook.PushEvent pushEvent)  
      protected void fireReleaseEvent​(org.gitlab4j.api.webhook.ReleaseEvent releaseEvent)  
      protected void fireTagPushEvent​(org.gitlab4j.api.webhook.TagPushEvent tagPushEvent)  
      protected void fireWikiPageEvent​(org.gitlab4j.api.webhook.WikiPageEvent wikiPageEvent)  
      protected void fireWorkItemEvent​(org.gitlab4j.api.webhook.WorkItemEvent workItemEvent)  
      java.lang.String getSecretToken()
      Get the secret token that received hook events should be validated against.
      void handleEvent​(jakarta.servlet.http.HttpServletRequest request)
      Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.
      void handleEvent​(org.gitlab4j.api.webhook.Event event)
      Verifies the provided Event and fires it off to the registered listeners.
      org.gitlab4j.api.webhook.Event handleRequest​(jakarta.servlet.http.HttpServletRequest request)
      Parses and verifies an Event instance from the HTTP request and fires it off to the registered listeners.
      void removeListener​(org.gitlab4j.api.webhook.WebHookListener listener)
      Removes a WebHook event listener.
      void setSecretToken​(java.lang.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, wait
    • Constructor Detail

      • WebHookManager

        public WebHookManager()
        Create a HookManager to handle GitLab webhook events.
      • WebHookManager

        public WebHookManager​(java.lang.String secretToken)
        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 Detail

      • getSecretToken

        public java.lang.String getSecretToken()
        Get the secret token that received hook events should be validated against.
        Specified by:
        getSecretToken in interface HookManager
        Returns:
        the secret token that received hook events should be validated against
      • setSecretToken

        public void setSecretToken​(java.lang.String secretToken)
        Set the secret token that received hook events should be validated against.
        Specified by:
        setSecretToken in interface HookManager
        Parameters:
        secretToken - the secret token to verify against
      • handleEvent

        public void handleEvent​(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.
        Specified by:
        handleEvent in interface HookManager
        Parameters:
        request - the HttpServletRequest to read the Event instance from
        Throws:
        GitLabApiException - if the parsed event is not supported
      • handleRequest

        public org.gitlab4j.api.webhook.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

        public void handleEvent​(org.gitlab4j.api.webhook.Event event)
                         throws GitLabApiException
        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

        public void addListener​(org.gitlab4j.api.webhook.WebHookListener listener)
        Adds a WebHook event listener.
        Parameters:
        listener - the SystemHookListener to add
      • removeListener

        public void removeListener​(org.gitlab4j.api.webhook.WebHookListener listener)
        Removes a WebHook event listener.
        Parameters:
        listener - the SystemHookListener to remove
      • fireEvent

        public void fireEvent​(org.gitlab4j.api.webhook.Event event)
                       throws GitLabApiException
        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

        protected void fireBuildEvent​(org.gitlab4j.api.webhook.BuildEvent buildEvent)
      • fireIssueEvent

        protected void fireIssueEvent​(org.gitlab4j.api.webhook.IssueEvent issueEvent)
      • fireJobEvent

        protected void fireJobEvent​(org.gitlab4j.api.webhook.JobEvent jobEvent)
      • fireMergeRequestEvent

        protected void fireMergeRequestEvent​(org.gitlab4j.api.webhook.MergeRequestEvent mergeRequestEvent)
      • fireNoteEvent

        protected void fireNoteEvent​(org.gitlab4j.api.webhook.NoteEvent noteEvent)
      • firePipelineEvent

        protected void firePipelineEvent​(org.gitlab4j.api.webhook.PipelineEvent pipelineEvent)
      • firePushEvent

        protected void firePushEvent​(org.gitlab4j.api.webhook.PushEvent pushEvent)
      • fireTagPushEvent

        protected void fireTagPushEvent​(org.gitlab4j.api.webhook.TagPushEvent tagPushEvent)
      • fireWikiPageEvent

        protected void fireWikiPageEvent​(org.gitlab4j.api.webhook.WikiPageEvent wikiPageEvent)
      • fireDeploymentEvent

        protected void fireDeploymentEvent​(org.gitlab4j.api.webhook.DeploymentEvent deploymentEvent)
      • fireWorkItemEvent

        protected void fireWorkItemEvent​(org.gitlab4j.api.webhook.WorkItemEvent workItemEvent)
      • fireReleaseEvent

        protected void fireReleaseEvent​(org.gitlab4j.api.webhook.ReleaseEvent releaseEvent)