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;
}
Aggregations