Search in sources :

Example 1 with OleBlob

use of com.healthmarketscience.jackcess.util.OleBlob in project tika by apache.

the class JackcessExtractor method handleOLE.

private void handleOLE(Row row, String cName, XHTMLContentHandler xhtml) throws IOException, SAXException, TikaException {
    OleBlob blob = row.getBlob(cName);
    //lifted shamelessly from Jackcess's OleBlobTest
    if (blob == null)
        return;
    OleBlob.Content content = blob.getContent();
    if (content == null)
        return;
    switch(content.getType()) {
        case LINK:
            xhtml.characters(((OleBlob.LinkContent) content).getLinkPath());
            break;
        case SIMPLE_PACKAGE:
            OleBlob.SimplePackageContent spc = (OleBlob.SimplePackageContent) content;
            //TODO: find test file that has this kind of attachment
            //and see if getFilePath or getLocalFilePath is meaningful
            //for TikaCoreProperties.ORIGINAL_RESOURCE_NAME
            TikaInputStream tis = null;
            try {
                tis = TikaInputStream.get(spc.getStream());
            } catch (IOException e) {
                EmbeddedDocumentUtil.recordEmbeddedStreamException(e, parentMetadata);
                break;
            }
            if (tis != null) {
                try {
                    handleEmbeddedResource(tis, //filename
                    spc.getFileName(), //relationshipId
                    null, //mediatype
                    spc.getTypeName(), xhtml, false);
                } finally {
                    IOUtils.closeQuietly(tis);
                }
            }
            break;
        case OTHER:
            OleBlob.OtherContent oc = (OleBlob.OtherContent) content;
            TikaInputStream ocStream = null;
            try {
                ocStream = TikaInputStream.get(oc.getStream());
            } catch (IOException e) {
                EmbeddedDocumentUtil.recordException(e, parentMetadata);
            }
            try {
                handleEmbeddedResource(ocStream, //filename
                null, //relationshipId
                null, //mediatype
                oc.getTypeName(), xhtml, false);
            } finally {
                IOUtils.closeQuietly(ocStream);
            }
            break;
        case COMPOUND_STORAGE:
            OleBlob.CompoundContent cc = (OleBlob.CompoundContent) content;
            handleCompoundContent(cc, xhtml);
            break;
    }
}
Also used : OleBlob(com.healthmarketscience.jackcess.util.OleBlob) TikaInputStream(org.apache.tika.io.TikaInputStream) IOException(java.io.IOException)

Aggregations

OleBlob (com.healthmarketscience.jackcess.util.OleBlob)1 IOException (java.io.IOException)1 TikaInputStream (org.apache.tika.io.TikaInputStream)1