Example usage for org.apache.poi.hsmf MAPIMessage setReturnNullOnMissingChunk

List of usage examples for org.apache.poi.hsmf MAPIMessage setReturnNullOnMissingChunk

Introduction

In this page you can find the example usage for org.apache.poi.hsmf MAPIMessage setReturnNullOnMissingChunk.

Prototype

public void setReturnNullOnMissingChunk(boolean returnNullOnMissingChunk) 

Source Link

Document

Sets whether on asking for a missing chunk, you get back null or a ChunkNotFoundException (default is the exception).

Usage

From source file:com.jaeksoft.searchlib.parser.MapiMsgParser.java

License:Open Source License

@Override
protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang)
        throws IOException, SearchLibException {
    MAPIMessage msg = new MAPIMessage(streamLimiter.getNewInputStream());
    msg.setReturnNullOnMissingChunk(true);
    ParserResultItem result = getNewParserResultItem();
    try {// w w w.jav  a 2s  .  c om
        result.addField(ParserFieldEnum.email_display_from, msg.getDisplayFrom());
        result.addField(ParserFieldEnum.email_display_to, msg.getDisplayTo());
        result.addField(ParserFieldEnum.email_display_cc, msg.getDisplayCC());
        result.addField(ParserFieldEnum.email_display_bcc, msg.getDisplayBCC());
        result.addField(ParserFieldEnum.subject, msg.getSubject());
        result.addField(ParserFieldEnum.htmlSource, msg.getHtmlBody());
        result.addField(ParserFieldEnum.content, msg.getTextBody());
        result.addField(ParserFieldEnum.creation_date, msg.getMessageDate());
        result.addField(ParserFieldEnum.email_conversation_topic, msg.getConversationTopic());
        RecipientChunks[] recipientChuncksList = msg.getRecipientDetailsChunks();
        if (recipientChuncksList != null) {
            for (RecipientChunks recipientChunks : recipientChuncksList) {
                result.addField(ParserFieldEnum.email_recipient_name, recipientChunks.getRecipientName());
                result.addField(ParserFieldEnum.email_recipient_address,
                        recipientChunks.getRecipientEmailAddress());
            }
        }
        if (StringUtils.isEmpty(msg.getHtmlBody()))
            result.langDetection(10000, ParserFieldEnum.content);
        else
            result.langDetection(10000, ParserFieldEnum.htmlSource);
    } catch (ChunkNotFoundException e) {
        Logging.warn(e);
    }
}

From source file:com.opensearchserver.extractor.parser.MapiMsg.java

License:Apache License

@Override
protected void parseContent(InputStream inputStream, String extension, String mimeType) throws Exception {
    MAPIMessage msg = new MAPIMessage(inputStream);
    msg.setReturnNullOnMissingChunk(true);

    ParserDocument document = getNewParserDocument();

    document.add(FROM, msg.getDisplayFrom());
    document.add(RECIPIENT_TO, msg.getDisplayTo());
    document.add(RECIPIENT_CC, msg.getDisplayCC());
    document.add(RECIPIENT_BCC, msg.getDisplayBCC());
    document.add(SUBJECT, msg.getSubject());
    document.add(HTML_CONTENT, msg.getHtmlBody());
    document.add(PLAIN_CONTENT, msg.getTextBody());
    document.add(MESSAGE_DATE, msg.getMessageDate());
    document.add(CONVERSATION_TOPIC, msg.getConversationTopic());

    if (StringUtils.isEmpty(msg.getHtmlBody()))
        document.add(LANG_DETECTION, languageDetection(document, PLAIN_CONTENT, 10000));
    else//from  w  w  w  . j av  a  2 s .c  om
        document.add(LANG_DETECTION, languageDetection(document, HTML_CONTENT, 10000));

    // TODO manage attachments
}

From source file:com.qwazr.library.poi.MapiMsgParser.java

License:Apache License

@Override
public void parseContent(final MultivaluedMap<String, String> parameters, final InputStream inputStream,
        final String extension, final String mimeType, final ParserResultBuilder resultBuilder)
        throws Exception {

    final MAPIMessage msg = new MAPIMessage(inputStream);
    msg.setReturnNullOnMissingChunk(true);

    final ParserFieldsBuilder metas = resultBuilder.metas();
    metas.set(MIME_TYPE, DEFAULT_MIMETYPES[0]);

    final ParserFieldsBuilder document = resultBuilder.newDocument();

    document.add(FROM, msg.getDisplayFrom());
    document.add(RECIPIENT_TO, msg.getDisplayTo());
    document.add(RECIPIENT_CC, msg.getDisplayCC());
    document.add(RECIPIENT_BCC, msg.getDisplayBCC());
    document.add(SUBJECT, msg.getSubject());
    document.add(HTML_CONTENT, msg.getHtmlBody());
    document.add(PLAIN_CONTENT, msg.getTextBody());
    document.add(MESSAGE_DATE, msg.getMessageDate());
    document.add(CONVERSATION_TOPIC, msg.getConversationTopic());

    if (StringUtils.isEmpty(msg.getHtmlBody()))
        document.add(LANG_DETECTION, languageDetection(document, PLAIN_CONTENT, 10000));
    else/*from   w  w  w . j  av  a  2  s .com*/
        document.add(LANG_DETECTION, languageDetection(document, HTML_CONTENT, 10000));

    // TODO manage attachments
}

From source file:org.silverpeas.core.mail.MsgMailExtractorIntegrationTest.java

License:Open Source License

/**
 * This unit test is support for MSG exploration solution testing.
 *
 * @throws Exception//from   w w w . j a  v a 2 s  .  com
 */
@Test
public void readMailWithAttachmentsMSG() throws Exception {
    MAPIMessage msg = new MAPIMessage(getDocumentFromName(FILENAME_MAIL_WITH_ATTACHMENTS).getPath());
    msg.setReturnNullOnMissingChunk(true);

    assertThat(msg.getDisplayFrom(), is("Nicolas Eysseric"));
    assertThat(msg.getRecipientDetailsChunks(), is(notNullValue()));
    assertThat(msg.getRecipientDetailsChunks().length, is(2));
    assertThat(msg.getRecipientDetailsChunks()[0].getRecipientName(), is("Aurore ADR. DELISSNYDER"));
    assertThat(msg.getRecipientDetailsChunks()[0].getRecipientEmailAddress(),
            is("Aurore.DELISSNYDER@hydrostadium.fr"));
    assertThat(msg.getRecipientDetailsChunks()[1].getRecipientName(), is("Ludovic BERTIN"));
    assertThat(msg.getRecipientDetailsChunks()[1].getRecipientEmailAddress(),
            is("ludovic.bertin@oosphere.com"));
    AttachmentChunks[] attachments = msg.getAttachmentFiles();
    assertThat(attachments, is(notNullValue()));
    assertThat(attachments.length, is(2));
    if (attachments != null && attachments.length > 0) {
        System.out.print("\n");
        for (AttachmentChunks attachmentChunks : attachments) {
            System.out.println(attachmentChunks.attachFileName.getValue());
        }
    } else {
        System.out.println("None.");
    }

    System.out.println("DATE : " + DateUtil.getOutputDateAndHour(getMessageDate(msg), "fr"));

    System.out.println("BODY : ");
    System.out.println(">>>");
    System.out.println(getMessageBody(msg));
    System.out.println("<<<");
}

From source file:org.silverpeas.core.mail.MsgMailExtractorIT.java

License:Open Source License

/**
 * This unit test is support for MSG exploration solution testing.
 *
 * @throws Exception//www .  j  a va  2 s.c  o m
 */
@Test
public void readMailWithAttachmentsMSG() throws Exception {
    MAPIMessage msg = new MAPIMessage(getDocumentFromName(FILENAME_MAIL_WITH_ATTACHMENTS).getPath());
    msg.setReturnNullOnMissingChunk(true);

    assertThat(msg.getDisplayFrom(), is("Nicolas Eysseric"));
    assertThat(msg.getRecipientDetailsChunks(), is(notNullValue()));
    assertThat(msg.getRecipientDetailsChunks().length, is(2));
    assertThat(msg.getRecipientDetailsChunks()[0].getRecipientName(), is("Aurore ADR. DELISSNYDER"));
    assertThat(msg.getRecipientDetailsChunks()[0].getRecipientEmailAddress(),
            is("Aurore.DELISSNYDER@hydrostadium.fr"));
    assertThat(msg.getRecipientDetailsChunks()[1].getRecipientName(), is("Ludovic BERTIN"));
    assertThat(msg.getRecipientDetailsChunks()[1].getRecipientEmailAddress(),
            is("ludovic.bertin@oosphere.com"));
    AttachmentChunks[] attachments = msg.getAttachmentFiles();
    assertThat(attachments, is(notNullValue()));
    assertThat(attachments.length, is(2));
    if (attachments != null && attachments.length > 0) {
        System.out.print("\n");
        for (AttachmentChunks attachmentChunks : attachments) {
            System.out.println(attachmentChunks.getAttachFileName().getValue());
        }
    } else {
        System.out.println("None.");
    }

    System.out.println("DATE : " + DateUtil.getOutputDateAndHour(getMessageDate(msg), "fr"));

    System.out.println("BODY : ");
    System.out.println(">>>");
    System.out.println(getMessageBody(msg));
    System.out.println("<<<");
}