private ArchivaTaskScheduler<ArtifactIndexingTask> scheduler;
- private IndexingContext context;
+ private IndexingContext indexingContext;
private NexusIndexer nexusIndexer;
try
{
log.info( "Creating indexing context for repo : {}", repository.getId() );
- context = managedRepositoryAdmin.createIndexContext( repository );
+ indexingContext = managedRepositoryAdmin.createIndexContext( repository );
}
catch ( RepositoryAdminException e )
{
File artifactFile = new File( managedRepository, path );
ArtifactIndexingTask task =
- new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD, context );
+ new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD, getIndexingContext() );
try
{
log.debug( "Queueing indexing task '{}' to add or update the artifact in the index.", task );
// specify in indexing task that this is not a repo scan request!
ArtifactIndexingTask task =
- new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD, context, false );
+ new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD,
+ getIndexingContext(), false );
// only update index we don't need to scan the full repo here
task.setOnlyUpdate( true );
try
public void completeScan()
{
+ IndexingContext context = this.indexingContext;
+ if ( context == null )
+ {
+ try
+ {
+ context = getIndexingContext();
+ }
+ catch ( ConsumerException e )
+ {
+ log.warn( "failed to get an IndexingContext:{}", e.getMessage() );
+ return;
+ }
+ }
ArtifactIndexingTask task =
new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH, context );
try
{
log.error( "Error queueing task: " + task + ": " + e.getMessage(), e );
}
- context = null;
}
public void completeScan( boolean executeOnEntireRepo )
{
return includes;
}
+
+
+ private IndexingContext getIndexingContext()
+ throws ConsumerException
+ {
+
+ if ( this.indexingContext == null )
+ {
+ try
+ {
+ indexingContext = managedRepositoryAdmin.createIndexContext( repository );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new ConsumerException( e.getMessage(), e );
+ }
+ }
+ return indexingContext;
+ }
}
indexDirectory.mkdirs();
}
- context =
- indexer.addIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory,
- managedRepository.toURI().toURL().toExternalForm(),
- indexDirectory.toURI().toURL().toString(), indexCreators );
+ context = indexer.getIndexingContexts().get( repository.getId() );
- context.setSearchable( repository.isScanned() );
+ if ( context == null )
+ {
+ context = indexer.addIndexingContext( repository.getId(), repository.getId(), managedRepository,
+ indexDirectory,
+ managedRepository.toURI().toURL().toExternalForm(),
+ indexDirectory.toURI().toURL().toString(), indexCreators );
+
+ context.setSearchable( repository.isScanned() );
+ }
return context;
}
catch ( MalformedURLException e )