public static IndexingContext createContext( ManagedRepositoryConfiguration repository ) throws IOException, UnsupportedExistingLuceneIndexException { String indexDir = repository.getIndexDir(); File managedRepository = new File( repository.getLocation() ); File indexDirectory = null; if ( indexDir != null && !"".equals( indexDir ) ) { indexDirectory = new File( repository.getIndexDir() ); } else { indexDirectory = new File( managedRepository, ".indexer" ); } IndexingContext context = new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory, null, null, NexusIndexer.FULL_INDEX, false ); context.setSearchable( repository.isScanned() ); return context; }
public void setRepositoryIndexContextSearchable( String repositoryId, boolean searchable ) throws IOException, NoSuchRepositoryException { Repository repository = repositoryRegistry.getRepository( repositoryId ); // cannot do "!repository.isIndexable()" since we may be called to handle that config change (using events)! // the repo might be already non-indexable, but the context would still exist! if ( !isIndexingSupported( repository ) ) { logSkippingRepositoryMessage( repository ); return; } IndexingContext ctx = getRepositoryLocalIndexContext( repository ); IndexingContext rctx = getRepositoryRemoteIndexContext( repository ); // do this only if we have contexts, otherwise be muted if ( ctx != null && rctx != null ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Searching on repository ID='" + repositoryId + "' is set to: " + String.valueOf( searchable ) ); } ctx.setSearchable( searchable ); rctx.setSearchable( searchable ); } }
repoRoot, new File( getWorkingDirectory(), getLocalContextId( repository.getId() ) ), null, null, indexCreators ); ctxLocal.setSearchable( repository.isSearchable() ); repoRoot, new File( getWorkingDirectory(), getRemoteContextId( repository.getId() ) ), null, null, indexCreators ); ctxRemote.setSearchable( repository.isSearchable() );