protected void doGet(HttpServletRequest req, HttpServletResponse rsp)
throws IOException {
rsp.setContentType("text/json");
rsp.setCharacterEncoding("UTF-8");
QueryProcessor p = processor.get();
OutputFormat format = OutputFormat.JSON;
try {
format = OutputFormat.valueOf(get(req, "format", format.toString()));
} catch (IllegalArgumentException err) {
error(rsp, "invalid format");
return;
}
switch (format) {
case JSON:
rsp.setContentType("text/json");
rsp.setCharacterEncoding("UTF-8");
break;
case TEXT:
rsp.setContentType("text/plain");
rsp.setCharacterEncoding("UTF-8");
break;
default:
error(rsp, "invalid format");
return;
}
p.setIncludeComments(get(req, "comments", false));
p.setIncludeCurrentPatchSet(get(req, "current-patch-set", false));
p.setIncludePatchSets(get(req, "patch-sets", false));
p.setIncludeApprovals(get(req, "all-approvals", false));
p.setOutput(rsp.getOutputStream(), format);
p.query(get(req, "q", "status:open"));
}