use of org.apache.maven.wagon.authentication.AuthenticationException in project intellij-community by JetBrains.
the class Maven3ServerIndexFetcher method connect.
@Override
public void connect(String _ignoredContextId, String _ignoredUrl) throws IOException {
ArtifactRepository artifactRepository = myRepositorySystem.createArtifactRepository(myOriginalRepositoryId, myOriginalRepositoryUrl, null, null, null);
final ArtifactRepository mirrorRepository = myWagonManager.getMirrorRepository(artifactRepository);
String mirrorUrl = mirrorRepository.getUrl();
String indexUrl = mirrorUrl + (mirrorUrl.endsWith("/") ? "" : "/") + ".index";
Repository repository = new Repository(myOriginalRepositoryId, indexUrl);
try {
myWagon = myWagonManager.getWagon(repository);
myWagon.addTransferListener(myListener);
myWagon.connect(repository, myWagonManager.getAuthenticationInfo(mirrorRepository.getId()), myWagonManager.getProxy(mirrorRepository.getProtocol()));
} catch (AuthenticationException e) {
IOException newEx = new IOException("Authentication exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
} catch (WagonException e) {
IOException newEx = new IOException("Wagon exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
}
}
use of org.apache.maven.wagon.authentication.AuthenticationException in project intellij-community by JetBrains.
the class Maven2ServerIndexFetcher method connect.
public void connect(String _ignoredContextId, String _ignoredUrl) throws IOException {
final ArtifactRepository mirrorRepository = myWagonManager.getMirrorRepository(new DefaultArtifactRepository(myOriginalRepositoryId, myOriginalRepositoryUrl, null));
String mirrorUrl = mirrorRepository.getUrl();
String indexUrl = mirrorUrl + (mirrorUrl.endsWith("/") ? "" : "/") + ".index";
Repository repository = new Repository(myOriginalRepositoryId, indexUrl);
try {
myWagon = myWagonManager.getWagon(repository);
myWagon.addTransferListener(myListener);
myWagon.connect(repository, myWagonManager.getAuthenticationInfo(mirrorRepository.getId()), myWagonManager.getProxy(mirrorRepository.getProtocol()));
} catch (AuthenticationException e) {
IOException newEx = new IOException("Authentication exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
} catch (WagonException e) {
IOException newEx = new IOException("Wagon exception connecting to " + repository);
newEx.initCause(e);
throw newEx;
}
}
use of org.apache.maven.wagon.authentication.AuthenticationException in project maven-plugins by apache.
the class RepositoryUtils method dependencyExistsInRepo.
/**
* @param repo not null
* @param artifact not null
* @return <code>true</code> if the artifact exists in the given repo, <code>false</code> otherwise or if
* the repo is blacklisted.
*/
public boolean dependencyExistsInRepo(ArtifactRepository repo, Artifact artifact) {
if (repo.isBlacklisted()) {
if (log.isDebugEnabled()) {
log.debug("The repo '" + repo.getId() + "' is black listed - Ignored it");
}
return false;
}
if (UNKNOWN_HOSTS.contains(repo.getUrl())) {
if (log.isDebugEnabled()) {
log.debug("The repo url '" + repo.getUrl() + "' is unknown - Ignored it");
}
return false;
}
repo = wagonManager.getMirrorRepository(repo);
String id = repo.getId();
Repository repository = new Repository(id, repo.getUrl());
Wagon wagon;
try {
wagon = wagonManager.getWagon(repository);
} catch (UnsupportedProtocolException e) {
logError("Unsupported protocol: '" + repo.getProtocol() + "'", e);
return false;
} catch (WagonConfigurationException e) {
logError("Unsupported protocol: '" + repo.getProtocol() + "'", e);
return false;
}
wagon.setTimeout(1000);
if (log.isDebugEnabled()) {
Debug debug = new Debug();
wagon.addSessionListener(debug);
wagon.addTransferListener(debug);
}
try {
// FIXME when upgrading to maven 3.x : this must be changed.
AuthenticationInfo auth = wagonManager.getAuthenticationInfo(repo.getId());
ProxyInfo proxyInfo = getProxyInfo();
if (proxyInfo != null) {
wagon.connect(repository, auth, proxyInfo);
} else {
wagon.connect(repository, auth);
}
return wagon.resourceExists(StringUtils.replace(getDependencyUrlFromRepository(artifact, repo), repo.getUrl(), ""));
} catch (ConnectionException e) {
logError("Unable to connect to: " + repo.getUrl(), e);
return false;
} catch (AuthenticationException e) {
logError("Unable to connect to: " + repo.getUrl(), e);
return false;
} catch (TransferFailedException e) {
if (e.getCause() instanceof UnknownHostException) {
log.error("Unknown host " + e.getCause().getMessage() + " - ignored it");
UNKNOWN_HOSTS.add(repo.getUrl());
} else {
logError("Unable to determine if resource " + artifact + " exists in " + repo.getUrl(), e);
}
return false;
} catch (AuthorizationException e) {
logError("Unable to connect to: " + repo.getUrl(), e);
return false;
} catch (AbstractMethodError e) {
log.error("Wagon " + wagon.getClass().getName() + " does not support the resourceExists method");
return false;
} finally {
try {
wagon.disconnect();
} catch (ConnectionException e) {
logError("Error disconnecting wagon - ignored", e);
}
}
}
use of org.apache.maven.wagon.authentication.AuthenticationException in project maven-plugins by apache.
the class DefaultRepositoryCopier method scanForArtifactPaths.
protected List<String> scanForArtifactPaths(ArtifactRepository repository) {
List<String> collected;
try {
Wagon wagon = wagonManager.getWagon(repository.getProtocol());
Repository artifactRepository = new Repository(repository.getId(), repository.getUrl());
wagon.connect(artifactRepository);
collected = new ArrayList<String>();
scan(wagon, "/", collected);
wagon.disconnect();
return collected;
} catch (UnsupportedProtocolException e) {
throw new RuntimeException(e);
} catch (ConnectionException e) {
throw new RuntimeException(e);
} catch (AuthenticationException e) {
throw new RuntimeException(e);
}
}
use of org.apache.maven.wagon.authentication.AuthenticationException in project wagon-git by synergian.
the class GitWagon method openConnectionInternal.
/**
* {@inheritDoc}
*/
protected void openConnectionInternal() throws ConnectionException, AuthenticationException {
log.debug("Invoked openConnectionInternal()");
if (git == null) {
try {
String url = getRepository().getUrl();
if (url.endsWith("/"))
url = url.substring(0, url.length() - 1);
String remote;
String branch;
url = url.substring("git:".length());
int i = url.indexOf(':');
if (i < 0) {
remote = url;
branch = "master";
} else {
branch = url.substring(0, i);
remote = url.substring(i + 3, url.length());
}
File workDir = Utils.createCheckoutDirectory(remote);
if (!workDir.exists() || !workDir.isDirectory() || !workDir.canWrite())
throw new ConnectionException("Unable to create working directory");
if (safeCheckout)
FileUtils.cleanDirectory(workDir);
git = new GitBackend(workDir, remote, branch, log);
git.pullAll();
} catch (Exception e) {
throw new ConnectionException("Unable to pull git repository: " + e.getMessage(), e);
}
}
}
Aggregations