Search in sources :

Example 1 with NoLocalRepositoryManagerException

use of org.sonatype.aether.repository.NoLocalRepositoryManagerException in project sonatype-aether by sonatype.

the class DefaultLocalRepositoryProvider method newLocalRepositoryManager.

public LocalRepositoryManager newLocalRepositoryManager(LocalRepository localRepository) throws NoLocalRepositoryManagerException {
    List<LocalRepositoryManagerFactory> factories = new ArrayList<LocalRepositoryManagerFactory>(managerFactories);
    Collections.sort(factories, COMPARATOR);
    for (LocalRepositoryManagerFactory factory : factories) {
        try {
            LocalRepositoryManager manager = factory.newInstance(localRepository);
            if (logger.isDebugEnabled()) {
                StringBuilder buffer = new StringBuilder(256);
                buffer.append("Using manager ").append(manager.getClass().getSimpleName());
                buffer.append(" with priority ").append(factory.getPriority());
                buffer.append(" for ").append(localRepository.getBasedir());
                logger.debug(buffer.toString());
            }
            return manager;
        } catch (NoLocalRepositoryManagerException e) {
        // continue and try next factory
        }
    }
    StringBuilder buffer = new StringBuilder(256);
    buffer.append("No manager available for local repository ");
    buffer.append(localRepository.getBasedir());
    buffer.append(" of type ").append(localRepository.getContentType());
    buffer.append(" using the available factories ");
    for (ListIterator<LocalRepositoryManagerFactory> it = factories.listIterator(); it.hasNext(); ) {
        LocalRepositoryManagerFactory factory = it.next();
        buffer.append(factory.getClass().getSimpleName());
        if (it.hasNext()) {
            buffer.append(", ");
        }
    }
    throw new NoLocalRepositoryManagerException(localRepository, buffer.toString());
}
Also used : LocalRepositoryManagerFactory(org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory) LocalRepositoryManager(org.sonatype.aether.repository.LocalRepositoryManager) ArrayList(java.util.ArrayList) NoLocalRepositoryManagerException(org.sonatype.aether.repository.NoLocalRepositoryManagerException)

Aggregations

ArrayList (java.util.ArrayList)1 LocalRepositoryManager (org.sonatype.aether.repository.LocalRepositoryManager)1 NoLocalRepositoryManagerException (org.sonatype.aether.repository.NoLocalRepositoryManagerException)1 LocalRepositoryManagerFactory (org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory)1