001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.impl;
020
021import java.util.List;
022
023import org.eclipse.aether.RepositorySystemSession;
024import org.eclipse.aether.repository.RemoteRepository;
025import org.eclipse.aether.repository.RepositoryPolicy;
026
027/**
028 * Helps dealing with remote repository definitions.
029 *
030 * @noimplement This interface is not intended to be implemented by clients.
031 * @noextend This interface is not intended to be extended by clients.
032 * @provisional This type is provisional and can be changed, moved or removed without prior notice.
033 */
034public interface RemoteRepositoryManager {
035
036    /**
037     * Aggregates repository definitions by merging duplicate repositories and optionally applies mirror, proxy and
038     * authentication settings from the supplied session.
039     *
040     * @param session The repository session during which the repositories will be accessed, must not be {@code null}.
041     * @param dominantRepositories The current list of remote repositories to merge the new definitions into, must not
042     *            be {@code null}.
043     * @param recessiveRepositories The remote repositories to merge into the existing list, must not be {@code null}.
044     * @param recessiveIsRaw {@code true} if the recessive repository definitions have not yet been subjected to mirror,
045     *            proxy and authentication settings, {@code false} otherwise.
046     *            Repositories that already list mirrored repositories are not subjected to mirror selection again,
047     *            while proxy and authentication selection still apply.
048     * @return The aggregated list of remote repositories, never {@code null}.
049     * @see RepositorySystemSession#getMirrorSelector()
050     * @see RepositorySystemSession#getProxySelector()
051     * @see RepositorySystemSession#getAuthenticationSelector()
052     */
053    List<RemoteRepository> aggregateRepositories(
054            RepositorySystemSession session,
055            List<RemoteRepository> dominantRepositories,
056            List<RemoteRepository> recessiveRepositories,
057            boolean recessiveIsRaw);
058
059    /**
060     * Aggregates repository definitions by merging duplicate repositories and optionally applies mirror, proxy and
061     * authentication settings from the supplied session, additionally distinguishing the provenance of the recessive
062     * repository definitions. Repository definitions that originate from a remote artifact descriptor (i.e. a POM
063     * downloaded during dependency collection) are remotely supplied input: implementations may withhold session
064     * authentication from them unless an operator-defined mirror has been selected for them, so that session
065     * authentication is applied only to repositories the operator configured. Repository definitions supplied
066     * by the build itself (e.g. via
067     * {@code RepositorySystem#newResolutionRepositories}) must keep receiving mirror, proxy and authentication
068     * settings as documented for
069     * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
070     * <p>
071     * The default implementation ignores the provenance hint and delegates to
072     * {@link #aggregateRepositories(RepositorySystemSession, List, List, boolean)}.
073     *
074     * @param session The repository session during which the repositories will be accessed, must not be {@code null}.
075     * @param dominantRepositories The current list of remote repositories to merge the new definitions into, must not
076     *            be {@code null}.
077     * @param recessiveRepositories The remote repositories to merge into the existing list, must not be {@code null}.
078     * @param recessiveIsRaw {@code true} if the recessive repository definitions have not yet been subjected to mirror,
079     *            proxy and authentication settings, {@code false} otherwise.
080     *            Repositories that already list mirrored repositories are not subjected to mirror selection again
081     *            unless they are declared by a remote artifact descriptor; proxy and authentication selection still apply.
082     * @param recessiveIsFromDescriptor {@code true} if the recessive repository definitions were declared by a remote
083     *            artifact descriptor (POM) rather than by the build itself, {@code false} otherwise.
084     * @return The aggregated list of remote repositories, never {@code null}.
085     * @since 2.0.23
086     * @see RepositorySystemSession#getMirrorSelector()
087     * @see RepositorySystemSession#getProxySelector()
088     * @see RepositorySystemSession#getAuthenticationSelector()
089     */
090    default List<RemoteRepository> aggregateRepositories(
091            RepositorySystemSession session,
092            List<RemoteRepository> dominantRepositories,
093            List<RemoteRepository> recessiveRepositories,
094            boolean recessiveIsRaw,
095            boolean recessiveIsFromDescriptor) {
096        return aggregateRepositories(session, dominantRepositories, recessiveRepositories, recessiveIsRaw);
097    }
098
099    /**
100     * Gets the effective repository policy for the specified remote repository by merging the applicable
101     * snapshot/release policy of the repository with global settings from the supplied session.
102     *
103     * @param session The repository session during which the repository will be accessed, must not be {@code null}.
104     * @param repository The remote repository to determine the effective policy for, must not be {@code null}.
105     * @param releases {@code true} if the policy for release artifacts needs to be considered, {@code false} if not.
106     * @param snapshots {@code true} if the policy for snapshot artifacts needs to be considered, {@code false} if not.
107     * @return The effective repository policy, never {@code null}.
108     * @see RepositorySystemSession#getChecksumPolicy()
109     * @see RepositorySystemSession#getUpdatePolicy()
110     */
111    RepositoryPolicy getPolicy(
112            RepositorySystemSession session, RemoteRepository repository, boolean releases, boolean snapshots);
113}