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