protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
HttpSession session = request.getSession(true);
DigitalObject requestedFile = null;
String fileId = request.getParameter("fileId");
if (fileId.equalsIgnoreCase("mandate")
|| fileId.equalsIgnoreCase("community")
||fileId.equalsIgnoreCase("policy")) {
requestedFile = getFile(fileId, request, response);
} else if (fileId.equalsIgnoreCase("report")) {
IDownloadManagerHelperBean mgr = (IDownloadManagerHelperBean)session.getAttribute("downloadManagerHelperBean");
if (mgr == null) {
response.sendRedirect("/plato/project/loadPlan.seam");
return;
}
String ppId = request.getParameter("ppId");
requestedFile = mgr.getUploadedReportFile(ppId);
}
if (requestedFile == null) {
response.sendRedirect("/plato/project/loadPlan.seam");
return;
}
response.setHeader("Content-Disposition", "attachment;filename=\""
+ requestedFile.getFullname() + "\"");
response.setContentLength((int) requestedFile.getData().getData().length);
response.setContentType(requestedFile.getContentType());
try {
ByteArrayInputStream in = new ByteArrayInputStream(requestedFile.getData().getData());
OutputStream out = response.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count;