Search in sources :

Example 1 with PSTException

use of com.pff.PSTException in project Xponents by OpenSextant.

the class OutlookPSTCrawler method collect.

@Override
public void collect() throws IOException, ConfigException {
    //
    // Logic:  Traverse PST file.
    //     it contains mail, contacts, tasks, notes, other stuff?
    //
    // Replicate folder structure discovered.
    // Mail and date-oriented items should be filed by date. For now, YYYY-MM-DD is fine.
    //
    // For mail messages, review DefaultMailCralwer:
    //  - for each message
    //    save message to disk;  create parent folder to contain message contents
    //    run text conversion individually on attachments.
    //
    //  - structure:
    //    ./Mail/
    //         2014-04-09/messageABC.eml
    //         2014-04-09/messageABC/attachment1.doc
    log.info("Traversing PST Folders for FILE={}", pst);
    try {
        PSTFile pstStore = new PSTFile(pst);
        processFolder(pstStore.getRootFolder());
    } catch (PSTException err) {
        throw new ConfigException("Failure with PST traversal", err);
    }
}
Also used : PSTFile(com.pff.PSTFile) PSTException(com.pff.PSTException) ConfigException(org.opensextant.ConfigException)

Example 2 with PSTException

use of com.pff.PSTException in project tika by apache.

the class OutlookPSTParser method parserMailItem.

private void parserMailItem(XHTMLContentHandler handler, PSTMessage pstMail, EmbeddedDocumentExtractor embeddedExtractor) throws SAXException, IOException {
    Metadata mailMetadata = new Metadata();
    mailMetadata.set(Metadata.RESOURCE_NAME_KEY, pstMail.getInternetMessageId());
    mailMetadata.set(Metadata.EMBEDDED_RELATIONSHIP_ID, pstMail.getInternetMessageId());
    mailMetadata.set(TikaCoreProperties.IDENTIFIER, pstMail.getInternetMessageId());
    mailMetadata.set(TikaCoreProperties.TITLE, pstMail.getSubject());
    mailMetadata.set(Metadata.MESSAGE_FROM, pstMail.getSenderName());
    mailMetadata.set(TikaCoreProperties.CREATOR, pstMail.getSenderName());
    mailMetadata.set(TikaCoreProperties.CREATED, pstMail.getCreationTime());
    mailMetadata.set(TikaCoreProperties.MODIFIED, pstMail.getLastModificationTime());
    mailMetadata.set(TikaCoreProperties.COMMENTS, pstMail.getComment());
    mailMetadata.set("descriptorNodeId", valueOf(pstMail.getDescriptorNodeId()));
    mailMetadata.set("senderEmailAddress", pstMail.getSenderEmailAddress());
    mailMetadata.set("recipients", pstMail.getRecipientsString());
    mailMetadata.set("displayTo", pstMail.getDisplayTo());
    mailMetadata.set("displayCC", pstMail.getDisplayCC());
    mailMetadata.set("displayBCC", pstMail.getDisplayBCC());
    mailMetadata.set("importance", valueOf(pstMail.getImportance()));
    mailMetadata.set("priority", valueOf(pstMail.getPriority()));
    mailMetadata.set("flagged", valueOf(pstMail.isFlagged()));
    mailMetadata.set(Office.MAPI_MESSAGE_CLASS, OutlookExtractor.getMessageClass(pstMail.getMessageClass()));
    mailMetadata.set(Message.MESSAGE_FROM_EMAIL, pstMail.getSenderEmailAddress());
    mailMetadata.set(Office.MAPI_FROM_REPRESENTING_EMAIL, pstMail.getSentRepresentingEmailAddress());
    mailMetadata.set(Message.MESSAGE_FROM_NAME, pstMail.getSenderName());
    mailMetadata.set(Office.MAPI_FROM_REPRESENTING_NAME, pstMail.getSentRepresentingName());
    //add recipient details
    try {
        for (int i = 0; i < pstMail.getNumberOfRecipients(); i++) {
            PSTRecipient recipient = pstMail.getRecipient(i);
            switch(OutlookExtractor.RECIPIENT_TYPE.getTypeFromVal(recipient.getRecipientType())) {
                case TO:
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_TO_DISPLAY_NAME, recipient.getDisplayName(), mailMetadata);
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_TO_EMAIL, recipient.getEmailAddress(), mailMetadata);
                    break;
                case CC:
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_CC_DISPLAY_NAME, recipient.getDisplayName(), mailMetadata);
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_CC_EMAIL, recipient.getEmailAddress(), mailMetadata);
                    break;
                case BCC:
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_BCC_DISPLAY_NAME, recipient.getDisplayName(), mailMetadata);
                    OutlookExtractor.addEvenIfNull(Message.MESSAGE_BCC_EMAIL, recipient.getEmailAddress(), mailMetadata);
                    break;
                default:
                    //do we want to handle unspecified or unknown?
                    break;
            }
        }
    } catch (PSTException e) {
    //swallow
    }
    byte[] mailContent = pstMail.getBody().getBytes(UTF_8);
    embeddedExtractor.parseEmbedded(new ByteArrayInputStream(mailContent), handler, mailMetadata, true);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Metadata(org.apache.tika.metadata.Metadata) PSTException(com.pff.PSTException) PSTRecipient(com.pff.PSTRecipient)

Aggregations

PSTException (com.pff.PSTException)2 PSTFile (com.pff.PSTFile)1 PSTRecipient (com.pff.PSTRecipient)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Metadata (org.apache.tika.metadata.Metadata)1 ConfigException (org.opensextant.ConfigException)1