in shared/impl-vlt/src/main/java/org/apache/sling/ide/jcr/RepositoryUtils.java [59:114]
public static RepositoryAddress getRepositoryAddress(RepositoryInfo repositoryInfo) {
StringBuilder errors = new StringBuilder();
for (String webDavUrlLocation : WEBDAV_URL_LOCATIONS) {
Session session = null;
URI url = repositoryInfo.getUrl().resolve(webDavUrlLocation);
try {
RepositoryAddress address = new RepositoryAddress(url);
Repository repository;
synchronized (SYNC) {
repository = REGISTERED_REPOSITORIES.get(address);
if (repository == null) {
Set<String> supportedSchemes = FACTORY.getSupportedSchemes();
if (!supportedSchemes.contains(address.getURI().getScheme())) {
throw new IllegalArgumentException("Unable to create a a repository for "
+ address.getURI()
+ ", since the scheme is unsupported. Only schemes '" + supportedSchemes
+ "' are supported");
}
// SLING-3739: ensure that a well-known ClassLoader is used
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(Repository.class.getClassLoader());
try {
repository = FACTORY.createRepository(address);
} finally {
Thread.currentThread().setContextClassLoader(old);
}
REGISTERED_REPOSITORIES.put(address, repository);
}
}
session = repository.login(new SimpleCredentials(repositoryInfo.getUsername(), repositoryInfo
.getPassword().toCharArray()));
return address;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
} catch (RepositoryException e) {
// TODO-m12n - reactivate this error trace
// Activator.getDefault().getPluginLogger().trace("Failed connecting to repository at " + url, e);
errors.append(url).append(" : ").append(e.getMessage()).append('\n');
continue;
} finally {
if (session != null) {
session.logout();
}
}
}
errors.deleteCharAt(errors.length() - 1);
throw new IllegalArgumentException("No repository found at " + repositoryInfo.getUrl() + "\n"
+ errors.toString());
}