new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository,
indexDirectory, null, null, NexusIndexer.FULL_INDEX, false );
context.setSearchable( repository.isScanned() );
File artifactFile = indexingTask.getResourceFile();
ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
if( ac != null )
{
if( indexingTask.getAction().equals( ArtifactIndexingTask.ADD ) )
{
boolean add = true;
IndexReader r = context.getIndexReader();
for ( int i = 0; i < r.numDocs(); i++ )
{
if ( !r.isDeleted( i ) )
{
Document d = r.document( i );
String uinfo = d.get( ArtifactInfo.UINFO );
if( ac.getArtifactInfo().getUinfo().equals( uinfo ) )
{
add = false;
break;
}
}
}
if( add )
{
log.debug( "Adding artifact '" + ac.getArtifactInfo() + "' to index.." );
indexerEngine.index( context, ac );
}
else
{
log.debug( "Updating artifact '" + ac.getArtifactInfo() + "' in index.." );
indexerEngine.update( context, ac );
}
}
else
{
log.debug( "removing artifact '" + ac.getArtifactInfo() + "' from index.." );
indexerEngine.remove( context, ac );
}
final File indexLocation = new File( managedRepository, ".index" );
IndexPackingRequest request = new IndexPackingRequest( context, indexLocation );