| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.web.servlets; |
| 20 |
|
|
| 21 |
|
import java.io.IOException; |
| 22 |
|
|
| 23 |
|
import javax.servlet.ServletConfig; |
| 24 |
|
import javax.servlet.ServletException; |
| 25 |
|
import javax.servlet.ServletOutputStream; |
| 26 |
|
import javax.servlet.http.HttpServletRequest; |
| 27 |
|
import javax.servlet.http.HttpServletResponse; |
| 28 |
|
|
| 29 |
|
import org.apache.log4j.Logger; |
| 30 |
|
import org.itracker.model.Report; |
| 31 |
|
import org.itracker.services.ReportService; |
| 32 |
|
|
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 8 |
Complexity Density: 0.42 |
|
| 34 |
|
public class ReportDownloadController extends GenericController { |
| 35 |
|
|
| 36 |
|
private static final Logger logger = Logger.getLogger(ReportDownloadController.class); |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
private static final long serialVersionUID = 1L; |
| 41 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 42 |
0
|
public ReportDownloadController() {... |
| 43 |
|
} |
| 44 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 45 |
0
|
public void init(ServletConfig config) {... |
| 46 |
|
|
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0.32 |
|
| 49 |
0
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {... |
| 50 |
0
|
if(! isLoggedInWithRedirect(request, response)) { |
| 51 |
0
|
return; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
0
|
try { |
| 61 |
0
|
ReportService reportService = getITrackerServices(getServletContext()).getReportService(); |
| 62 |
|
|
| 63 |
0
|
Integer reportId = null; |
| 64 |
0
|
Report report = null; |
| 65 |
|
|
| 66 |
0
|
try { |
| 67 |
0
|
reportId = new Integer((request.getParameter("id") == null ? "-1" : (request.getParameter("id")))); |
| 68 |
0
|
report = reportService.getReportDAO().findByPrimaryKey(reportId); |
| 69 |
|
} catch(NumberFormatException nfe) { |
| 70 |
0
|
if (logger.isDebugEnabled()) { |
| 71 |
0
|
logger.debug("Invalid reportId " + request.getParameter("id") + " specified."); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
|
|
| 75 |
0
|
if(report == null) { |
| 76 |
0
|
forward("/error.jsp", request, response); |
| 77 |
0
|
return; |
| 78 |
|
} |
| 79 |
|
|
| 80 |
0
|
response.setHeader("Content-Disposition", "attachment; filename=report" + report.getId() + "\""); |
| 81 |
0
|
ServletOutputStream out = response.getOutputStream(); |
| 82 |
|
|
| 83 |
0
|
out.close(); |
| 84 |
|
} catch(IOException ioe) { |
| 85 |
0
|
logger.info("Unable to display report.", ioe); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
0
|
return; |
| 89 |
|
} |
| 90 |
|
} |