Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.jee.servlet;
 
Show the most recent audit log events. Defaults to returning 2000 most recent log entries. Only includes debug messages if requested and if available.
public class AuditDownloadServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	public AuditDownloadServlet(JeeBase jeethrows IOException {
		super(jee);
	}
	@SuppressWarnings("unchecked")
	public void doGet(String tokenUser uHttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
		String fileName = "audit_" + Json.toDateTime(new Date()) + ".csv";
		response.setContentType("text/plain; charset=UTF-8; name=\"" + fileName + "\"");
		response.setHeader("Content-Disposition""attachment; filename=\"" + fileName + "\"");
		response.setHeader("Cache-Control""max-age=60");
		List<AuditLogEntryr = .getAPI().getRecentLogEntries(unullnulltrue, 100000);
		PrintWriter out = response.getWriter();
		for(AuditLogEntry i : r) {
			out.append("\"" + Json.toDateTime(i.getDate()));
			out.append("\",");
			out.append(i.getIp());
			out.append(",");
			out.append(i.getLevel());
			out.append(",");
			out.append(i.getPersonUuid() == null?"":i.getPersonUuid().toString());
			out.append(",\"");
			out.append("\",\"");
			out.append(i.getMessage().replaceAll("\"""\\\\\\\""));
			out.append("\"\r\n");
		}
	}
New to GrepCode? Check out our FAQ X