Search in sources :

Example 1 with RepositoryConnectionException

use of org.mule.runtime.module.repository.api.RepositoryConnectionException in project mule by mulesoft.

the class DefaultRepositoryService method lookupBundle.

@Override
public File lookupBundle(BundleDependency bundleDependency) {
    try {
        if (remoteRepositories.isEmpty()) {
            throw new RepositoryServiceDisabledException("Repository service has not been configured so it's disabled. " + "To enable it you must configure the set of repositories to use using the system property: " + MULE_REMOTE_REPOSITORIES_PROPERTY);
        }
        DefaultArtifact artifact = toArtifact(bundleDependency);
        ArtifactRequest getArtifactRequest = new ArtifactRequest();
        getArtifactRequest.setRepositories(remoteRepositories);
        getArtifactRequest.setArtifact(artifact);
        ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, getArtifactRequest);
        return artifactResult.getArtifact().getFile();
    } catch (ArtifactResolutionException e) {
        if (e.getCause() instanceof ArtifactNotFoundException) {
            throw new BundleNotFoundException(e);
        } else {
            throw new RepositoryConnectionException("There was a problem connecting to one of the repositories", e);
        }
    }
}
Also used : RepositoryConnectionException(org.mule.runtime.module.repository.api.RepositoryConnectionException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) RepositoryServiceDisabledException(org.mule.runtime.module.repository.api.RepositoryServiceDisabledException) ArtifactNotFoundException(org.eclipse.aether.transfer.ArtifactNotFoundException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) BundleNotFoundException(org.mule.runtime.module.repository.api.BundleNotFoundException)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)1 ArtifactNotFoundException (org.eclipse.aether.transfer.ArtifactNotFoundException)1 BundleNotFoundException (org.mule.runtime.module.repository.api.BundleNotFoundException)1 RepositoryConnectionException (org.mule.runtime.module.repository.api.RepositoryConnectionException)1 RepositoryServiceDisabledException (org.mule.runtime.module.repository.api.RepositoryServiceDisabledException)1