public interface

RepositoryHookService

com.atlassian.bitbucket.hook.repository.RepositoryHookService

Class Overview

Handles the aggregation of hooks and their enabled status. Settings for these hooks are handled elsewhere.

Summary

Public Methods
@Nonnull SettingsBuilder createSettingsBuilder()
Create a new SettingsBuilder which can be used to create a Settings instance.
@Nonnull RepositoryHook disable(Repository repository, String hookKey)
Disable the hook identified by the supplied key for the specified repository.
@Nonnull RepositoryHook enable(Repository repository, String hookKey)
Enable the hook identified by the supplied key for the specified repository.
@Nonnull RepositoryHook enable(Repository repository, String hookKey, Settings settings)
Enable the hook identified by the supplied key for the specified repository and apply the new settings.
@Nonnull Page<RepositoryHook> findAll(Repository repository, PageRequest pageRequest)
Find all installed hooks of the specified repository with their enabled status.
@Nonnull Page<RepositoryHook> findByType(Repository repository, RepositoryHookType type, PageRequest pageRequest)
Find all installed hooks of the specified RepositoryHookType with enabled status for this repository
@Nonnull CacheableAvatarSupplier getAvatar(String hookKey)
Returns a supplier of an avatar for this hook, either one specified in the module or a default.
@Nullable RepositoryHook getByKey(Repository repository, String hookKey)
Find an installed hook with the specified key enabled status for this repository
@Nullable Settings getSettings(Repository repository, String hookKey)
Gets the settings for the specified hook and repository.
@Nonnull Settings setSettings(Repository repository, String hookKey, Settings settings)
Sets the settings for the specified hook and repository.

Public Methods

@Nonnull public SettingsBuilder createSettingsBuilder ()

Create a new SettingsBuilder which can be used to create a Settings instance.

Returns
  • a new builder

@Nonnull public RepositoryHook disable (Repository repository, String hookKey)

Disable the hook identified by the supplied key for the specified repository.

Parameters
repository the repository this hook is being disabled on
hookKey the hook to be disabled
Returns

@Nonnull public RepositoryHook enable (Repository repository, String hookKey)

Enable the hook identified by the supplied key for the specified repository.

Parameters
repository the repository this hook is being enabled on
hookKey the hook to be enabled
Returns

@Nonnull public RepositoryHook enable (Repository repository, String hookKey, Settings settings)

Enable the hook identified by the supplied key for the specified repository and apply the new settings.

This is a convenient method which performs enable(Repository, String) and setSettings(Repository, String, Settings) in the same transaction

Parameters
repository the repository this hook is being enabled on
hookKey the hook to be enabled
settings the new settings.
Returns
Throws
FormValidationException when settings are invalid, leaving the existing version unchanged
ArgumentValidationException if the settings to be saved are too large, the current limit is 32KB once serialized.

@Nonnull public Page<RepositoryHook> findAll (Repository repository, PageRequest pageRequest)

Find all installed hooks of the specified repository with their enabled status.

Parameters
repository the repository to load the hook from
pageRequest paging options
Returns

@Nonnull public Page<RepositoryHook> findByType (Repository repository, RepositoryHookType type, PageRequest pageRequest)

Find all installed hooks of the specified RepositoryHookType with enabled status for this repository

Parameters
repository the repository to load the hook from
type the type of hooks to be looked for
pageRequest paging options
Returns

@Nonnull public CacheableAvatarSupplier getAvatar (String hookKey)

Returns a supplier of an avatar for this hook, either one specified in the module or a default.

Parameters
hookKey the hook key with the desired avatar
Returns
  • an supplier for streaming the avatar

@Nullable public RepositoryHook getByKey (Repository repository, String hookKey)

Find an installed hook with the specified key enabled status for this repository

Parameters
repository the repository to load the hook from
hookKey the hook to lookup
Returns

@Nullable public Settings getSettings (Repository repository, String hookKey)

Gets the settings for the specified hook and repository.

Parameters
repository the repository the settings apply to.
hookKey the complete module key of the hook which the settings are associated with.
Returns
  • the settings currently stored or null if no settings are stored.

@Nonnull public Settings setSettings (Repository repository, String hookKey, Settings settings)

Sets the settings for the specified hook and repository.

Parameters
repository the repository the settings apply to.
hookKey the complete module key of the hook which the settings are associated with.
settings the new settings to save
Returns
  • the settings saved.
Throws
FormValidationException when settings are invalid, leaving the existing version unchanged
ArgumentValidationException if the settings to be saved are too large, the current limit is 32KB once serialized.