summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java26
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java17
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java44
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java6
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java5
5 files changed, 26 insertions, 72 deletions
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 7badf11e1..787c42519 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
@@ -19,22 +19,23 @@ package org.apache.archiva.consumers.lucene;
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.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;
-import org.apache.archiva.scheduler.ArchivaTaskScheduler;
-import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ConfigurationNames;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.scheduler.ArchivaTaskScheduler;
+import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
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.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
import org.codehaus.plexus.taskqueue.TaskQueueException;
@@ -44,8 +45,8 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -54,13 +55,13 @@ import java.util.List;
/**
* Consumer for indexing the repository to provide search and IDE integration features.
*/
-@Service("knownRepositoryContentConsumer#index-content")
-@Scope("prototype")
+@Service( "knownRepositoryContentConsumer#index-content" )
+@Scope( "prototype" )
public class NexusIndexerConsumer
extends AbstractMonitoredConsumer
implements KnownRepositoryContentConsumer, RegistryListener
{
- private Logger log = LoggerFactory.getLogger( NexusIndexerConsumer.class );
+ private Logger log = LoggerFactory.getLogger( getClass() );
private ArchivaConfiguration configuration;
@@ -80,6 +81,9 @@ public class NexusIndexerConsumer
private List<? extends IndexCreator> allIndexCreators;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
public NexusIndexerConsumer( ArchivaTaskScheduler<ArtifactIndexingTask> scheduler,
ArchivaConfiguration configuration, FileTypes filetypes,
PlexusSisuBridge plexusSisuBridge, MavenIndexerUtils mavenIndexerUtils )
@@ -116,13 +120,9 @@ public class NexusIndexerConsumer
try
{
log.info( "Creating indexing context for repo : {}", repository.getId() );
- context = ArtifactIndexingTask.createContext( repository, nexusIndexer, allIndexCreators );
- }
- catch ( IOException e )
- {
- throw new ConsumerException( e.getMessage(), e );
+ context = managedRepositoryAdmin.createIndexContext( repository );
}
- catch ( UnsupportedExistingLuceneIndexException e )
+ catch ( RepositoryAdminException e )
{
throw new ConsumerException( e.getMessage(), e );
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
index 3d9a0b199..059898732 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
@@ -20,7 +20,9 @@ package org.apache.archiva.scheduler.indexing;
* under the License.
*/
+import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.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;
@@ -29,7 +31,6 @@ import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
-import org.apache.maven.index.DefaultArtifactContextProducer;
import org.apache.maven.index.FlatSearchRequest;
import org.apache.maven.index.FlatSearchResponse;
import org.apache.maven.index.MAVEN;
@@ -37,7 +38,6 @@ import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.artifact.IllegalArtifactCoordinateException;
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.SourcedSearchExpression;
import org.apache.maven.index.packer.IndexPacker;
import org.apache.maven.index.packer.IndexPackingRequest;
@@ -78,6 +78,9 @@ public class ArchivaIndexingTaskExecutor
@Inject
private MavenIndexerUtils mavenIndexerUtils;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
private NexusIndexer nexusIndexer;
private List<? extends IndexCreator> allIndexCreators;
@@ -130,15 +133,9 @@ public class ArchivaIndexingTaskExecutor
{
log.debug( "Creating indexing context on resource: {}",
indexingTask.getResourceFile().getPath() );
- context = ArtifactIndexingTask.createContext( repository, nexusIndexer, allIndexCreators );
- }
- catch ( IOException e )
- {
- log.error( "Error occurred while creating context: " + e.getMessage() );
- throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage(),
- e );
+ context = managedRepositoryAdmin.createIndexContext( repository );
}
- catch ( UnsupportedExistingLuceneIndexException e )
+ catch ( RepositoryAdminException e )
{
log.error( "Error occurred while creating context: " + e.getMessage() );
throw new TaskExecutionException( "Error occurred while creating context: " + e.getMessage(),
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
index 5ab9efd08..560105366 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
@@ -181,48 +181,4 @@ public class ArtifactIndexingTask
+ resourceFile + "]";
}
- /**
- * FIXME remove this static somewhere else !
- * @param repository
- * @param indexer
- * @param indexCreators
- * @return
- * @throws IOException
- * @throws UnsupportedExistingLuceneIndexException
- */
- public static IndexingContext createContext( ManagedRepository repository, NexusIndexer indexer,
- List<? extends IndexCreator> indexCreators )
- throws IOException, UnsupportedExistingLuceneIndexException
- {
- IndexingContext context = indexer.getIndexingContexts().get( repository.getId() );
-
- if ( context != null )
- {
- LoggerFactory.getLogger( ArtifactIndexingTask.class ).debug(
- "skip adding repository with id {} as already exists", repository.getId() );
- return context;
- }
-
-
- String indexDir = repository.getIndexDirectory();
- File managedRepository = new File( repository.getLocation() );
-
- File indexDirectory = null;
- if ( indexDir != null && !"".equals( indexDir ) )
- {
- indexDirectory = new File( repository.getIndexDirectory() );
- }
- else
- {
- indexDirectory = new File( managedRepository, ".indexer" );
- }
-
-
- context = indexer.addIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory,
- managedRepository.toURI().toURL().toExternalForm(),
- indexDirectory.toURI().toURL().toString(), indexCreators );
-
- context.setSearchable( repository.isScanned() );
- return context;
- }
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
index e0fbdeb65..aff511520 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
@@ -21,6 +21,7 @@ package org.apache.archiva.scheduler.indexing;
import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.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.commons.io.FileUtils;
@@ -76,6 +77,9 @@ public class ArchivaIndexingTaskExecutorTest
@Inject
MavenIndexerUtils mavenIndexerUtils;
+ @Inject
+ ManagedRepositoryAdmin managedRepositoryAdmin;
+
@Before
public void setUp()
throws Exception
@@ -93,7 +97,7 @@ public class ArchivaIndexingTaskExecutorTest
indexer = plexusSisuBridge.lookup( NexusIndexer.class );
- ArtifactIndexingTask.createContext( repositoryConfig, indexer, mavenIndexerUtils.getAllIndexCreators() );
+ managedRepositoryAdmin.createIndexContext( repositoryConfig );
}
@After
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
index 6db1e6f29..79cde9868 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
@@ -175,10 +175,7 @@ public class DefaultRepositoriesService
{
ManagedRepository repository = managedRepositoryAdmin.getManagedRepository( repositoryId );
- IndexingContext context =
- ArtifactIndexingTask.createContext( repository, plexusSisuBridge.lookup( NexusIndexer.class ),
- new ArrayList<IndexCreator>(
- mavenIndexerUtils.getAllIndexCreators( ) ) );
+ IndexingContext context = managedRepositoryAdmin.createIndexContext( repository );
ArtifactIndexingTask task =
new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH, context );