Search in sources :

Example 1 with IndexFormatTooOldException

use of org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException in project archiva by apache.

the class ArchivaIndexManagerMock method createRemoteContext.

private IndexingContext createRemoteContext(RemoteRepository remoteRepository) throws IOException {
    Path appServerBase = archivaConfiguration.getAppServerBaseDir();
    String contextKey = "remote-" + remoteRepository.getId();
    // create remote repository path
    Path repoDir = remoteRepository.getLocalPath();
    if (!Files.exists(repoDir)) {
        Files.createDirectories(repoDir);
    }
    Path indexDirectory = null;
    // is there configured indexDirectory ?
    if (remoteRepository.supportsFeature(RemoteIndexFeature.class)) {
        RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
        indexDirectory = getIndexPath(remoteRepository);
        String remoteIndexUrl = calculateIndexRemoteUrl(remoteRepository.getLocation(), rif);
        try {
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        } catch (IndexFormatTooOldException e) {
            // existing index with an old lucene format so we need to delete it!!!
            // delete it first then recreate it.
            // 
            log.warn(// 
            "the index of repository {} is too old we have to delete and recreate it", remoteRepository.getId());
            org.apache.archiva.common.utils.FileUtils.deleteDirectory(indexDirectory);
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        }
    } else {
        throw new IOException("No remote index defined");
    }
}
Also used : Path(java.nio.file.Path) IndexFormatTooOldException(org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) IOException(java.io.IOException)

Example 2 with IndexFormatTooOldException

use of org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException in project archiva by apache.

the class MavenIndexManager method createManagedContext.

private IndexingContext createManagedContext(ManagedRepository repository) throws IOException {
    IndexingContext context;
    // take care first about repository location as can be relative
    Path repositoryDirectory = repository.getLocalPath();
    if (!Files.exists(repositoryDirectory)) {
        try {
            Files.createDirectories(repositoryDirectory);
        } catch (IOException e) {
            log.error("Could not create directory {}", repositoryDirectory);
        }
    }
    Path indexDirectory = null;
    if (repository.supportsFeature(IndexCreationFeature.class)) {
        indexDirectory = getIndexPath(repository);
        String indexUrl = repositoryDirectory.toUri().toURL().toExternalForm();
        try {
            context = getIndexingContext(repository, repository.getId(), repositoryDirectory, indexDirectory, indexUrl);
            context.setSearchable(repository.isScanned());
        } catch (IndexFormatTooOldException e) {
            // existing index with an old lucene format so we need to delete it!!!
            // delete it first then recreate it.
            // 
            log.warn(// 
            "the index of repository {} is too old we have to delete and recreate it", repository.getId());
            org.apache.archiva.common.utils.FileUtils.deleteDirectory(indexDirectory);
            context = getIndexingContext(repository, repository.getId(), repositoryDirectory, indexDirectory, indexUrl);
            context.setSearchable(repository.isScanned());
        }
        return context;
    } else {
        throw new IOException("No repository index defined");
    }
}
Also used : Path(java.nio.file.Path) IndexFormatTooOldException(org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexingContext(org.apache.maven.index.context.IndexingContext) IOException(java.io.IOException)

Example 3 with IndexFormatTooOldException

use of org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException in project archiva by apache.

the class ArchivaIndexManagerMock method createManagedContext.

private IndexingContext createManagedContext(ManagedRepository repository) throws IOException {
    IndexingContext context;
    // take care first about repository location as can be relative
    Path repositoryDirectory = repository.getLocalPath();
    if (!Files.exists(repositoryDirectory)) {
        try {
            Files.createDirectories(repositoryDirectory);
        } catch (IOException e) {
            log.error("Could not create directory {}", repositoryDirectory);
        }
    }
    Path indexDirectory = null;
    if (repository.supportsFeature(IndexCreationFeature.class)) {
        indexDirectory = getIndexPath(repository);
        String indexUrl = repositoryDirectory.toUri().toURL().toExternalForm();
        try {
            context = getIndexingContext(repository, repository.getId(), repositoryDirectory, indexDirectory, indexUrl);
            context.setSearchable(repository.isScanned());
        } catch (IndexFormatTooOldException e) {
            // existing index with an old lucene format so we need to delete it!!!
            // delete it first then recreate it.
            // 
            log.warn(// 
            "the index of repository {} is too old we have to delete and recreate it", repository.getId());
            org.apache.archiva.common.utils.FileUtils.deleteDirectory(indexDirectory);
            context = getIndexingContext(repository, repository.getId(), repositoryDirectory, indexDirectory, indexUrl);
            context.setSearchable(repository.isScanned());
        }
        return context;
    } else {
        throw new IOException("No repository index defined");
    }
}
Also used : Path(java.nio.file.Path) IndexFormatTooOldException(org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexingContext(org.apache.maven.index.context.IndexingContext) IOException(java.io.IOException)

Example 4 with IndexFormatTooOldException

use of org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException in project archiva by apache.

the class MavenIndexManager method createRemoteContext.

private IndexingContext createRemoteContext(RemoteRepository remoteRepository) throws IOException {
    Path appServerBase = archivaConfiguration.getAppServerBaseDir();
    String contextKey = "remote-" + remoteRepository.getId();
    // create remote repository path
    Path repoDir = remoteRepository.getLocalPath();
    if (!Files.exists(repoDir)) {
        Files.createDirectories(repoDir);
    }
    Path indexDirectory = null;
    // is there configured indexDirectory ?
    if (remoteRepository.supportsFeature(RemoteIndexFeature.class)) {
        RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
        indexDirectory = getIndexPath(remoteRepository);
        String remoteIndexUrl = calculateIndexRemoteUrl(remoteRepository.getLocation(), rif);
        try {
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        } catch (IndexFormatTooOldException e) {
            // existing index with an old lucene format so we need to delete it!!!
            // delete it first then recreate it.
            // 
            log.warn(// 
            "the index of repository {} is too old we have to delete and recreate it", remoteRepository.getId());
            org.apache.archiva.common.utils.FileUtils.deleteDirectory(indexDirectory);
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        }
    } else {
        throw new IOException("No remote index defined");
    }
}
Also used : Path(java.nio.file.Path) IndexFormatTooOldException(org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) IOException(java.io.IOException)

Example 5 with IndexFormatTooOldException

use of org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException in project archiva by apache.

the class ArchivaIndexManagerMock method createRemoteContext.

private IndexingContext createRemoteContext(RemoteRepository remoteRepository) throws IOException {
    Path appServerBase = archivaConfiguration.getAppServerBaseDir();
    String contextKey = "remote-" + remoteRepository.getId();
    // create remote repository path
    Path repoDir = remoteRepository.getLocalPath();
    if (!Files.exists(repoDir)) {
        Files.createDirectories(repoDir);
    }
    Path indexDirectory = null;
    // is there configured indexDirectory ?
    if (remoteRepository.supportsFeature(RemoteIndexFeature.class)) {
        RemoteIndexFeature rif = remoteRepository.getFeature(RemoteIndexFeature.class).get();
        indexDirectory = getIndexPath(remoteRepository);
        String remoteIndexUrl = calculateIndexRemoteUrl(remoteRepository.getLocation(), rif);
        try {
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        } catch (IndexFormatTooOldException e) {
            // existing index with an old lucene format so we need to delete it!!!
            // delete it first then recreate it.
            // 
            log.warn(// 
            "the index of repository {} is too old we have to delete and recreate it", remoteRepository.getId());
            org.apache.archiva.common.utils.FileUtils.deleteDirectory(indexDirectory);
            return getIndexingContext(remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl);
        }
    } else {
        throw new IOException("No remote index defined");
    }
}
Also used : Path(java.nio.file.Path) IndexFormatTooOldException(org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)6 Path (java.nio.file.Path)6 IndexFormatTooOldException (org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException)6 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)3 RemoteIndexFeature (org.apache.archiva.repository.features.RemoteIndexFeature)3 IndexingContext (org.apache.maven.index.context.IndexingContext)3