Created
May 20, 2011 13:21
-
-
Save vs/982876 to your computer and use it in GitHub Desktop.
SVNKit API: adjusting HTTP connection timeout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.tmatesoft.svn.util; | |
import java.io.File; | |
import java.util.Collection; | |
import org.tmatesoft.svn.core.SVNDepth; | |
import org.tmatesoft.svn.core.SVNException; | |
import org.tmatesoft.svn.core.SVNURL; | |
import org.tmatesoft.svn.core.auth.SVNAuthentication; | |
import org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager; | |
import org.tmatesoft.svn.core.internal.wc.DefaultSVNHostOptionsProvider; | |
import org.tmatesoft.svn.core.internal.wc.ISVNHostOptions; | |
import org.tmatesoft.svn.core.wc.SVNClientManager; | |
import org.tmatesoft.svn.core.wc.SVNRevision; | |
import org.tmatesoft.svn.core.wc.SVNUpdateClient; | |
public class SvnExportAction { | |
public static void main(String[] args) { | |
DefaultSVNAuthenticationManager authManager = new | |
AuthenticationManager( | |
svnConfigDir, true, username, password); | |
SVNClientManager svnClientManager = | |
SVNClientManager.newInstance(options); | |
if (svnUrlStr.startsWith("https")) { | |
svnClientManager.setAuthenticationManager(authManager); | |
} | |
SVNUpdateClient svnUpdateClient = | |
svnClientManager.getUpdateClient(); | |
try { | |
svnUpdateClient.doExport(svnUrl, checkoutTempDir, | |
SVNRevision.UNDEFINED, | |
SVNRevision.HEAD, "\n", true, SVNDepth.FILES); | |
} | |
} | |
private static class AuthenticationManager extends DefaultSVNAuthenticationManager { | |
public AuthenticationManager(File configDirectory, boolean storeAuth, String userName, String password) { | |
super(configDirectory, storeAuth, userName, password); | |
HostOptionsProvider hostOptionsProvider = new HostOptionsProvider(configDirectory); | |
setHostOptionsProvider(hostOptionsProvider); | |
} | |
public AuthenticationManager(File configDirectory, boolean storeAuth, String userName, String password, File privateKey, String passphrase) { | |
super(configDirectory, storeAuth, userName, password, privateKey, passphrase); | |
HostOptionsProvider hostOptionsProvider = new HostOptionsProvider(configDirectory); | |
setHostOptionsProvider(hostOptionsProvider); | |
} | |
} | |
private static class HostOptionsProvider extends DefaultSVNHostOptionsProvider { | |
public HostOptionsProvider() { | |
super(); | |
} | |
public HostOptionsProvider(File configDirectory) { | |
super(configDirectory); | |
} | |
public ISVNHostOptions getHostOptions(SVNURL url) { | |
return super.getHostOptions(url); | |
} | |
} | |
private static class HostOptions { | |
private final ISVNHostOptions delegate; | |
private HostOptions(ISVNHostOptions delegate) { | |
this.delegate = delegate; | |
} | |
public Collection getAuthTypes() { | |
return delegate.getAuthTypes(); | |
} | |
public boolean isAuthStorageEnabled() { | |
return delegate.isAuthStorageEnabled(); | |
} | |
public boolean isStorePasswords() { | |
return delegate.isStorePasswords(); | |
} | |
public boolean isStoreSSLClientCertificatePassphrases() { | |
return delegate.isStoreSSLClientCertificatePassphrases(); | |
} | |
public boolean isStorePlainTextPasswords(String realm, SVNAuthentication auth) throws SVNException { | |
return delegate.isStorePlainTextPasswords(realm, auth); | |
} | |
public boolean isStorePlainTextPassphrases(String realm, SVNAuthentication auth) throws SVNException { | |
return delegate.isStorePlainTextPassphrases(realm, auth); | |
} | |
public String getUserName() { | |
return delegate.getUserName(); | |
} | |
public String getSSLClientCertFile() { | |
return delegate.getSSLClientCertFile(); | |
} | |
public String getSSLClientCertPassword() { | |
return delegate.getSSLClientCertPassword(); | |
} | |
public boolean trustDefaultSSLCertificateAuthority() { | |
return delegate.trustDefaultSSLCertificateAuthority(); | |
} | |
public File[] getSSLAuthorityFiles() { | |
return delegate.getSSLAuthorityFiles(); | |
} | |
public String getProxyHost() { | |
return delegate.getProxyHost(); | |
} | |
public String getProxyPort() { | |
return delegate.getProxyPort(); | |
} | |
public String getProxyUserName() { | |
return delegate.getProxyUserName(); | |
} | |
public String getProxyPassword() { | |
return delegate.getProxyPassword(); | |
} | |
public int getReadTimeout() { | |
return delegate.getReadTimeout(); | |
} | |
public int getConnectTimeout() { | |
// Adjust connection timeout as needed | |
return delegate.getConnectTimeout(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment