Search in sources :

Example 1 with UnsupportedRepositoryTypeException

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

the class ArchivaIndexManagerMock method createContext.

@Override
public ArchivaIndexingContext createContext(Repository repository) throws IndexCreationFailedException {
    log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType());
    if (repository.getType() != RepositoryType.MAVEN) {
        throw new UnsupportedRepositoryTypeException(repository.getType());
    }
    IndexingContext mvnCtx = null;
    try {
        if (repository instanceof RemoteRepository) {
            mvnCtx = createRemoteContext((RemoteRepository) repository);
        } else if (repository instanceof ManagedRepository) {
            mvnCtx = createManagedContext((ManagedRepository) repository);
        }
    } catch (IOException e) {
        log.error("IOException during context creation " + e.getMessage(), e);
        throw new IndexCreationFailedException("Could not create index context for repository " + repository.getId() + (StringUtils.isNotEmpty(e.getMessage()) ? ": " + e.getMessage() : ""), e);
    }
    MavenIndexContextMock context = new MavenIndexContextMock(repository, mvnCtx);
    return context;
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexingContext(org.apache.maven.index.context.IndexingContext) RemoteRepository(org.apache.archiva.repository.RemoteRepository) IOException(java.io.IOException) UnsupportedRepositoryTypeException(org.apache.archiva.repository.UnsupportedRepositoryTypeException)

Example 2 with UnsupportedRepositoryTypeException

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

the class MavenIndexManager method createContext.

@Override
public ArchivaIndexingContext createContext(Repository repository) throws IndexCreationFailedException {
    log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType());
    if (repository.getType() != RepositoryType.MAVEN) {
        throw new UnsupportedRepositoryTypeException(repository.getType());
    }
    IndexingContext mvnCtx = null;
    try {
        if (repository instanceof RemoteRepository) {
            mvnCtx = createRemoteContext((RemoteRepository) repository);
        } else if (repository instanceof ManagedRepository) {
            mvnCtx = createManagedContext((ManagedRepository) repository);
        }
    } catch (IOException e) {
        log.error("IOException during context creation " + e.getMessage(), e);
        throw new IndexCreationFailedException("Could not create index context for repository " + repository.getId() + (StringUtils.isNotEmpty(e.getMessage()) ? ": " + e.getMessage() : ""), e);
    }
    MavenIndexContext context = new MavenIndexContext(repository, mvnCtx);
    return context;
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexingContext(org.apache.maven.index.context.IndexingContext) RemoteRepository(org.apache.archiva.repository.RemoteRepository) IOException(java.io.IOException) UnsupportedRepositoryTypeException(org.apache.archiva.repository.UnsupportedRepositoryTypeException)

Example 3 with UnsupportedRepositoryTypeException

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

the class IndexManagerFactory method getIndexManager.

public ArchivaIndexManager getIndexManager(RepositoryType type) {
    if (managers.containsKey(type)) {
        return managers.get(type);
    } else {
        ArchivaIndexManager manager = applicationContext.getBeansOfType(ArchivaIndexManager.class).values().stream().filter(m -> m.supportsRepository(type)).findFirst().orElseThrow(() -> new UnsupportedRepositoryTypeException(type));
        managers.put(type, manager);
        return manager;
    }
}
Also used : UnsupportedRepositoryTypeException(org.apache.archiva.repository.UnsupportedRepositoryTypeException)

Example 4 with UnsupportedRepositoryTypeException

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

the class ArchivaIndexManagerMock method createContext.

@Override
public ArchivaIndexingContext createContext(Repository repository) throws IndexCreationFailedException {
    log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType());
    if (repository.getType() != RepositoryType.MAVEN) {
        throw new UnsupportedRepositoryTypeException(repository.getType());
    }
    IndexingContext mvnCtx = null;
    try {
        if (repository instanceof RemoteRepository) {
            mvnCtx = createRemoteContext((RemoteRepository) repository);
        } else if (repository instanceof ManagedRepository) {
            mvnCtx = createManagedContext((ManagedRepository) repository);
        }
    } catch (IOException e) {
        log.error("IOException during context creation " + e.getMessage(), e);
        throw new IndexCreationFailedException("Could not create index context for repository " + repository.getId() + (StringUtils.isNotEmpty(e.getMessage()) ? ": " + e.getMessage() : ""), e);
    }
    MavenIndexContextMock context = new MavenIndexContextMock(repository, mvnCtx);
    return context;
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) IndexCreationFailedException(org.apache.archiva.indexer.IndexCreationFailedException) ArchivaIndexingContext(org.apache.archiva.indexer.ArchivaIndexingContext) IndexingContext(org.apache.maven.index.context.IndexingContext) RemoteRepository(org.apache.archiva.repository.RemoteRepository) IOException(java.io.IOException) UnsupportedRepositoryTypeException(org.apache.archiva.repository.UnsupportedRepositoryTypeException)

Aggregations

UnsupportedRepositoryTypeException (org.apache.archiva.repository.UnsupportedRepositoryTypeException)4 IOException (java.io.IOException)3 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)3 IndexCreationFailedException (org.apache.archiva.indexer.IndexCreationFailedException)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 RemoteRepository (org.apache.archiva.repository.RemoteRepository)3 IndexingContext (org.apache.maven.index.context.IndexingContext)3