Class DefaultMirrorSelector

  • All Implemented Interfaces:
    MirrorSelector

    public final class DefaultMirrorSelector
    extends java.lang.Object
    implements MirrorSelector
    A simple mirror selector that selects mirrors based on repository identifiers.
    • Constructor Detail

      • DefaultMirrorSelector

        public DefaultMirrorSelector()
    • Method Detail

      • add

        public DefaultMirrorSelector add​(java.lang.String id,
                                         java.lang.String url,
                                         java.lang.String type,
                                         boolean repositoryManager,
                                         java.lang.String mirrorOfIds,
                                         java.lang.String mirrorOfTypes)
        Adds the specified mirror to this selector.
        Parameters:
        id - The identifier of the mirror, must not be null.
        url - The URL of the mirror, must not be null.
        type - The content type of the mirror, must not be null.
        repositoryManager - A flag whether the mirror is a repository manager or a simple server.
        mirrorOfIds - The identifier(s) of remote repositories to mirror, must not be null. Multiple identifiers can be separated by comma and additionally the wildcards "*" and "external:*" can be used to match all (external) repositories, prefixing a repo id with an exclamation mark allows to express an exclusion. For example "external:*,!central".
        mirrorOfTypes - The content type(s) of remote repositories to mirror, may be null or empty to match any content type. Similar to the repo id specification, multiple types can be comma-separated, the wildcard "*" and the "!" negation syntax are supported. For example "*,!p2".
        Returns:
        This selector for chaining, never null.
      • matchPattern

        static boolean matchPattern​(RemoteRepository repository,
                                    java.lang.String pattern)
        This method checks if the pattern matches the originalRepository. Valid patterns: * = everything external:* = everything not on the localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1
        Parameters:
        repository - to compare for a match.
        pattern - used for match. Currently only '*' is supported.
        Returns:
        true if the repository is a match to this pattern.
      • isExternalRepo

        static boolean isExternalRepo​(RemoteRepository repository)
        Checks the URL to see if this repository refers to an external repository.
        Parameters:
        repository - The repository to check, must not be null.
        Returns:
        true if external, false otherwise.
      • matchesType

        static boolean matchesType​(java.lang.String repoType,
                                   java.lang.String mirrorType)
        Checks whether the types configured for a mirror match with the type of the repository.
        Parameters:
        repoType - The type of the repository, may be null.
        mirrorType - The types supported by the mirror, may be null.
        Returns:
        true if the types associated with the mirror match the type of the original repository, false otherwise.