]> source.dussan.org Git - archiva.git/commitdiff
more cleanup of direct use of archiva-configuration
authorOlivier Lamy <olamy@apache.org>
Tue, 13 Sep 2011 21:10:05 +0000 (21:10 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 13 Sep 2011 21:10:05 +0000 (21:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170352 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/pom.xml
archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java

index addd28285cf5a622e0d67b287e4f3598addd4ace..2c61d74f6a963294d4564a7448785964f6ec5ddc 100644 (file)
   <artifactId>archiva-indexer</artifactId>
   <name>Archiva Base :: Indexer</name>
   <dependencies>
+
     <dependency>
       <groupId>org.apache.archiva</groupId>
-      <artifactId>archiva-configuration</artifactId>
+      <artifactId>archiva-repository-admin-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.lucene</groupId>
       <groupId>javax.inject</groupId>
       <artifactId>javax.inject</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-configuration</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-admin-default</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
index 1ff81bfbb315aa17b47879618d6de039f1210358..9734179d68722305947409f287356e937484efd1 100644 (file)
@@ -19,6 +19,9 @@ package org.apache.archiva.indexer.search;
  * under the License.
  */
 
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
@@ -26,9 +29,6 @@ import org.apache.archiva.indexer.util.SearchUtil;
 import org.apache.commons.lang.StringUtils;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.index.ArtifactInfo;
 import org.apache.maven.index.FlatSearchRequest;
 import org.apache.maven.index.FlatSearchResponse;
@@ -62,17 +62,17 @@ public class NexusRepositorySearch
 
     private NexusIndexer indexer;
 
-    private ArchivaConfiguration archivaConfig;
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
 
     private MavenIndexerUtils mavenIndexerUtils;
 
     @Inject
-    public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ArchivaConfiguration archivaConfig,
+    public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ManagedRepositoryAdmin managedRepositoryAdmin,
                                   MavenIndexerUtils mavenIndexerUtils )
         throws PlexusSisuBridgeException
     {
         this.indexer = plexusSisuBridge.lookup( NexusIndexer.class );
-        this.archivaConfig = archivaConfig;
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
         this.mavenIndexerUtils = mavenIndexerUtils;
 
     }
@@ -283,16 +283,15 @@ public class NexusRepositorySearch
         {
             try
             {
-                Configuration config = archivaConfig.getConfiguration();
-                ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repo );
+                ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repo );
 
                 if ( repoConfig != null )
                 {
-                    String indexDir = repoConfig.getIndexDir();
+                    String indexDir = repoConfig.getIndexDirectory();
                     File indexDirectory = null;
                     if ( indexDir != null && !"".equals( indexDir ) )
                     {
-                        indexDirectory = new File( repoConfig.getIndexDir() );
+                        indexDirectory = new File( repoConfig.getIndexDirectory() );
                     }
                     else
                     {
@@ -338,6 +337,10 @@ public class NexusRepositorySearch
             {
                 log.warn( "IO error occured while accessing index of repository '" + repo + "' : " + e.getMessage() );
                 continue;
+            } catch ( RepositoryAdminException e )
+            {
+                  log.warn( "RepositoryAdminException occured while accessing index of repository '" + repo + "' : " + e.getMessage() );
+                continue;
             }
         }
         return indexingContextIds;
index 9775f6e538eaf949763d04f8687840f2272216b9..7530b546cfcad07436a8261eb7e8f3e5ab86a092 100644 (file)
   <context:annotation-config/>
   <context:component-scan base-package="org.apache.archiva.indexer.search"/>
 
-  <!--
-    <bean id="nexusSearch" class="org.apache.archiva.indexer.search.NexusRepositorySearch">
-        <constructor-arg ref="nexusIndexer"/>
-        <constructor-arg ref="archivaConfiguration#default"/>
-    </bean>
-  -->
   <bean id="logger" class="org.apache.maven.archiva.common.utils.Slf4JPlexusLogger">
     <constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg>
   </bean>
-  
-   <!--  <bean id="indexingContextMap" class="org.apache.archiva.indexer.IndexingContextMap"/>  -->
+
 </beans>
\ No newline at end of file
index 0a1b5679551be7ec2b4b85057b4a8ee574d50420..435414c54ebdecd62f42aedcbe4492da596e0010 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.archiva.indexer.search;
 */
 
 import junit.framework.TestCase;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.commons.io.FileUtils;
@@ -94,7 +95,10 @@ public abstract class AbstractNexusRepositorySearch
 
         archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
 
-        search = new NexusRepositorySearch( plexusSisuBridge, archivaConfig, mavenIndexerUtils );
+        DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
+        defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
+
+        search = new NexusRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils );
 
         nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );