@Test public void testAggregateMirrorRepos_DominantMirrorIncomplete() { RemoteRepository dominant1 = newRepo( "a", "http: RemoteRepository dominantMirror1 = newRepo( "x", "file: RemoteRepository recessive1 = newRepo( "a", "https: RemoteRepository recessive2 = newRepo( "b", "https: RemoteRepository recessiveMirror1 = newRepo( "x", "http: List<RemoteRepository> result = manager.aggregateRepositories( session, Arrays.asList( dominantMirror1 ), Arrays.asList( recessiveMirror1 ), false ); assertEquals( 1, result.size() ); assertEqual( newRepo( "x", "file: assertEquals( 2, result.get( 0 ).getMirroredRepositories().size() ); assertEquals( dominant1, result.get( 0 ).getMirroredRepositories().get( 0 ) ); assertEquals( recessive2, result.get( 0 ).getMirroredRepositories().get( 1 ) ); }
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 );  }