@Override
public ActionForward execute(final ActionMapping mapping, final ActionForm actionForm, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
final String oid = request.getParameter("oid");
final File file = FenixFramework.getDomainObject(oid);
if (file == null) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.getWriter().write(HttpStatus.getStatusText(HttpStatus.SC_BAD_REQUEST));
response.getWriter().close();
} else {
final Person person = AccessControl.getPerson();
if (!file.isPrivate() || file.isPersonAllowedToAccess(person)) {
response.setContentType(file.getContentType());
response.addHeader("Content-Disposition", "attachment; filename=" + file.getFilename());
response.setContentLength(file.getSize().intValue());
final DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.write(file.getContents());
dos.close();
} else if (file.isPrivate() && person == null) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.getWriter().write(HttpStatus.getStatusText(HttpStatus.SC_UNAUTHORIZED));
response.getWriter().close();
} else {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);