@RequestMapping(value = "/setDocument", method = RequestMethod.GET)
  public @ResponseBody Long setDocument(
      @RequestParam(value = "nID_Subject", required = false) long nID_Subject,
      @RequestParam(value = "sID_Subject_Upload") String sID_Subject_Upload,
      @RequestParam(value = "sSubjectName_Upload") String sSubjectName_Upload,
      @RequestParam(value = "sName") String sName,
      // @RequestParam(value = "sFile", required = false) String fileName,
      @RequestParam(value = "nID_DocumentType") Long nID_DocumentType,
      // @RequestParam(value = "nID_DocumentContentType", required = false) Integer
      // nID_DocumentContentType,
      @RequestParam(value = "sDocumentContentType", required = false)
          String documentContentTypeName,
      @RequestParam(value = "soDocumentContent") String sContent,
      @RequestParam(value = "oSignData") String oSignData, // todo required?? (issue587)
      // @RequestParam(value = "oFile", required = false) MultipartFile oFile,
      // @RequestBody byte[] content,
      HttpServletRequest request,
      HttpServletResponse httpResponse)
      throws IOException {

    // MultipartFile oFile = new MockMultipartFile("filename.txt", "fullfilename.txt", "text/plain",
    // sContent.getBytes());
    String sFileName = "filename.txt";
    String sFileContentType = "text/plain";
    byte[] aoContent = sContent.getBytes();

    documentContentTypeName =
        request.getHeader("Content-Type") != null
            ? request.getHeader("filename")
            : documentContentTypeName;
    DocumentContentType documentContentType = null;
    if (documentContentTypeName != null) {
      documentContentType = documentContentTypeDao.getDocumentContentType(documentContentTypeName);
      if (documentContentType == null) {
        documentContentType = new DocumentContentType();
        documentContentType.setName(documentContentTypeName);
        documentContentType.setId(documentContentTypeDao.setDocumentContent(documentContentType));
      }
    } else {
      throw new ActivitiObjectNotFoundException(
          "RequestParam 'nID_DocumentContentType' not found!", DocumentContentType.class);
    }

    Subject subject_Upload = syncSubject_Upload(sID_Subject_Upload);

    return documentDao.setDocument(
        nID_Subject,
        subject_Upload.getId(),
        sID_Subject_Upload,
        sSubjectName_Upload,
        sName,
        nID_DocumentType,
        documentContentType.getId(),
        sFileName,
        sFileContentType,
        aoContent,
        oSignData);
  }
 @RequestMapping(value = "/removeDocumentContentType", method = RequestMethod.GET)
 public @ResponseBody void removeDocumentContentType(
     @RequestParam(value = "nID") Long nID, HttpServletResponse response) {
   try {
     documentContentTypeDao.removeDocumentContentType(nID);
   } catch (RuntimeException e) {
     response.setStatus(403);
     response.setHeader("Reason", e.getMessage());
   }
 }
 @RequestMapping(value = "/setDocumentContentType", method = RequestMethod.GET)
 public @ResponseBody ResponseEntity<DocumentContentType> setDocumentContentType(
     @RequestParam(value = "nID") Long nID, @RequestParam(value = "sName") String sName) {
   ResponseEntity<DocumentContentType> result;
   try {
     DocumentContentType documentType = documentContentTypeDao.setDocumentContentType(nID, sName);
     result = JsonRestUtils.toJsonResponse(documentType);
   } catch (RuntimeException e) {
     result = toJsonErrorResponse(403, e.getMessage());
   }
   return result;
 }
 @RequestMapping(value = "/getDocumentContentTypes", method = RequestMethod.GET)
 public @ResponseBody List<DocumentContentType> getDocumentContentTypes() {
   return documentContentTypeDao.getDocumentContentTypes();
 }