Search in sources :

Example 1 with ArchivaIndexManager

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

the class RepositoryRegistry method createIndexingContext.

private void createIndexingContext(EditableRepository editableRepo) throws RepositoryException {
    if (editableRepo.supportsFeature(IndexCreationFeature.class)) {
        ArchivaIndexManager idxManager = getIndexManager(editableRepo.getType());
        try {
            editableRepo.setIndexingContext(idxManager.createContext(editableRepo));
            idxManager.updateLocalIndexPath(editableRepo);
        } catch (IndexCreationFailedException e) {
            throw new RepositoryException("Could not create index for repository " + editableRepo.getId() + ": " + e.getMessage(), e);
        }
    }
}
Also used : IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) ArchivaIndexManager(org.apache.archiva.indexer.ArchivaIndexManager)

Example 2 with ArchivaIndexManager

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

the class RepositoryRegistry method raise.

@Override
public <T> void raise(RepositoryEvent<T> event) {
    if (event instanceof IndexCreationEvent) {
        if (managedRepositories.containsKey(event.getRepository().getId()) || remoteRepositories.containsKey(event.getRepository().getId())) {
            EditableRepository repo = (EditableRepository) event.getRepository();
            if (repo != null && repo.getIndexingContext() != null) {
                try {
                    ArchivaIndexManager idxmgr = getIndexManager(repo.getType());
                    if (idxmgr != null) {
                        ArchivaIndexingContext newCtx = idxmgr.move(repo.getIndexingContext(), repo);
                        repo.setIndexingContext(newCtx);
                        idxmgr.updateLocalIndexPath(repo);
                    }
                } catch (IndexCreationFailedException e) {
                    log.error("Could not move index to new directory {}", e.getMessage(), e);
                }
            }
        }
    }
    for (RepositoryEventListener listener : listeners) {
        listener.raise(event);
    }
}
Also used : IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexCreationEvent(org.apache.archiva.repository.features.IndexCreationEvent) ArchivaIndexManager(org.apache.archiva.indexer.ArchivaIndexManager)

Aggregations

ArchivaIndexManager (org.apache.archiva.indexer.ArchivaIndexManager)2 IndexCreationFailedException (org.apache.archiva.indexer.IndexCreationFailedException)2 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)1 IndexCreationEvent (org.apache.archiva.repository.features.IndexCreationEvent)1