@RequestMapping(value = "/getDocumentContent", method = RequestMethod.GET)
 public @ResponseBody String getDocumentContent(
     @RequestParam(value = "nID") Long id, @RequestParam(value = "nID_Subject") long nID_Subject)
     throws ActivitiRestException {
   Document document = documentDao.getDocument(id);
   if (nID_Subject != document.getSubject().getId()) {
     throw new ActivitiRestException("401", "You don't have access!");
   } else {
     return Util.contentByteToString(
         documentDao.getDocumentContent(document.getContentKey())); // ????
   }
 }
  @RequestMapping(value = "/getDocumentFile", method = RequestMethod.GET)
  public @ResponseBody byte[] getDocumentFile(
      @RequestParam(value = "nID") Long id,
      @RequestParam(value = "nID_Subject") long nID_Subject,
      @RequestParam(value = "sCode_DocumentAccess", required = false) String accessCode,
      @RequestParam(value = "nID_DocumentOperator_SubjectOrgan", required = false) Long organID,
      @RequestParam(value = "nID_DocumentType", required = false) Long docTypeID,
      @RequestParam(value = "sPass", required = false) String password,
      HttpServletRequest request,
      HttpServletResponse httpResponse)
      throws ActivitiRestException {
    Document document = documentDao.getDocument(id);
    if (nID_Subject != document.getSubject().getId()) {

      if (accessCode != null) {
        Document oDocument =
            handlerFactory
                .buildHandlerFor(documentDao.getOperator(organID))
                .setDocumentType(docTypeID)
                .setAccessCode(accessCode)
                .setPassword(password)
                .getDocument();
        if (oDocument == null) {
          throw new ActivitiRestException("401", "You don't have access by accessCode!");
        }
      } else {
        throw new ActivitiRestException("401", "You don't have access!");
      }
    }
    byte[] content = documentDao.getDocumentContent(document.getContentKey());
    // byte[] content = "".getBytes();

    httpResponse.setHeader("Content-disposition", "attachment; filename=" + document.getFile());
    // httpResponse.setHeader("Content-Type", document.getDocumentContentType()
    //		.getName() + ";charset=UTF-8");
    httpResponse.setHeader("Content-Type", document.getContentType() + ";charset=UTF-8");
    httpResponse.setContentLength(content.length);
    return content;
  }