diff options
author | James Moger <james.moger@gitblit.com> | 2011-05-26 17:11:38 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-05-26 17:11:38 -0400 |
commit | 2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa (patch) | |
tree | b9bc648068b0af5cbbbc3e2e0ad707e0c59d4db2 /src/com/gitblit/DownloadZipServlet.java | |
parent | f13c4c5a35a18d8478b276cc44570bbc3398aa73 (diff) | |
download | gitblit-2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa.tar.gz gitblit-2a7306a1d92522569a8bb6e5a7c0bcdd5cf4cfaa.zip |
Findbugs. CodePro Audit. Checkstyle. Unit test refactoring.
Diffstat (limited to 'src/com/gitblit/DownloadZipServlet.java')
-rw-r--r-- | src/com/gitblit/DownloadZipServlet.java | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/com/gitblit/DownloadZipServlet.java b/src/com/gitblit/DownloadZipServlet.java index caa0a358..3bbf2253 100644 --- a/src/com/gitblit/DownloadZipServlet.java +++ b/src/com/gitblit/DownloadZipServlet.java @@ -32,30 +32,24 @@ import com.gitblit.wicket.models.RepositoryModel; public class DownloadZipServlet extends HttpServlet {
- public static String asLink(String baseURL, String repository, String objectId, String path) {
- return baseURL + (baseURL.endsWith("/") ? "" : "/") + "zip?r=" + repository + (path == null ? "" : ("&p=" + path)) + (objectId == null ? "" : ("&h=" + objectId));
- }
-
private static final long serialVersionUID = 1L;
- private final static Logger logger = LoggerFactory.getLogger(DownloadZipServlet.class);
+ private transient Logger logger = LoggerFactory.getLogger(DownloadZipServlet.class);
public DownloadZipServlet() {
super();
}
- @Override
- protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
- processRequest(request, response);
- }
-
- @Override
- protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
- processRequest(request, response);
+ public static String asLink(String baseURL, String repository, String objectId, String path) {
+ return baseURL + (baseURL.endsWith("/") ? "" : "/") + "zip?r=" + repository
+ + (path == null ? "" : ("&p=" + path))
+ + (objectId == null ? "" : ("&h=" + objectId));
}
- private void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
- if (!GitBlit.self().settings().getBoolean(Keys.web.allowZipDownloads, true)) {
+ private void processRequest(javax.servlet.http.HttpServletRequest request,
+ javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,
+ java.io.IOException {
+ if (!GitBlit.getBoolean(Keys.web.allowZipDownloads, true)) {
logger.warn("Zip downloads are disabled");
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
@@ -96,7 +90,8 @@ public class DownloadZipServlet extends HttpServlet { String contentType = "application/octet-stream";
response.setContentType(contentType + "; charset=" + response.getCharacterEncoding());
// response.setContentLength(attachment.getFileSize());
- response.setHeader("Content-Disposition", "attachment; filename=\"" + name + ".zip" + "\"");
+ response.setHeader("Content-Disposition", "attachment; filename=\"" + name + ".zip"
+ + "\"");
response.setDateHeader("Last-Modified", date.getTime());
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
@@ -112,4 +107,18 @@ public class DownloadZipServlet extends HttpServlet { logger.error("Failed to write attachment to client", t);
}
}
+
+ @Override
+ protected void doPost(javax.servlet.http.HttpServletRequest request,
+ javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,
+ java.io.IOException {
+ processRequest(request, response);
+ }
+
+ @Override
+ protected void doGet(javax.servlet.http.HttpServletRequest request,
+ javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,
+ java.io.IOException {
+ processRequest(request, response);
+ }
}
|