Search in sources :

Example 1 with EditableRepository

use of org.apache.archiva.repository.EditableRepository in project archiva by apache.

the class MavenIndexManager 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)

Example 2 with EditableRepository

use of org.apache.archiva.repository.EditableRepository 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)

Example 3 with EditableRepository

use of org.apache.archiva.repository.EditableRepository 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

IOException (java.io.IOException)3 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)3 IndexCreationFailedException (org.apache.archiva.indexer.IndexCreationFailedException)3 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)3 EditableRepository (org.apache.archiva.repository.EditableRepository)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 RemoteRepository (org.apache.archiva.repository.RemoteRepository)3 Repository (org.apache.archiva.repository.Repository)3