use of org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService.ReportFormat in project records-management by Alfresco.
the class AuditLogGet method execute.
@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
File auditTrail = null;
try {
RecordsManagementAuditQueryParameters queryParams = parseQueryParameters(req);
ReportFormat reportFormat = parseReportFormat(req);
if (!userCanAccessAudit(queryParams)) {
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Access denied because the user does not have the Access Audit capability");
}
// limit the number of audit log entries to be returned
if (queryParams.getMaxEntries() <= 0 || queryParams.getMaxEntries() > viewLogMaxSize) {
queryParams.setMaxEntries(viewLogMaxSize);
}
// parse the parameters and get a file containing the audit trail
auditTrail = this.rmAuditService.getAuditTrailFile(queryParams, reportFormat);
if (logger.isDebugEnabled()) {
logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath());
}
boolean attach = false;
String attachFileName = null;
String export = req.getParameter(PARAM_EXPORT);
if (export != null && Boolean.parseBoolean(export)) {
attach = true;
attachFileName = auditTrail.getName();
if (logger.isDebugEnabled()) {
logger.debug("Exporting audit trail using file name: " + attachFileName);
}
}
// stream the file back to the client
contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null);
} finally {
if (auditTrail != null) {
if (logger.isDebugEnabled()) {
logger.debug("Audit results written to file: \n" + " File: " + auditTrail + "\n" + " Parameter: " + parseQueryParameters(req));
} else {
auditTrail.delete();
}
}
}
}
Aggregations