public UploadedFile[] processJava2Domino(Document docCurrent, Object objCurrent, Definition def) {
    try {

      UploadedFile file = getValue(objCurrent, def.getJavaField());

      if (file != null) {
        IUploadedFile FTemp = file.getUploadedFile();
        File SrFile = FTemp.getServerFile();

        File FNew =
            new File(
                SrFile.getParentFile().getAbsolutePath()
                    + File.separator
                    + FTemp.getClientFileName());
        SrFile.renameTo(FNew);
        RichTextItem rt = null;
        rt = (RichTextItem) docCurrent.getFirstItem(def.getNotesField());
        if (rt == null) rt = docCurrent.createRichTextItem(def.getNotesField());
        rt.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", FNew.getAbsolutePath(), null);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
  public FileHelper addFile(FileHelper fh, UploadedFile file, String strNewId) {
    try {
      Database ndbCurrent =
          ExtLibUtil.getCurrentSession().getDatabase(fh.getServer(), fh.getPath());
      if (ndbCurrent == null) return null;
      Document docCurrent = ndbCurrent.getDocumentByUNID(fh.getDocID());
      if (docCurrent == null) {
        ndbCurrent.recycle();
        return null;
      }
      IUploadedFile FTemp = file.getUploadedFile();
      File SrFile = FTemp.getServerFile();

      File FNew =
          new File(
              SrFile.getParentFile().getAbsolutePath()
                  + File.separator
                  + FTemp.getClientFileName());
      SrFile.renameTo(FNew);
      RichTextItem rt = null;
      rt = (RichTextItem) docCurrent.getFirstItem(fh.getFieldName());
      if (rt == null) {
        rt = docCurrent.createRichTextItem(fh.getFieldName());
      }

      EmbeddedObject em =
          rt.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", FNew.getAbsolutePath(), null);

      docCurrent.save(true, false, true);
      FileHelper fhNew = new FileHelper();
      fhNew.setFieldName(fh.getFieldName());
      fhNew.setServer(fh.getServer());
      fhNew.setPath(fh.getPath());
      fhNew.setFileSize(em.getFileSize());
      fhNew.setName(em.getName());
      fhNew.setDisplayName(FTemp.getClientFileName());
      fhNew.setId(strNewId);
      fhNew.setDocID(fh.getDocID());
      fhNew.setFileType(ComponentSessionFacade.get().getMimeTypes().getContentType(FNew));
      fhNew.setNewFile(false);

      rt.recycle();
      docCurrent.recycle();
      ndbCurrent.recycle();

      return fhNew;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 /**
  * RWFException constructor
  *
  * @param - msg, String the error message to be used.
  * @param Database d the current database
  * @param Document doc the context document.
  */
 public RWFException(String msg, Database d, Document doc) {
   super(msg);
   try {
     Document e = d.createDocument();
     e.replaceItemValue("Form", EXCEPTION_FORM);
     e.replaceItemValue(EXCEPTION_TYPE_FIELD, "Workflow Exception");
     e.replaceItemValue(EXCEPTION_MSG_FIELD, msg);
     RichTextItem rt = e.createRichTextItem(EXCEPTION_DOCLINK_FIELD);
     rt.appendDocLink(doc);
     e.save();
   } catch (NotesException e) {
     e.printStackTrace();
     System.out.println(e.text);
   }
 }
  @SuppressWarnings("unchecked")
  public void removeFile(FileHelper fh) {
    try {
      Database ndbCurrent =
          ExtLibUtil.getCurrentSession().getDatabase(fh.getServer(), fh.getPath());
      if (ndbCurrent == null) return;
      Document docCurrent = ndbCurrent.getDocumentByUNID(fh.getDocID());
      if (docCurrent == null) {
        ndbCurrent.recycle();
        return;
      }
      // RESULTS IN NOTE ITEM NOT FOUND ERROR AFTERWARDS
      // EmbeddedObject entity = docCurrent.getAttachment(fh.getName());
      // if (entity == null)
      // return;
      // entity.remove();

      RichTextItem rti = (RichTextItem) docCurrent.getFirstItem(fh.getFieldName());
      Vector<EmbeddedObject> entitys = rti.getEmbeddedObjects();

      for (EmbeddedObject entity : entitys) {
        if (entity.getType() == EmbeddedObject.EMBED_ATTACHMENT) {
          if (entity.getName().equals(fh.getName())) {
            entity.remove();
            break;
          }
        }
      }
      docCurrent.save(true, false, true);

      rti.recycle();
      docCurrent.recycle();
      ndbCurrent.recycle();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }