Class WebhookServiceImpl
java.lang.Object
io.meeds.gamification.github.services.impl.WebhookServiceImpl
- All Implemented Interfaces:
WebhookService
-
Constructor Summary
ConstructorsConstructorDescriptionWebhookServiceImpl(org.exoplatform.commons.api.settings.SettingService settingService, WebHookStorage webHookStorage, GithubConsumerService githubServiceConsumer, io.meeds.gamification.service.RuleService ruleService) -
Method Summary
Modifier and TypeMethodDescriptionintcountWebhooks(String currentUser, boolean forceUpdate) Count all gitHub webhookscreateWebhook(String organizationName, String accessToken, String currentUser) create github organization hook.voiddeleteWebhook(long organizationId) voiddeleteWebhook(long organizationId, String currentUser) delete gitHub webhookvoidForce update the stored github organization webhooks if there is a change to the remote webhooks, such as an entity deletion or the update eventgetWebhookId(long webhookId) Retrieves a webHook identified by its technical identifier.getWebhookId(long webhookId, String username) Retrieves a webHook identified by its technical identifier accessed by a usergetWebhooks(int offset, int limit) getWebhooks(int offset, int limit, boolean forceUpdate) Get available github hooks using offset and limit.getWebhooks(String currentUser, int offset, int limit, boolean forceUpdate) Get available github hooks using offset and limit.booleanisWebHookRepositoryEnabled(long organizationId, long repositoryId) Check if webhook repository is enabledbooleanisWebHookRepositoryEnabled(String payload) Check if webhook repository is enabledbooleanisWebHookWatchLimitEnabled(long organizationId) Check if webhook watch limit is enabledretrieveOrganizationRepos(long organizationRemoteId, String currentUser, int page, int perPage, String keyword) Retrieve available github organization repositories.voidsetWebHookRepositoryEnabled(long organizationId, long repositoryId, boolean enabled, String currentUser) enables/disables repositoryvoidsetWebHookWatchLimitEnabled(long organizationId, boolean enabled, String currentUser) Limit webhook watch scope or notvoidupdateWebHookAccessToken(long webHookId, String accessToken, String currentUser) Update github organization hook.booleanverifyWebhookSecret(String payload, String signature)
-
Constructor Details
-
WebhookServiceImpl
public WebhookServiceImpl(org.exoplatform.commons.api.settings.SettingService settingService, WebHookStorage webHookStorage, GithubConsumerService githubServiceConsumer, io.meeds.gamification.service.RuleService ruleService)
-
-
Method Details
-
getWebhooks
public List<WebHook> getWebhooks(String currentUser, int offset, int limit, boolean forceUpdate) throws IllegalAccessException Description copied from interface:WebhookServiceGet available github hooks using offset and limit.- Specified by:
getWebhooksin interfaceWebhookService- Parameters:
currentUser- user name attempting to access connector hooksoffset- Offset of resultlimit- Limit of resultforceUpdate- force Load remote webhook or not.- Returns:
ListofWebHook- 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:WebhookServiceRetrieves a webHook identified by its technical identifier accessed by a user- Specified by:
getWebhookIdin interfaceWebhookService- Parameters:
webhookId- WebHook technical identifierusername- user name attempting to access connector webhook- Returns:
- found
WebHook - Throws:
IllegalAccessException- when user is not authorized to access webhookorg.exoplatform.commons.exception.ObjectNotFoundException- webhook not found
-
getWebhookId
Description copied from interface:WebhookServiceRetrieves a webHook identified by its technical identifier.- Specified by:
getWebhookIdin interfaceWebhookService- Parameters:
webhookId- WebHook technical identifier- Returns:
- found
WebHook
-
getWebhooks
Description copied from interface:WebhookServiceGet available github hooks using offset and limit.- Specified by:
getWebhooksin interfaceWebhookService- Parameters:
offset- Offset of resultlimit- Limit of resultforceUpdate- force Load remote webhooks or not.- Returns:
ListofWebHook
-
getWebhooks
-
countWebhooks
Description copied from interface:WebhookServiceCount all gitHub webhooks- Specified by:
countWebhooksin interfaceWebhookService- Parameters:
currentUser- User name accessing webhooksforceUpdate- force Load remote webhooks count or not.- Returns:
- webhooks count
- Throws:
IllegalAccessException- when user is not authorized to get github webhooks
-
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:WebhookServicecreate github organization hook.- Specified by:
createWebhookin interfaceWebhookService- Parameters:
organizationName- github organization nameaccessToken- gitHub personal access tokencurrentUser- user name attempting to create github hook- Returns:
WebHook- Throws:
org.exoplatform.commons.ObjectAlreadyExistsException- when webhook already existsIllegalAccessException- when user is not authorized to create github webhookorg.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:WebhookServiceUpdate github organization hook.- Specified by:
updateWebHookAccessTokenin interfaceWebhookService- Parameters:
webHookId- webHook IdaccessToken- gitHub personal access tokencurrentUser- user name attempting to update github hook- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
deleteWebhook
public void deleteWebhook(long organizationId, String currentUser) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:WebhookServicedelete gitHub webhook- Specified by:
deleteWebhookin interfaceWebhookService- Parameters:
organizationId- github remote organization idcurrentUser- user name attempting to delete gitHub hook- Throws:
IllegalAccessException- when user is not authorized to delete the gitHub hookorg.exoplatform.commons.exception.ObjectNotFoundException
-
deleteWebhook
public void deleteWebhook(long organizationId) -
forceUpdateWebhooks
public void forceUpdateWebhooks()Description copied from interface:WebhookServiceForce 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:
forceUpdateWebhooksin interfaceWebhookService
-
verifyWebhookSecret
- Specified by:
verifyWebhookSecretin interfaceWebhookService- 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
Description copied from interface:WebhookServiceCheck if webhook repository is enabled- Specified by:
isWebHookRepositoryEnabledin interfaceWebhookService- 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:WebhookServiceCheck if webhook repository is enabled- Specified by:
isWebHookRepositoryEnabledin interfaceWebhookService- Parameters:
organizationId- gitHub organization remote IdrepositoryId- 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:WebhookServiceenables/disables repository- Specified by:
setWebHookRepositoryEnabledin interfaceWebhookService- Parameters:
organizationId- gitHub organization remote IdrepositoryId- gitHub repository remote Idenabled- true to enabled, else falsecurrentUser- 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:WebhookServiceCheck if webhook watch limit is enabled- Specified by:
isWebHookWatchLimitEnabledin interfaceWebhookService- Parameters:
organizationId- gitHub organization remote Id- Returns:
- true if webHook watch limit is enabled, else false.
-
setWebHookWatchLimitEnabled
public void setWebHookWatchLimitEnabled(long organizationId, boolean enabled, String currentUser) throws IllegalAccessException Description copied from interface:WebhookServiceLimit webhook watch scope or not- Specified by:
setWebHookWatchLimitEnabledin interfaceWebhookService- Parameters:
organizationId- gitHub organization remote Idenabled- true to enabled, else falsecurrentUser- user name attempting to enables/disables webHook watch limit.- Throws:
IllegalAccessException- when user is not authorized Limit webhook watch scope
-
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:WebhookServiceRetrieve available github organization repositories.- Specified by:
retrieveOrganizationReposin interfaceWebhookService- Parameters:
organizationRemoteId- gitHub organization remote IdcurrentUser- user name attempting to access remote organization repositoriespage- pageperPage- perPagekeyword- to search in repositories title- Returns:
ListofRemoteRepository- Throws:
IllegalAccessException- when user is not authorized to access remote organization repositoriesorg.exoplatform.commons.exception.ObjectNotFoundException
-