Class WebhookServiceImpl

java.lang.Object
io.meeds.github.gamification.services.impl.WebhookServiceImpl
All Implemented Interfaces:
WebhookService

@Primary @Service public class WebhookServiceImpl extends Object implements WebhookService
  • Constructor Details

    • WebhookServiceImpl

      public WebhookServiceImpl()
  • Method Details

    • getWebhooks

      public org.springframework.data.domain.Page<WebHook> getWebhooks(String currentUser, org.springframework.data.domain.Pageable pageable) throws IllegalAccessException
      Description copied from interface: WebhookService
      Get available github hooks using offset and limit.
      Specified by:
      getWebhooks in interface WebhookService
      Parameters:
      currentUser - user name attempting to access connector hooks
      pageable - Pageable the page to be returned.
      Returns:
      Pageable of WebHook
      Throws:
      IllegalAccessException - when user is not authorized to access github hooks
    • getWebhookId

      public WebHook getWebhookId(long webhookId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: WebhookService
      Retrieves a webHook identified by its technical identifier accessed by a user
      Specified by:
      getWebhookId in interface WebhookService
      Parameters:
      webhookId - WebHook technical identifier
      username - user name attempting to access connector webhook
      Returns:
      found WebHook
      Throws:
      IllegalAccessException - when user is not authorized to access webhook
      org.exoplatform.commons.exception.ObjectNotFoundException - webhook not found
    • getWebhookId

      public WebHook getWebhookId(long webhookId)
      Description copied from interface: WebhookService
      Retrieves a webHook identified by its technical identifier.
      Specified by:
      getWebhookId in interface WebhookService
      Parameters:
      webhookId - WebHook technical identifier
      Returns:
      found WebHook
    • getWebhooks

      public org.springframework.data.domain.Page<WebHook> getWebhooks(org.springframework.data.domain.Pageable pageable)
    • createWebhook

      public WebHook createWebhook(String organizationName, String accessToken, String currentUser) throws org.exoplatform.commons.ObjectAlreadyExistsException, IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: WebhookService
      create github organization hook.
      Specified by:
      createWebhook in interface WebhookService
      Parameters:
      organizationName - github organization name
      accessToken - gitHub personal access token
      currentUser - user name attempting to create github hook
      Returns:
      WebHook
      Throws:
      org.exoplatform.commons.ObjectAlreadyExistsException - when webhook already exists
      IllegalAccessException - when user is not authorized to create github webhook
      org.exoplatform.commons.exception.ObjectNotFoundException - when the github organization identified by its technical name is not found
    • updateWebHookAccessToken

      public void updateWebHookAccessToken(long webHookId, String accessToken, String currentUser) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: WebhookService
      Update github organization hook.
      Specified by:
      updateWebHookAccessToken in interface WebhookService
      Parameters:
      webHookId - webHook Id
      accessToken - gitHub personal access token
      currentUser - user name attempting to update github hook
      Throws:
      IllegalAccessException
      org.exoplatform.commons.exception.ObjectNotFoundException
    • deleteWebhook

      public void deleteWebhook(long organizationId, String currentUser) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: WebhookService
      delete gitHub webhook
      Specified by:
      deleteWebhook in interface WebhookService
      Parameters:
      organizationId - github remote organization id
      currentUser - user name attempting to delete gitHub hook
      Throws:
      IllegalAccessException - when user is not authorized to delete the gitHub hook
      org.exoplatform.commons.exception.ObjectNotFoundException
    • deleteWebhook

      public void deleteWebhook(long organizationId)
    • verifyWebhookSecret

      public boolean verifyWebhookSecret(String payload, String signature)
      Specified by:
      verifyWebhookSecret in interface WebhookService
      Parameters:
      payload - payload The raw payload of the webhook request.
      signature - The signature received from the external system.
      Returns:
      true if the computed signature matches the provided signature.
    • isWebHookRepositoryEnabled

      public boolean isWebHookRepositoryEnabled(String payload)
      Description copied from interface: WebhookService
      Check if webhook repository is enabled
      Specified by:
      isWebHookRepositoryEnabled in interface WebhookService
      Parameters:
      payload - payload The raw payload of the webhook request.
      Returns:
      true if the intended repository is enabled, else false.
    • isWebHookRepositoryEnabled

      public boolean isWebHookRepositoryEnabled(long organizationId, long repositoryId)
      Description copied from interface: WebhookService
      Check if webhook repository is enabled
      Specified by:
      isWebHookRepositoryEnabled in interface WebhookService
      Parameters:
      organizationId - gitHub organization remote Id
      repositoryId - gitHub repository remote Id
      Returns:
      true if the intended repository is enabled, else false.
    • setWebHookRepositoryEnabled

      public void setWebHookRepositoryEnabled(long organizationId, long repositoryId, boolean enabled, String currentUser) throws IllegalAccessException
      Description copied from interface: WebhookService
      enables/disables repository
      Specified by:
      setWebHookRepositoryEnabled in interface WebhookService
      Parameters:
      organizationId - gitHub organization remote Id
      repositoryId - gitHub repository remote Id
      enabled - true to enabled, else false
      currentUser - user name attempting to enables/disables repository.
      Throws:
      IllegalAccessException - when user is not authorized enables/disables repository
    • isWebHookWatchLimitEnabled

      public boolean isWebHookWatchLimitEnabled(long organizationId)
      Description copied from interface: WebhookService
      Check if webhook watch limit is enabled
      Specified by:
      isWebHookWatchLimitEnabled in interface WebhookService
      Parameters:
      organizationId - gitHub organization remote Id
      Returns:
      true if webHook watch limit is enabled, else false.
    • retrieveOrganizationRepos

      public List<RemoteRepository> retrieveOrganizationRepos(long organizationRemoteId, String currentUser, int page, int perPage, String keyword) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: WebhookService
      Retrieve available github organization repositories.
      Specified by:
      retrieveOrganizationRepos in interface WebhookService
      Parameters:
      organizationRemoteId - gitHub organization remote Id
      currentUser - user name attempting to access remote organization repositories
      page - page
      perPage - perPage
      keyword - to search in repositories title
      Returns:
      List of RemoteRepository
      Throws:
      IllegalAccessException - when user is not authorized to access remote organization repositories
      org.exoplatform.commons.exception.ObjectNotFoundException
    • forceUpdateWebhooks

      public void forceUpdateWebhooks()
      Description copied from interface: WebhookService
      Force update the stored github organization webhooks if there is a change to the remote webhooks, such as an entity deletion or the update event
      Specified by:
      forceUpdateWebhooks in interface WebhookService