// lock for reads now:
AppData.getReportsLock().readLock().lock();
try {
Map<String, Report> reports = AppData.getReports();
Report report = reports.get(reportPath);
if (report == null) {
try {
report = createReport(reportPath);
// add report to app scope:
reports.put(reportPath,report);
} catch (JAXBException e) {
log.info("Error unmarshalling XML report", e);
if ((e.getLinkedException() != null) &&
(e.getLinkedException() instanceof FileNotFoundException)) {
RequestDispatcher rd = request.getRequestDispatcher("/report_not_found.jsp");
rd.include(request, response);
} else {
RequestDispatcher rd = request.getRequestDispatcher("/bad_syntax.jsp");
request.setAttribute("error", e);
rd.include(request, response);
}
return;
} catch (BadReportSyntaxException e) {
log.info("Bad Report Syntax", e);
RequestDispatcher rd = request.getRequestDispatcher("/invalid_xml.jsp");
request.setAttribute("error", e);
rd.include(request, response);
return;
}
}
ReportSessionInfo reportSessionInfo = getReportSessionInfo(report,session,reportPath);
request.setAttribute(AttributeNames.reportSessionInfo,reportSessionInfo);
// check if user has access to this report:
if (report.hasAccess(request)) {
try {
if (request.getParameter(ParameterNames.clearData) != null) {
reportSessionInfo.clearCachedData();
response.sendRedirect(request.getContextPath() + request.getServletPath());
return;
}
if ((request.getParameter(ParameterNames.run) != null) || report.getAllInputs().size() == 0) {
Map<String, List> reportData = reportSessionInfo.runReport(request.getParameterMap());
request.setAttribute(AttributeNames.reportData,reportData);
} else if (reportSessionInfo.isReportWasRunAndDataWasNotCleared()) {
Map<String, List> reportData = reportSessionInfo.runOnlyForNonCachedData();
request.setAttribute(AttributeNames.reportData,reportData);