@Test public void testMirrorAuthentication() { final RemoteRepository repo = newRepo( "a", "http: final RemoteRepository mirror = newRepo( "a", "http: session.setMirrorSelector( new MirrorSelector() { public RemoteRepository getMirror( RemoteRepository repository ) { return mirror; } } ); List<RemoteRepository> result = manager.aggregateRepositories( session, Collections.<RemoteRepository> emptyList(), Arrays.asList( repo ), true ); assertEquals( 1, result.size() ); assertSame( mirror.getAuthentication(), result.get( 0 ).getAuthentication() ); }
public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw ) { if ( recessiveRepositories.isEmpty() ) { return dominantRepositories; } MirrorSelector mirrorSelector = session.getMirrorSelector(); AuthenticationSelector authSelector = session.getAuthenticationSelector(); ProxySelector proxySelector = session.getProxySelector(); List<RemoteRepository> result = new ArrayList<RemoteRepository>( dominantRepositories ); next: for ( RemoteRepository recessiveRepository : recessiveRepositories ) { RemoteRepository repository = recessiveRepository; if ( recessiveIsRaw ) { RemoteRepository mirrorRepository = mirrorSelector.getMirror( recessiveRepository ); if ( mirrorRepository != null ) { logMirror( session, recessiveRepository, mirrorRepository ); repository = mirrorRepository; } } String key = getKey( repository ); for ( ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) { RemoteRepository dominantRepository = it.next(); if ( key.equals( getKey( dominantRepository ) ) ) { if ( !dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty() ) { RemoteRepository mergedRepository = mergeMirrors( session, dominantRepository, repository ); if ( mergedRepository != dominantRepository ) { it.set( mergedRepository ); } } continue next; } } if ( recessiveIsRaw ) { RemoteRepository.Builder builder = null; Authentication auth = authSelector.getAuthentication( repository ); if ( auth != null ) { builder = new RemoteRepository.Builder( repository ); builder.setAuthentication( auth ); } Proxy proxy = proxySelector.getProxy( repository ); if ( proxy != null ) { if ( builder == null ) { builder = new RemoteRepository.Builder( repository ); } builder.setProxy( proxy ); } if ( builder != null ) { repository = builder.build(); } } result.add( repository ); } return result; }
DefaultRemoteRepositoryManager implements RemoteRepositoryManager, Service { public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw ) { if ( recessiveRepositories.isEmpty() ) { return dominantRepositories; } MirrorSelector mirrorSelector = session.getMirrorSelector(); AuthenticationSelector authSelector = session.getAuthenticationSelector(); ProxySelector proxySelector = session.getProxySelector(); List<RemoteRepository> result = new ArrayList<RemoteRepository>( dominantRepositories ); next: for ( RemoteRepository recessiveRepository : recessiveRepositories ) { RemoteRepository repository = recessiveRepository; if ( recessiveIsRaw ) { RemoteRepository mirrorRepository = mirrorSelector.getMirror( recessiveRepository ); if ( mirrorRepository != null ) { logMirror( session, recessiveRepository, mirrorRepository ); repository = mirrorRepository; } } String key = getKey( repository ); for ( ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) { RemoteRepository dominantRepository = it.next(); if ( key.equals( getKey( dominantRepository ) ) ) { if ( !dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty() ) { RemoteRepository mergedRepository = mergeMirrors( session, dominantRepository, repository ); if ( mergedRepository != dominantRepository ) { it.set( mergedRepository ); } } continue next; } } if ( recessiveIsRaw ) { RemoteRepository.Builder builder = null; Authentication auth = authSelector.getAuthentication( repository ); if ( auth != null ) { builder = new RemoteRepository.Builder( repository ); builder.setAuthentication( auth ); } Proxy proxy = proxySelector.getProxy( repository ); if ( proxy != null ) { if ( builder == null ) { builder = new RemoteRepository.Builder( repository ); } builder.setProxy( proxy ); } if ( builder != null ) { repository = builder.build(); } } result.add( repository ); } return result; } }
DefaultRemoteRepositoryManager implements RemoteRepositoryManager, Service { public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw ) { if ( recessiveRepositories.isEmpty() ) { return dominantRepositories; } MirrorSelector mirrorSelector = session.getMirrorSelector(); AuthenticationSelector authSelector = session.getAuthenticationSelector(); ProxySelector proxySelector = session.getProxySelector(); List<RemoteRepository> result = new ArrayList<RemoteRepository>( dominantRepositories ); next: for ( RemoteRepository recessiveRepository : recessiveRepositories ) { RemoteRepository repository = recessiveRepository; if ( recessiveIsRaw ) { RemoteRepository mirrorRepository = mirrorSelector.getMirror( recessiveRepository ); if ( mirrorRepository != null ) { logMirror( session, recessiveRepository, mirrorRepository ); repository = mirrorRepository; } } String key = getKey( repository ); for ( ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) { RemoteRepository dominantRepository = it.next(); if ( key.equals( getKey( dominantRepository ) ) ) { if ( !dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty() ) { RemoteRepository mergedRepository = mergeMirrors( session, dominantRepository, repository ); if ( mergedRepository != dominantRepository ) { it.set( mergedRepository ); } } continue next; } } if ( recessiveIsRaw ) { RemoteRepository.Builder builder = null; Authentication auth = authSelector.getAuthentication( repository ); if ( auth != null ) { builder = new RemoteRepository.Builder( repository ); builder.setAuthentication( auth ); } Proxy proxy = proxySelector.getProxy( repository ); if ( proxy != null ) { if ( builder == null ) { builder = new RemoteRepository.Builder( repository ); } builder.setProxy( proxy ); } if ( builder != null ) { repository = builder.build(); } } result.add( repository ); } return result; } DefaultRemoteRepositoryManager(); @Inject  DefaultRemoteRepositoryManager( UpdatePolicyAnalyzer updatePolicyAnalyzer,
                                    ChecksumPolicyProvider checksumPolicyProvider, LoggerFactory loggerFactory ); }
DefaultRemoteRepositoryManager implements RemoteRepositoryManager, Service { public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw ) { if ( recessiveRepositories.isEmpty() ) { return dominantRepositories; } MirrorSelector mirrorSelector = session.getMirrorSelector(); AuthenticationSelector authSelector = session.getAuthenticationSelector(); ProxySelector proxySelector = session.getProxySelector(); List<RemoteRepository> result = new ArrayList<RemoteRepository>( dominantRepositories ); next: for ( RemoteRepository recessiveRepository : recessiveRepositories ) { RemoteRepository repository = recessiveRepository; if ( recessiveIsRaw ) { RemoteRepository mirrorRepository = mirrorSelector.getMirror( recessiveRepository ); if ( mirrorRepository != null ) { logMirror( session, recessiveRepository, mirrorRepository ); repository = mirrorRepository; } } String key = getKey( repository ); for ( ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) { RemoteRepository dominantRepository = it.next(); if ( key.equals( getKey( dominantRepository ) ) ) { if ( !dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty() ) { RemoteRepository mergedRepository = mergeMirrors( session, dominantRepository, repository ); if ( mergedRepository != dominantRepository ) { it.set( mergedRepository ); } } continue next; } } if ( recessiveIsRaw ) { RemoteRepository.Builder builder = null; Authentication auth = authSelector.getAuthentication( repository ); if ( auth != null ) { builder = new RemoteRepository.Builder( repository ); builder.setAuthentication( auth ); } Proxy proxy = proxySelector.getProxy( repository ); if ( proxy != null ) { if ( builder == null ) { builder = new RemoteRepository.Builder( repository ); } builder.setProxy( proxy ); } if ( builder != null ) { repository = builder.build(); } } result.add( repository ); } return result; } DefaultRemoteRepositoryManager(); @Inject  DefaultRemoteRepositoryManager( UpdatePolicyAnalyzer updatePolicyAnalyzer,
                                    ChecksumPolicyProvider checksumPolicyProvider, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultRemoteRepositoryManager setLoggerFactory( LoggerFactory loggerFactory ); DefaultRemoteRepositoryManager setUpdatePolicyAnalyzer( UpdatePolicyAnalyzer updatePolicyAnalyzer ); DefaultRemoteRepositoryManager setChecksumPolicyProvider( ChecksumPolicyProvider checksumPolicyProvider ); List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
                                                         List<RemoteRepository> dominantRepositories,
                                                         List<RemoteRepository> recessiveRepositories,
                                                         boolean recessiveIsRaw ); RepositoryPolicy getPolicy( RepositorySystemSession session, RemoteRepository repository, boolean releases,
                                       boolean snapshots ); }
DefaultRemoteRepositoryManager implements RemoteRepositoryManager, Service { public List<RemoteRepository> aggregateRepositories( RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw ) { if ( recessiveRepositories.isEmpty() ) { return dominantRepositories; } MirrorSelector mirrorSelector = session.getMirrorSelector(); AuthenticationSelector authSelector = session.getAuthenticationSelector(); ProxySelector proxySelector = session.getProxySelector(); List<RemoteRepository> result = new ArrayList<RemoteRepository>( dominantRepositories ); next: for ( RemoteRepository recessiveRepository : recessiveRepositories ) { RemoteRepository repository = recessiveRepository; if ( recessiveIsRaw ) { RemoteRepository mirrorRepository = mirrorSelector.getMirror( recessiveRepository ); if ( mirrorRepository != null ) { logMirror( session, recessiveRepository, mirrorRepository ); repository = mirrorRepository; } } String key = getKey( repository ); for ( ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) { RemoteRepository dominantRepository = it.next(); if ( key.equals( getKey( dominantRepository ) ) ) { if ( !dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty() ) { RemoteRepository mergedRepository = mergeMirrors( session, dominantRepository, repository ); if ( mergedRepository != dominantRepository ) { it.set( mergedRepository ); } } continue next; } } if ( recessiveIsRaw ) { RemoteRepository.Builder builder = null; Authentication auth = authSelector.getAuthentication( repository ); if ( auth != null ) { builder = new RemoteRepository.Builder( repository ); builder.setAuthentication( auth ); } Proxy proxy = proxySelector.getProxy( repository ); if ( proxy != null ) { if ( builder == null ) { builder = new RemoteRepository.Builder( repository ); } builder.setProxy( proxy ); } if ( builder != null ) { repository = builder.build(); } } result.add( repository ); } return result; } DefaultRemoteRepositoryManager(); @Inject  DefaultRemoteRepositoryManager( UpdatePolicyAnalyzer updatePolicyAnalyzer,
                                    ChecksumPolicyProvider checksumPolicyProvider, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultRemoteRepositoryManager setLoggerFactory( LoggerFactory loggerFactory ); DefaultRemoteRepositoryManager setUpdatePolicyAnalyzer( UpdatePolicyAnalyzer updatePolicyAnalyzer ); DefaultRemoteRepositoryManager setChecksumPolicyProvider( ChecksumPolicyProvider checksumPolicyProvider ); List<RemoteRepository> aggregateRepositories( RepositorySystemSession session,
                                                         List<RemoteRepository> dominantRepositories,
                                                         List<RemoteRepository> recessiveRepositories,
                                                         boolean recessiveIsRaw ); RepositoryPolicy getPolicy( RepositorySystemSession session, RemoteRepository repository, boolean releases,
                                       boolean snapshots );  }