archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1176110 - in /archiva/trunk/archiva-modules: archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/prox...
Date Mon, 26 Sep 2011 22:48:28 GMT
Author: olamy
Date: Mon Sep 26 22:48:28 2011
New Revision: 1176110

URL: http://svn.apache.org/viewvc?rev=1176110&view=rev
Log:
[MRM-1524] downloading (optionnaly) remote index to display remote artifacts in search results
: include remote repos when searching

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/proxyconnector/ProxyConnectorAdmin.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java?rev=1176110&r1=1176109&r2=1176110&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
Mon Sep 26 22:48:28 2011
@@ -21,7 +21,9 @@ package org.apache.archiva.indexer.searc
 
 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;
     }
 
 

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/proxyconnector/ProxyConnectorAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/proxyconnector/ProxyConnectorAdmin.java?rev=1176110&r1=1176109&r2=1176110&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/proxyconnector/ProxyConnectorAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/proxyconnector/ProxyConnectorAdmin.java
Mon Sep 26 22:48:28 2011
@@ -47,15 +47,19 @@ public interface ProxyConnectorAdmin
 
     /**
      * <b>only for enabled/disable or changing bean values except target/source</b>
+     *
      * @param proxyConnector
      * @param auditInformation
      * @return
      * @throws RepositoryAdminException
      */
     Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation
)
-            throws RepositoryAdminException;
-
+        throws RepositoryAdminException;
 
+    /**
+     * @return key/value : managed repo Id / list to proxy connector ordered
+     * @throws RepositoryAdminException
+     */
     Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
         throws RepositoryAdminException;
 

Modified: archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java?rev=1176110&r1=1176109&r2=1176110&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
(original)
+++ archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
Mon Sep 26 22:48:28 2011
@@ -34,6 +34,7 @@ import org.apache.archiva.configuration.
 import org.apache.archiva.proxy.common.WagonFactory;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.index.NexusIndexer;
+import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
 import org.apache.maven.index.updater.IndexUpdater;
 import org.slf4j.Logger;
@@ -43,6 +44,7 @@ import org.springframework.scheduling.su
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Named;
 import java.io.File;
@@ -142,6 +144,22 @@ public class DefaultDownloadRemoteIndexS
 
     }
 
+    @PreDestroy
+    private void shutdown()
+        throws RepositoryAdminException, IOException
+    {
+        for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories()
)
+        {
+            String contextKey = "remote-" + remoteRepository.getId();
+            IndexingContext context = nexusIndexer.getIndexingContexts().get( contextKey
);
+            if ( context == null )
+            {
+                continue;
+            }
+            nexusIndexer.removeIndexingContext( context, false );
+        }
+    }
+
     public void configurationEvent( ConfigurationEvent event )
     {
         // TODO remove jobs and add again



Mime
View raw message