if (null == file) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
final Blob content = (Blob) file.get(File.FILE_CONTENT);
final String name = file.getString(File.FILE_NAME);
response.addHeader("Content-Disposition",
"attachment; filename="
+ URLEncoder.encode(name, "UTF-8"));
response.setContentType(file.getString(File.FILE_CONTENT_TYPE));
response.getOutputStream().write(content.getBytes());
response.getOutputStream().close();
final int downloadCnt = file.getInt(File.FILE_DOWNLOAD_COUNT);
file.put(File.FILE_DOWNLOAD_COUNT, downloadCnt + 1);
fileRepository.update(id, file);