type = Task.TestType.valueOf(testType);
} catch (IllegalArgumentException e) {
response.sendRedirect("");
return;
}
FileInfo fileInfo = contestManager.getTestDataFile(contestId,
task.getName(),
testNumber,
type);
if (fileInfo == null || fileInfo.getSize() > Integer.MAX_VALUE) {
response.sendRedirect("");
return;
}
response.setContentType("plain/text");
response.setContentLength((int) fileInfo.getSize());
response.setHeader("Content-Disposition", "attachment; filename=\""
+ new File(fileInfo.getAbsolutePath()).getName()
+ "\"");
FileUtils.copyStreams(fileInfo.getInputStream(), response.getOutputStream());
fileInfo.getInputStream().close();
}