public static final String FEDERATION_PATH = "/federation/";\r
\r
public static final String RPC_PATH = "/rpc/";\r
+ \r
+ public static final String PAGES= "/pages/";\r
\r
public static final String BORDER = "***********************************************************";\r
\r
public static final String FEDERATION_USER = "$gitblit";\r
\r
public static final String PROPOSAL_EXT = ".json";\r
-\r
+ \r
+ public static final String ENCODING = "UTF-8";\r
+ \r
public static String getGitBlitVersion() {\r
return NAME + " v" + VERSION;\r
}\r
*/\r
package com.gitblit;\r
\r
+import java.io.IOException;\r
+import java.text.MessageFormat;\r
+import java.text.ParseException;\r
import java.util.Date;\r
\r
+import javax.servlet.ServletException;\r
import javax.servlet.http.HttpServlet;\r
import javax.servlet.http.HttpServletResponse;\r
\r
import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.MarkdownUtils;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
response.sendError(HttpServletResponse.SC_FORBIDDEN);\r
return;\r
}\r
- \r
+\r
String repository = request.getParameter("r");\r
String basePath = request.getParameter("p");\r
String objectId = request.getParameter("h");\r
}\r
\r
Repository r = GitBlit.self().getRepository(repository);\r
+ if (r == null) {\r
+ error(response, MessageFormat.format("# Error\nFailed to find repository {0}", repository));\r
+ return;\r
+ }\r
RevCommit commit = JGitUtils.getCommit(r, objectId);\r
+ if (commit == null) {\r
+ error(response, MessageFormat.format("# Error\nFailed to find commit {0}", objectId));\r
+ r.close();\r
+ return;\r
+ }\r
Date date = JGitUtils.getCommitDate(commit);\r
+\r
String contentType = "application/octet-stream";\r
response.setContentType(contentType + "; charset=" + response.getCharacterEncoding());\r
response.setHeader("Content-Disposition", "attachment; filename=\"" + name + ".zip"\r
} catch (Throwable t) {\r
logger.error("Failed to write attachment to client", t);\r
}\r
+\r
+ // close the repository\r
+ r.close();\r
} catch (Throwable t) {\r
logger.error("Failed to write attachment to client", t);\r
}\r
}\r
\r
+ private void error(HttpServletResponse response, String mkd) throws ServletException,\r
+ IOException, ParseException {\r
+ String content = MarkdownUtils.transformMarkdown(mkd);\r
+ response.setContentType("text/html; charset=" + Constants.ENCODING);\r
+ response.getWriter().write(content);\r
+ }\r
+\r
@Override\r
protected void doPost(javax.servlet.http.HttpServletRequest request,\r
javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,\r