package de.tutorials.web.svn.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.tigris.subversion.javahl.ClientException;
import org.tigris.subversion.javahl.Revision;
import org.tigris.subversion.javahl.SVNClient;
import org.tigris.subversion.javahl.SVNClientInterface;
/**
* Servlet implementation class for Servlet: SVNDownloadServlet
*
* @web.servlet name="SVNDownloadServlet" display-name="SVNDownloadServlet"
*
* @web.servlet-mapping url-pattern="/SVNDownloadServlet"
*
*/
public class SVNDownloadServlet extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {
/*
* (non-Java-doc)
*
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public SVNDownloadServlet() {
super();
}
/*
* (non-Java-doc)
*
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
* HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment; filename=eclipse.dat;");
SVNClientInterface svnClient = null;
try {
svnClient = new SVNClient();
svnClient.username("tom");
svnClient.password("tom");
svnClient.streamFileContent(
"svn://localhost/de.tutorials.web.svn/eclipse.zip",
Revision.getInstance(14L), Revision.getInstance(14L),
16384, response.getOutputStream());
} catch (ClientException e) {
e.printStackTrace();
} finally {
if (svnClient != null) {
svnClient.dispose();
}
}
}
}