use of net.nemerosa.ontrack.extension.svn.model.SVNURLFormatException in project ontrack by nemerosa.
the class SVNConfigurationServiceImpl method validate.
@Override
protected ConnectionResult validate(SVNConfiguration configuration) {
// No trailing slash
String url = configuration.getUrl();
if (StringUtils.endsWith(url, "/")) {
throw new SVNURLFormatException("The Subversion URL must not end with a slash: %s", url);
}
try (Transaction ignored = transactionService.start()) {
// Creates a repository
SVNRepository repository = SVNRepository.of(0, configuration, null);
// Configuration URL
SVNURL svnurl = SVNUtils.toURL(configuration.getUrl());
// Connection to the root
if (!svnClient.exists(repository, svnurl, SVNRevision.HEAD)) {
return ConnectionResult.error(configuration.getUrl() + " does not exist.");
}
// Gets base info
SVNInfo info = svnClient.getInfo(repository, svnurl, SVNRevision.HEAD);
// Checks the repository root
if (!Objects.equals(info.getRepositoryRootURL(), svnurl)) {
return ConnectionResult.error(configuration.getUrl() + " must be the root of the repository.");
}
// OK
return ConnectionResult.ok();
} catch (Exception ex) {
return ConnectionResult.error(ex.getMessage());
}
}
Aggregations