Class SystemHookManager

  • All Implemented Interfaces:
    HookManager

    public class SystemHookManager
    extends Object
    implements HookManager
    This class provides a handler for processing GitLab System Hook callouts.
    • Constructor Detail

      • SystemHookManager

        public SystemHookManager()
        Create a HookManager to handle GitLab system hook events.
      • SystemHookManager

        public SystemHookManager​(String secretToken)
        Create a HookManager to handle GitLab system hook events which will be verified against the specified secretToken.
        Parameters:
        secretToken - the secret token to verify against
    • Method Detail

      • getSecretToken

        public 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​(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​(javax.servlet.http.HttpServletRequest request)
                         throws GitLabApiException
        Parses and verifies an SystemHookEvent 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 SystemHookEvent handleRequest​(javax.servlet.http.HttpServletRequest request)
                                      throws GitLabApiException
        Parses and verifies an SystemHookEvent 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 processed SystemHookEvent instance read from the request,null if the request not contain a system hook event
        Throws:
        GitLabApiException - if the parsed event is not supported
      • handleEvent

        public void handleEvent​(SystemHookEvent 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​(SystemHookListener listener)
        Adds a System Hook event listener.
        Parameters:
        listener - the SystemHookListener to add
      • removeListener

        public void removeListener​(SystemHookListener listener)
        Removes a System Hook event listener.
        Parameters:
        listener - the SystemHookListener to remove
      • fireEvent

        public void fireEvent​(SystemHookEvent event)
                       throws GitLabApiException
        Fire the event to the registered listeners.
        Parameters:
        event - the SystemHookEvent instance to fire to the registered event listeners
        Throws:
        GitLabApiException - if the event is not supported