@Override public File getIndexDirectoryFile() { return context.getIndexDirectoryFile(); }
@Override public void run(IndexingContext context) throws IOException { if (context.getIndexDirectoryFile() != null) { new File( context.getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ).delete(); } }}); repository.deleteItem(false, request);
@Override public URI getPath() { return delegate.getIndexDirectoryFile().toURI(); }
@Override public boolean isEmpty() throws IOException { return Files.list(delegate.getIndexDirectoryFile().toPath()).count()==0; }
public LuceneIndexAdaptor( IndexUpdateRequest updateRequest ) { super( updateRequest.getIndexingContext().getIndexDirectoryFile() ); this.updateRequest = updateRequest; }
LuceneIndexAdaptor( IndexUpdateRequest updateRequest ) { super( updateRequest.getIndexingContext().getIndexDirectoryFile() ); this.updateRequest = updateRequest; }
LuceneIndexAdaptor( IndexUpdateRequest updateRequest ) { super( updateRequest.getIndexingContext().getIndexDirectoryFile() ); this.updateRequest = updateRequest; }
private Properties readIndexProperties( IndexPackingRequest request ) throws IOException { File file = null; if ( request.isUseTargetProperties() || request.getContext().getIndexDirectoryFile() == null ) { file = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); } else { file = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); } Properties properties = new Properties(); FileInputStream fos = null; try { fos = new FileInputStream( file ); properties.load( fos ); } finally { if ( fos != null ) { fos.close(); } } return properties; }
private Properties readIndexProperties( IndexPackingRequest request ) throws IOException { File file = null; if ( request.isUseTargetProperties() || request.getContext().getIndexDirectoryFile() == null ) { file = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); } else { file = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); } Properties properties = new Properties(); FileInputStream fos = null; try { fos = new FileInputStream( file ); properties.load( fos ); } finally { if ( fos != null ) { fos.close(); } } return properties; }
private Properties readIndexProperties( IndexPackingRequest request ) throws IOException { File file = null; if ( request.isUseTargetProperties() || request.getContext().getIndexDirectoryFile() == null ) { file = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); } else { file = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); } Properties properties = new Properties(); FileInputStream fos = null; try { fos = new FileInputStream( file ); properties.load( fos ); } finally { if ( fos != null ) { fos.close(); } } return properties; }
void writeIndexProperties( IndexPackingRequest request, Properties info ) throws IOException { File propertyFile = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); info.setProperty( IndexingContext.INDEX_ID, request.getContext().getId() ); try ( OutputStream os = new FileOutputStream( propertyFile ) ) { info.store( os, null ); } try ( OutputStream os = new FileOutputStream( targetPropertyFile ) ) { info.store( os, null ); } if ( request.isCreateChecksumFiles() ) { FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".sha1" ).getAbsolutePath(), DigesterUtils.getSha1Digest( targetPropertyFile ) ); FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".md5" ).getAbsolutePath(), DigesterUtils.getMd5Digest( targetPropertyFile ) ); } }
new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE );
void writeIndexProperties( IndexPackingRequest request, Properties info ) throws IOException { File propertyFile = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); info.setProperty( IndexingContext.INDEX_ID, request.getContext().getId() ); try ( OutputStream os = new FileOutputStream( propertyFile ) ) { info.store( os, null ); } try ( OutputStream os = new FileOutputStream( targetPropertyFile ) ) { info.store( os, null ); } if ( request.isCreateChecksumFiles() ) { FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".sha1" ).getAbsolutePath(), DigesterUtils.getSha1Digest( targetPropertyFile ) ); FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".md5" ).getAbsolutePath(), DigesterUtils.getMd5Digest( targetPropertyFile ) ); } }
@Override public void pack( final ArchivaIndexingContext context ) throws IndexUpdateFailedException { executeUpdateFunction( context, indexingContext -> { try { IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexingContext.acquireIndexSearcher( ).getIndexReader( ), indexingContext.getIndexDirectoryFile( ) ); indexPacker.packIndex( request ); indexingContext.updateTimestamp( true ); } catch ( IOException e ) { log.error( "IOException while packing index of context " + context.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ) ); throw new IndexUpdateFailedException( "IOException during update of " + context.getId( ), e ); } } ); }
Path newPath = getIndexPath(repo); IndexingContext ctx = context.getBaseContext(IndexingContext.class); Path oldPath = ctx.getIndexDirectoryFile().toPath(); if (oldPath.equals(newPath)) {
log.debug( "Creating packed index from {} on {}", context.getIndexDirectoryFile( ), icf.getLocalPackedIndexPath( ) ); IndexPackingRequest request = new IndexPackingRequest( context, // context.acquireIndexSearcher( ).getIndexReader( ),
@PostConstruct public void startup() throws DownloadRemoteIndexException, UnsupportedBaseContextException { archivaConfiguration.addListener( this ); // TODO add indexContexts even if null for ( org.apache.archiva.repository.RemoteRepository remoteRepository : repositoryRegistry.getRemoteRepositories() ) { String contextKey = "remote-" + remoteRepository.getId(); IndexingContext context = remoteRepository.getIndexingContext().getBaseContext(IndexingContext.class); if ( context == null ) { continue; } RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get(); // TODO record jobs from configuration if ( rif.isDownloadRemoteIndex() && StringUtils.isNotEmpty( remoteRepository.getSchedulingDefinition() ) ) { boolean fullDownload = context.getIndexDirectoryFile().list().length == 0; scheduleDownloadRemote( remoteRepository.getId(), false, fullDownload ); } } }
Path mergedRepoDir = indexingContext.getIndexDirectoryFile().toPath(); TemporaryGroupIndex temporaryGroupIndex = new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
deleteContent && context.getIndexDirectoryFile().exists() );
File indexDirectory = indexingContext.getIndexDirectoryFile(); FileUtils.deleteDirectory( indexDirectory );