/**
* @param provider to authenticate when required
* @param configuration the configuration to get and set the username and
* password
* @throws SvnClientException
*/
@Inject
public SvnClientJavaHl(ICredentialProvider provider, IConfiguration configuration) throws SvnClientException {
try {
if (!SVNClientAdapterFactory.isSVNClientAvailable(JhlClientAdapterFactory.JAVAHL_CLIENT)) {
JhlClientAdapterFactory.setup();
}
client = SVNClientAdapterFactory.createSVNClient(JhlClientAdapterFactory.JAVAHL_CLIENT);
final String username = configuration.getSvnUsername();
if (username != null) {
client.setUsername(username);
}
final String password = configuration.getSvnPassword();
if (password != null) {
client.setPassword(password);
}
client.addPasswordCallback(new SVNPromptUserPassword(provider, configuration, client));
} catch (SVNClientException | ConfigurationException e) {
throw new SvnClientException(e);
}
}
/**
* Setup the client adapter implementation and register it in the adapters factory
* @throws SVNClientException
*/
public static void setup() throws SVNClientException {
if (!isAvailable()) {
throw new SVNClientException("Javahl client adapter is not available");
}
SVNClientAdapterFactory.registerAdapterFactory(new JhlClientAdapterFactory());
}