Search in sources :

Example 11 with IndexCreationFailedException

use of org.apache.archiva.indexer.IndexCreationFailedException in project archiva by apache.

the class ArchivaIndexManagerMock method reset.

@Override
public ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException {
    ArchivaIndexingContext ctx;
    executeUpdateFunction(context, indexingContext -> {
        try {
            indexingContext.close(true);
        } catch (IOException e) {
            log.warn("Index close failed");
        }
        try {
            FileUtils.deleteDirectory(Paths.get(context.getPath()));
        } catch (IOException e) {
            throw new IndexUpdateFailedException("Could not delete index files");
        }
    });
    try {
        Repository repo = context.getRepository();
        ctx = createContext(context.getRepository());
        if (repo instanceof EditableRepository) {
            ((EditableRepository) repo).setIndexingContext(ctx);
        }
    } catch (IndexCreationFailedException e) {
        throw new IndexUpdateFailedException("Could not create index");
    }
    return ctx;
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) EditableRepository(org.apache.archiva.repository.EditableRepository) Repository(org.apache.archiva.repository.Repository) RemoteRepository(org.apache.archiva.repository.RemoteRepository) IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) IOException(java.io.IOException) IndexUpdateFailedException(org.apache.archiva.indexer.IndexUpdateFailedException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) EditableRepository(org.apache.archiva.repository.EditableRepository)

Aggregations

IndexCreationFailedException (org.apache.archiva.indexer.IndexCreationFailedException)11 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)10 IOException (java.io.IOException)9 ManagedRepository (org.apache.archiva.repository.ManagedRepository)6 RemoteRepository (org.apache.archiva.repository.RemoteRepository)6 IndexingContext (org.apache.maven.index.context.IndexingContext)6 Path (java.nio.file.Path)3 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)3 UnsupportedBaseContextException (org.apache.archiva.indexer.UnsupportedBaseContextException)3 EditableRepository (org.apache.archiva.repository.EditableRepository)3 Repository (org.apache.archiva.repository.Repository)3 UnsupportedRepositoryTypeException (org.apache.archiva.repository.UnsupportedRepositoryTypeException)3 ArchivaIndexManager (org.apache.archiva.indexer.ArchivaIndexManager)2 IndexCreationEvent (org.apache.archiva.repository.features.IndexCreationEvent)1