diff options
author | Olivier Lamy <olamy@apache.org> | 2011-09-26 22:48:28 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-09-26 22:48:28 +0000 |
commit | 276eaf0b5ddabe7c48dfc9bb5df03204e9b215a4 (patch) | |
tree | 6bc268f37c1ba7aca58c32af248d068bd2be0d26 /archiva-modules/archiva-base/archiva-indexer | |
parent | ae7be0e0490495d869881e2e95b4a549e2cfdce3 (diff) | |
download | archiva-276eaf0b5ddabe7c48dfc9bb5df03204e9b215a4.tar.gz archiva-276eaf0b5ddabe7c48dfc9bb5df03204e9b215a4.zip |
[MRM-1524] downloading (optionnaly) remote index to display remote artifacts in search results : include remote repos when searching
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176110 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-indexer')
-rw-r--r-- | archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java index fb5986f56..c5e441d6a 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java @@ -21,7 +21,9 @@ package org.apache.archiva.indexer.search; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; +import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; +import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; @@ -48,6 +50,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -65,17 +68,19 @@ public class NexusRepositorySearch private ManagedRepositoryAdmin managedRepositoryAdmin; + private ProxyConnectorAdmin proxyConnectorAdmin; + private MavenIndexerUtils mavenIndexerUtils; @Inject public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ManagedRepositoryAdmin managedRepositoryAdmin, - MavenIndexerUtils mavenIndexerUtils ) + MavenIndexerUtils mavenIndexerUtils, ProxyConnectorAdmin proxyConnectorAdmin ) throws PlexusSisuBridgeException { this.indexer = plexusSisuBridge.lookup( NexusIndexer.class ); this.managedRepositoryAdmin = managedRepositoryAdmin; this.mavenIndexerUtils = mavenIndexerUtils; - + this.proxyConnectorAdmin = proxyConnectorAdmin; } /** @@ -308,7 +313,7 @@ public class NexusRepositorySearch */ private List<String> addIndexingContexts( List<String> selectedRepos ) { - List<String> indexingContextIds = new ArrayList<String>(); + Set<String> indexingContextIds = new HashSet<String>(); for ( String repo : selectedRepos ) { try @@ -336,6 +341,7 @@ public class NexusRepositorySearch // set searchable flag context.setSearchable( repoConfig.isScanned() ); indexingContextIds.add( context.getId() ); + indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) ); continue; } @@ -345,6 +351,7 @@ public class NexusRepositorySearch context.setSearchable( repoConfig.isScanned() ); if ( context.isSearchable() ) { + indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) ); indexingContextIds.add( context.getId() ); } else @@ -375,7 +382,34 @@ public class NexusRepositorySearch continue; } } - return indexingContextIds; + + return new ArrayList<String>( indexingContextIds ); + } + + + private Set<String> getRemoteIndexingContextIds( String managedRepoId ) + throws RepositoryAdminException + { + Set<String> ids = new HashSet<String>(); + + List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId ); + + if ( proxyConnectors == null || proxyConnectors.isEmpty() ) + { + return ids; + } + + for ( ProxyConnector proxyConnector : proxyConnectors ) + { + String remoteId = "remote-" + proxyConnector.getTargetRepoId(); + IndexingContext context = indexer.getIndexingContexts().get( remoteId ); + if ( context != null && context.isSearchable() ) + { + ids.add( remoteId ); + } + } + + return ids; } |