diff options
Diffstat (limited to 'archiva-modules/archiva-base')
5 files changed, 19 insertions, 64 deletions
diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java deleted file mode 100644 index cd01c37e9..000000000 --- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/ArchivaNexusIndexerUtil.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.index.context.IndexCreator; -import org.apache.maven.index.creator.JarFileContentsIndexCreator; -import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator; -import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator; -import org.apache.maven.index.creator.OSGIArtifactIndexCreator; - -import java.util.Arrays; -import java.util.List; - -/** - * ArchivaNexusIndexerUtil - */ -public class ArchivaNexusIndexerUtil -{ - // FIXME olamy use lookup mechanism from plexus/sisu as here some possible injections can fail ! - - public static final List<? extends IndexCreator> FULL_INDEX = - Arrays.<IndexCreator>asList( new MinimalArtifactInfoIndexCreator(), new JarFileContentsIndexCreator(), - new MavenPluginArtifactInfoIndexCreator(), new OSGIArtifactIndexCreator() ); - -} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java index 075a16289..ccdb2c493 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java @@ -38,6 +38,7 @@ import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; import org.apache.maven.archiva.consumers.ConsumerException; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; @@ -73,6 +74,8 @@ public class NexusIndexerConsumer private ManagedRepositoryConfiguration repository; + private List<IndexCreator> allIndexCreators; + public NexusIndexerConsumer( ArchivaTaskScheduler<ArtifactIndexingTask> scheduler, ArchivaConfiguration configuration, FileTypes filetypes, PlexusSisuBridge plexusSisuBridge ) throws PlexusSisuBridgeException @@ -81,6 +84,7 @@ public class NexusIndexerConsumer this.filetypes = filetypes; this.scheduler = scheduler; this.nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); + this.allIndexCreators = plexusSisuBridge.lookupList( IndexCreator.class ); } public String getDescription() @@ -107,7 +111,7 @@ public class NexusIndexerConsumer try { log.info( "Creating indexing context for repo : " + repository.getId() ); - context = ArtifactIndexingTask.createContext( repository, nexusIndexer ); + context = ArtifactIndexingTask.createContext( repository, nexusIndexer, allIndexCreators ); } catch ( IOException e ) { 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 a189384dd..a22b599e9 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 @@ -25,7 +25,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.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -35,6 +34,7 @@ import org.apache.maven.index.FlatSearchResponse; import org.apache.maven.index.MAVEN; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.OSGI; +import org.apache.maven.index.context.IndexCreator; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; import org.apache.maven.index.expr.StringSearchExpression; @@ -62,12 +62,15 @@ public class NexusRepositorySearch private ArchivaConfiguration archivaConfig; + private List<? extends IndexCreator> allIndexCreators; + @Inject public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ArchivaConfiguration archivaConfig ) throws PlexusSisuBridgeException { this.indexer = plexusSisuBridge.lookup( NexusIndexer.class ); this.archivaConfig = archivaConfig; + allIndexCreators = plexusSisuBridge.lookupList( IndexCreator.class ); } /** @@ -274,7 +277,7 @@ public class NexusRepositorySearch IndexingContext context = indexer.addIndexingContext( repoConfig.getId(), repoConfig.getId(), new File( repoConfig.getLocation() ), indexDirectory, null, null, - ArchivaNexusIndexerUtil.FULL_INDEX ); + getAllIndexCreators() ); context.setSearchable( repoConfig.isScanned() ); } else @@ -295,6 +298,13 @@ public class NexusRepositorySearch } } + + protected List<? extends IndexCreator> getAllIndexCreators() + { + return allIndexCreators; + } + + private SearchResults convertToSearchResults( FlatSearchResponse response, SearchResultLimits limits ) { SearchResults results = new SearchResults(); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java index ea2a1a0e1..ef493bdab 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java @@ -22,7 +22,6 @@ package org.apache.archiva.indexer.search; import junit.framework.TestCase; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.commons.io.FileUtils; -import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.common.utils.FileUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -30,7 +29,6 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.index.ArtifactContext; import org.apache.maven.index.ArtifactContextProducer; import org.apache.maven.index.NexusIndexer; -import org.apache.maven.index.artifact.IllegalArtifactCoordinateException; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; import org.easymock.MockControl; @@ -59,7 +57,7 @@ public abstract class AbstractNexusRepositorySearch public static String TEST_REPO_2 = "nexus-search-test-repo-2"; - RepositorySearch search; + NexusRepositorySearch search; ArchivaConfiguration archivaConfig; @@ -166,7 +164,7 @@ public abstract class AbstractNexusRepositorySearch IndexingContext context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory, repo.toURI().toURL().toExternalForm(), indexDirectory.toURI().toURL().toString(), - ArchivaNexusIndexerUtil.FULL_INDEX ); + search.getAllIndexCreators() ); List<ArtifactContext> artifactContexts = new ArrayList<ArtifactContext>( filesToBeIndexed.size() ); for ( File artifactFile : filesToBeIndexed ) diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java index da2a5d396..e2ded80ee 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java @@ -19,23 +19,9 @@ package org.apache.archiva.indexer.search; * under the License. */ -import junit.framework.TestCase; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.commons.io.FileUtils; -import org.apache.maven.archiva.common.utils.ArchivaNexusIndexerUtil; import org.apache.maven.archiva.common.utils.FileUtil; -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.ArtifactContext; -import org.apache.maven.index.ArtifactContextProducer; -import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.artifact.IllegalArtifactCoordinateException; -import org.apache.maven.index.context.IndexingContext; import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; -import org.easymock.MockControl; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; @@ -46,7 +32,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.inject.Inject; @RunWith( SpringJUnit4ClassRunner.class ) |