public void renderAvatar(
HttpServletRequest request,
HttpServletResponse response,
@PathVariable Long id)
throws NotFoundException, IOException {
JCUser user = userService.get(id);
Date ifModifiedDate = getIfModifiedSineDate(request.getHeader(IF_MODIFIED_SINCE_HEADER));
if (!user.getAvatarLastModificationTime().isAfter(ifModifiedDate.getTime())) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
} else {
byte[] avatar = user.getAvatar();
response.setContentType("image/jpeg");
response.setContentLength(avatar.length);
response.getOutputStream().write(avatar);
}
Date avatarLastModificationDate = new Date(
user.getAvatarLastModificationTime().getMillis());
setupAvatarHeaders(response, avatarLastModificationDate);
}