Class BitbucketSeverMirrorHelper


  • @Service
    public class BitbucketSeverMirrorHelper
    extends Object
    • Constructor Detail

      • BitbucketSeverMirrorHelper

        public BitbucketSeverMirrorHelper()
    • Method Detail

      • isBitbucketServerVersionMirrorsSupported

        public boolean isBitbucketServerVersionMirrorsSupported​(com.atlassian.stash.rest.client.api.StashClient stashClient)

        Checks if given Bitbucket Server is supported.

        Smart mirroring is supported only for Bibtucket Server versions >= 5.0.0 with DC license.

      • getRepositoryMirrors

        public List<StashMirrorServerEntity> getRepositoryMirrors​(com.atlassian.stash.rest.client.api.StashClient stashClient,
                                                                  String projectKey,
                                                                  String repositorySlug)
                                                           throws IllegalArgumentException
        Reads all mirrors for a given repository
        Parameters:
        stashClient - stash client corresponding to the BBS instance serving the repository
        projectKey - key of the project containing the repository
        repositorySlug - slug of the repository
        Returns:
        list of mirrors for specified repository
        Throws:
        IllegalArgumentException - when can't find repository by projectKey and repositorySlug.
      • getRepositoryMirrors

        public List<StashMirrorServerEntity> getRepositoryMirrors​(com.atlassian.stash.rest.client.api.StashClient stashClient,
                                                                  String projectKey,
                                                                  String repositorySlug,
                                                                  Predicate<com.atlassian.stash.rest.client.api.entity.MirrorServer> filter)
                                                           throws IllegalArgumentException
        Reads all mirrors for a given repository
        Parameters:
        stashClient - stash client corresponding to the BBS instance serving the repository
        projectKey - key of the project containing the repository
        repositorySlug - slug of the repository
        filter - for mirror. Applied before ssh details fetching from BBS.
        Returns:
        list of mirrors for specified repository
        Throws:
        IllegalArgumentException - when can't find repository by projectKey and repositorySlug.
      • findSpecifiedMirror

        @NotNull
        public @NotNull Optional<StashMirrorServerEntity> findSpecifiedMirror​(com.atlassian.stash.rest.client.api.StashClient stashClient,
                                                                              String projectKey,
                                                                              String repositorySlug,
                                                                              @NotNull
                                                                              @NotNull com.atlassian.bamboo.specs.model.repository.bitbucket.server.BitbucketServerMirrorProperties mirrorProperties)
        Finds mirror specified by mirrorProperties on the list
        Parameters:
        stashClient - stash client corresponding to the BBS instance serving the repository
        projectKey - key of the project containing the repository
        repositorySlug - slug of the repository
        mirrorProperties - mirror specification
        Returns:
        optional containing the mirror (if found)