@Override
 public void downloadFile(UUID id, HttpServletResponse response)
     throws ObjectNotFoundException, FileNotFoundException, IOException {
   StudentDocument studentDocument = get(id);
   if (studentDocument == null) {
     throw new ObjectNotFoundException(
         "could not find document with id of " + id, StudentDocument.class.toString());
   }
   File file = new File(studentDocument.getFileLocation());
   InputStream is = new FileInputStream(file);
   response.setHeader(
       "Content-Disposition", "attachment; filename=" + studentDocument.getFileName());
   // copy it to response's OutputStream
   IOUtils.copy(is, response.getOutputStream());
   response.flushBuffer();
 }
  @Override
  public StudentDocument createStudentDocFromUploadBean(
      StudentDocumentTO bean, String fileLocation, UUID studentId) throws ObjectNotFoundException {

    StudentDocument studentDocument = new StudentDocument();
    studentDocument.setComments(bean.getComment());
    studentDocument.setFileLocation(fileLocation);
    studentDocument.setName(bean.getName());
    studentDocument.setAuthor(getSecurityService().currentlyAuthenticatedUser().getPerson());
    if (bean.getConfidentialityLevelId() != null) {
      studentDocument.setConfidentialityLevel(
          getConfidentialityLevelService().get(bean.getConfidentialityLevelId()));
    }
    studentDocument.setPerson(getPersonService().get(studentId));
    studentDocument.setFileName(bean.getFile().getOriginalFilename());
    return studentDocument;
  }