* Creates an instance of SVNClientManager providing authentication
* information (name, password) and an options driver
*/
SVNClientManager ourClientManager = SVNClientManager
.newInstance(options);
SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
/*
* Creates the event handler to display information
*/
ourClientManager.setEventHandler(new SVNEventAdapter() {
public void handleEvent(SVNEvent event, double progress) {
SVNEventAction action = event.getAction();
File curFile = event.getFile();
String path = curFile.getAbsolutePath();
path = path.substring(path.indexOf(FOLDER_NAME));
if (action == SVNEventAction.ADD
|| action == SVNEventAction.UPDATE_ADD) {
m_taskOutput.append("Downloading " + path + " \n");
m_taskOutput.setCaretPosition(m_taskOutput
.getDocument().getLength());
System.out.println("Downloading " + curFile.getName());
}
if (action == SVNEventAction.STATUS_COMPLETED
|| action == SVNEventAction.UPDATE_COMPLETED) {
setProgress(100);
m_taskOutput.append("Download completed. ");
m_taskOutput.setCaretPosition(m_taskOutput
.getDocument().getLength());
System.out.println("Download completed. ");
}
}
});
/*
* sets externals not to be ignored during the checkout
*/
updateClient.setIgnoreExternals(false);
/*
* A url of a repository to check out
*/
SVNURL url = null;
try {
url = SVNURL.parseURIDecoded("http://" + SVN_URL);
} catch (SVNException e2) {
e2.printStackTrace();
}
/*
* A revision to check out
*/
SVNRevision revision = SVNRevision.HEAD;
/*
* A revision for which you're sure that the url you specify is
* exactly what you need
*/
SVNRevision pegRevision = SVNRevision.HEAD;
/*
* A local path where a Working Copy will be ckecked out
*/
File destPath = new File(m_installpath);
/*
* returns the number of the revision at which the working copy is
*/
try {
System.out.println(m_installpath);
m_taskOutput.append("Game folder: " + m_installpath + "\n");
boolean exists = destPath.exists();
if (!exists) {
m_taskOutput
.append("Installing...\nPlease be patient while PokeNet is downloaded...\n");
System.out.println("Installing...");
updateClient.doCheckout(url, destPath, pegRevision,
revision, SVNDepth.INFINITY, true);
} else {
ourClientManager.getWCClient().doCleanup(destPath);
m_taskOutput.append("Updating...\n");
System.out.println("Updating...\n");
updateClient.doUpdate(destPath, revision,
SVNDepth.INFINITY, true, true);
}
} catch (SVNException e1) {
// It's probably locked, lets cleanup and resume.
e1.printStackTrace();
try {
ourClientManager.getWCClient().doCleanup(destPath);
m_taskOutput.append("Resuming Download...\n");
System.out.println("Resuming Download...\n");
updateClient.doUpdate(destPath, revision,
SVNDepth.INFINITY, true, true);
} catch (SVNException e) {
e.printStackTrace();
}
}