{
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@SuppressWarnings("unchecked")
LogFileHelper helper = new LogFileHelper(Collections.list(LogManager.getRootLogger().getAllAppenders()));
List<LogFileDetails> logFiles = null;
try
{
logFiles = helper.findLogFileDetails(requestedFiles);
}
catch(IllegalArgumentException e)
{
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
if (logFiles.size() == 0)
{
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
String fileName = String.format(LOGS_FILE_NAME, new SimpleDateFormat(DATE_FORMAT).format(new Date()));
response.setStatus(HttpServletResponse.SC_OK);
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setContentType(LogFileHelper.ZIP_MIME_TYPE);
OutputStream os = response.getOutputStream();
try
{
helper.writeLogFiles(logFiles, os);
}
finally
{
if (os != null)
{