put("reportname", inReport.getReportName());
tokens.put("description", inReport.getDescription());
tokens.put("groups", inReport.getGroups());
CHAPTER 7 n ENTER THE ENTERPRISE: A DWR-BASED REPORT PORTAL 400
tokens.put("reportxml", inReport.getReportXML());
tokens.put("datasourcename", inReport.getDataSourceName());
databaseWorker.executeUpdate(SQL_ADD_REPORT_TO_PORTAL, tokens);
return getReportsList(inRequest);
} catch (DataIntegrityViolationException dive) {
throw new Exception("Report could not be created.\n\n" +
"(Does the report already exist?)");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
Since what is passed in to this method is a ReportDescriptor object, we simply pull the
values we need from it for inclusion in the data Map to replace tokens in the SQL query with,
and off we go. Note the same DataIntegrityViolationException handling as we saw earlier.
Also note that this method, and a number of others, has the HttpServletRequest as a parameter.
Recall that DWR will automagically populate this for us, and it??™s time we have such a
parameter present.
Removing a report from the portal is the next function, and it is encapsulated in the
removeReportFromPortal() method:
public List
removeReportFromPortal(
final String inReportName, final HttpServletRequest inRequest)
throws Exception {
try {
Map tokens = new HashMap();
tokens.
Pages:
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695