Пример #1
0
  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;
  }
Пример #2
0
  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;
  }