Package org.openntf.domino

Examples of org.openntf.domino.Stream$Schema


            return doc;
        }

        private void addSchema(Document doc, String id, SimpleFeatureType featureType) {
            Schema schema = doc.createAndAddSchema();
            schema.setId(id);
            schema.setName(id);
            for (AttributeDescriptor ad : featureType.getAttributeDescriptors()) {
                // skip geometry attributes
                if (ad instanceof GeometryDescriptor) {
                    continue;
                }

                SimpleField field = schema.createAndAddSimpleField();
                field.setName(ad.getLocalName());
                field.setType(getKmlFieldType(ad));
            }
        }
View Full Code Here


  private int getStrPayloadLotus(final Session sess, final String whose) throws IOException {

    int payload = 0;
    File fAux = null;
    Stream str = null;
    try {
      fAux = File.createTempFile("ntfdom", "aux.tmp");
      str = sess.createStream();
      str.open(fAux.getPath(), "LMBCS");
      str.writeText(whose);
      payload = str.getBytes();

    } finally {
      if (str != null)
        str.close();
      if (fAux != null)
        fAux.delete();
    }
    return payload;
  }
View Full Code Here

   * @see org.openntf.domino.email.IEmail#addAttachments(java.util.ArrayList, org.openntf.domino.MIMEEntity)
   */
  @Override
  public void addAttachments(final MIMEEntity parent) {
    try {
      Stream streamFile = null;
      for (IEmailAttachment attach : getAttachments()) {
        InputStream is = null;
        EmbeddedObject eo = null;

        String fileName = attach.getFileName();
        // Get content type
        String contentType = URLConnection.guessContentTypeFromName(fileName);
        if (null == contentType) {
          contentType = "application/octet-stream";
        }
        int idex = StringUtil.indexOfIgnoreCase(fileName, ".", fileName.length() - 6);
        if (idex > -1) {
          String extension = fileName.substring(idex);
          if (StringUtil.equals("gif", extension)) {
            contentType = "image/gif";
          } else if (StringUtil.equals("jpg", extension) || StringUtil.equals("jpeg", extension)) {
            contentType = "image/jpeg";
          } else if (StringUtil.equals("png", extension)) {
            contentType = "image/png";
          }
        }
        contentType += "; name=\"" + fileName + "\"";

        try {
          Type attachmentType = attach.getAttachmentType();
          if (attachmentType == Type.DOCUMENT) {
            //retrieve the document containing the attachment to send from the relevant
            Database dbFile = getSession().getDatabase(getSession().getServerName(), attach.getDbPath());
            Document docFile = dbFile.getDocumentByUNID(attach.getUnid());
            if (null != docFile) {
              eo = docFile.getAttachment(attach.getFileName());
              is = eo.getInputStream();
            }
          } else if (attachmentType == Type.FILE) {
            is = new FileInputStream(attach.getPath() + attach.getFileName());
          } else if (attachmentType == Type.STREAM) {
            is = attach.getInputStream();
          } else {
            is = new ByteArrayInputStream(attach.getBytes());
          }

          if (null != is) {
            MIMEEntity mimeChild = parent.createChildEntity();
            MIMEHeader mimeHeader = mimeChild.createHeader("Content-Disposition");

            if (attach.isInlineImage()) {
              mimeHeader.setHeaderVal("inline; filename=\"" + attach.getFileName() + "\"");
            } else {
              mimeHeader.setHeaderVal("attachment; filename=\"" + attach.getFileName() + "\"");
            }

            mimeHeader = mimeChild.createHeader("Content-ID");
            mimeHeader.setHeaderVal("<" + attach.getContentId() + ">");

            streamFile = getSession().createStream();
            streamFile.setContents(is);
            mimeChild.setContentFromBytes(streamFile, contentType, MIMEEntity.ENC_IDENTITY_BINARY);
            streamFile.close();
          }
        } catch (Exception e) {
          DominoUtils.handleException(e);
        } finally {
          if (null != is) {
View Full Code Here

   * @see org.openntf.domino.email.IEmail#send()
   */
  @Override
  public Document send() {
    try {
      Stream stream;
      MIMEEntity mimeEntity;
      MIMEHeader mimeHeader;
      Database currDb;

      Session currSess = getSession();
      currSess.setConvertMime(false); // in case Khan is still in suspended animation!

      // Create memo doc
      try {
        currDb = currSess.getCurrentDatabase();
        if (null == currDb) {
          // Will this work if we're running from DOTS or OSGi plugin??
          currDb = currSess.getDatabase(currSess.getServerName(), "mail.box");
        }
      } catch (Throwable t) {
        currDb = currSess.getDatabase(currSess.getServerName(), "mail.box");
      }
      Document memo = currDb.createDocument();
      memo.put("RecNoOutOfOffice", "1");    //no replies from out of office agents
      MIMEEntity mimeRoot = memo.createMIMEEntity("Body");

      mimeHeader = mimeRoot.createHeader("To");
      mimeHeader.setHeaderVal(join(getTo(), ""));
      memo.replaceItemValue("sendTo", getTo());

      if (cc_.size() > 0) {
        mimeHeader = mimeRoot.createHeader("CC");
        mimeHeader.setHeaderVal(join(getCC(), ""));
        memo.replaceItemValue("cc", getCC());
      }

      if (bcc_.size() > 0) {
        mimeHeader = mimeRoot.createHeader("BCC");
        mimeHeader.setHeaderVal(join(getBCC(), ""));
        memo.replaceItemValue("bcc", getBCC());
      }

      //set subject
      mimeHeader = mimeRoot.createHeader("Subject");
      mimeHeader.setHeaderVal(getSubject());

      //create text/alternative directive: text/plain and text/html part will be childs of this entity
      MIMEEntity mimeRootChild = mimeRoot.createChildEntity();
      String mimeBoundary = memo.getUniversalID().toLowerCase();
      mimeHeader = mimeRootChild.createHeader("Content-Type");
      mimeHeader.setHeaderVal("multipart/alternative; boundary=\"" + mimeBoundary + "\"");

      //create plain text part
      if (getText().size() > 0) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        stream.writeText(join(getText(), System.getProperty("line.separator")));
        mimeEntity.setContentFromText(stream, "text/plain; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
      }

      //create HTML part
      if (contentsHTML_.size() > 0) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        stream.writeText(join(contentsHTML_, System.getProperty("line.separator")));
        mimeEntity.setContentFromText(stream, "text/html; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
      }

      //create embedded JSON part
      if (StringUtil.isEmpty(getJSON())) {
        mimeEntity = mimeRootChild.createChildEntity();
        stream = currSess.createStream();
        String json = "{\"url\" : \"" + getJSON() + "\"}" + System.getProperty("line.separator");
        stream.writeText(json);
        mimeEntity.setContentFromText(stream, "application/embed+json; charset=\"UTF-8\"", MIMEEntity.ENC_NONE);
        stream.close();
      }

      // Add any attachments
      addAttachments(mimeRoot);

View Full Code Here

TOP

Related Classes of org.openntf.domino.Stream$Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.