Search in sources :

Example 21 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project poi by apache.

the class TestHPSFBugs method test56138.

/**
    * CodePage Strings can be zero length
    */
@Test
public void test56138() throws IOException, NoPropertySetStreamException {
    InputStream is = _samples.openResourceAsStream("TestZeroLengthCodePage.mpp");
    NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
    is.close();
    SummaryInformation si = (SummaryInformation) PropertySetFactory.create(fs.getRoot(), SummaryInformation.DEFAULT_STREAM_NAME);
    DocumentSummaryInformation dsi = (DocumentSummaryInformation) PropertySetFactory.create(fs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME);
    // Test
    assertEquals("MSProject", si.getApplicationName());
    assertEquals("project1", si.getTitle());
    assertEquals("Jon Iles", si.getAuthor());
    assertEquals("", dsi.getCompany());
    assertEquals(2, dsi.getSectionCount());
    fs.close();
}
Also used : NPOIFSFileSystem(org.apache.poi.poifs.filesystem.NPOIFSFileSystem) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) Test(org.junit.Test)

Example 22 with DocumentSummaryInformation

use of org.apache.poi.hpsf.DocumentSummaryInformation in project tika by apache.

the class SummaryExtractor method parseSummaryEntryIfExists.

private void parseSummaryEntryIfExists(DirectoryNode root, String entryName) throws IOException, TikaException {
    try {
        DocumentEntry entry = (DocumentEntry) root.getEntry(entryName);
        PropertySet properties = new PropertySet(new DocumentInputStream(entry));
        if (properties.isSummaryInformation()) {
            parse(new SummaryInformation(properties));
        }
        if (properties.isDocumentSummaryInformation()) {
            parse(new DocumentSummaryInformation(properties));
        }
    } catch (FileNotFoundException e) {
    // entry does not exist, just skip it
    } catch (NoPropertySetStreamException e) {
    // no property stream, just skip it
    } catch (UnexpectedPropertySetTypeException e) {
        throw new TikaException("Unexpected HPSF document", e);
    } catch (MarkUnsupportedException e) {
        throw new TikaException("Invalid DocumentInputStream", e);
    } catch (Exception e) {
        LOG.warn("Ignoring unexpected exception while parsing summary entry {}", entryName, e);
    }
}
Also used : TikaException(org.apache.tika.exception.TikaException) SummaryInformation(org.apache.poi.hpsf.SummaryInformation) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) DocumentEntry(org.apache.poi.poifs.filesystem.DocumentEntry) FileNotFoundException(java.io.FileNotFoundException) PropertySet(org.apache.poi.hpsf.PropertySet) DocumentSummaryInformation(org.apache.poi.hpsf.DocumentSummaryInformation) NoPropertySetStreamException(org.apache.poi.hpsf.NoPropertySetStreamException) DocumentInputStream(org.apache.poi.poifs.filesystem.DocumentInputStream) UnexpectedPropertySetTypeException(org.apache.poi.hpsf.UnexpectedPropertySetTypeException) MarkUnsupportedException(org.apache.poi.hpsf.MarkUnsupportedException) NoPropertySetStreamException(org.apache.poi.hpsf.NoPropertySetStreamException) UnexpectedPropertySetTypeException(org.apache.poi.hpsf.UnexpectedPropertySetTypeException) TikaException(org.apache.tika.exception.TikaException) MarkUnsupportedException(org.apache.poi.hpsf.MarkUnsupportedException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

DocumentSummaryInformation (org.apache.poi.hpsf.DocumentSummaryInformation)22 SummaryInformation (org.apache.poi.hpsf.SummaryInformation)15 Test (org.junit.Test)10 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)9 ByteArrayInputStream (java.io.ByteArrayInputStream)6 CustomProperties (org.apache.poi.hpsf.CustomProperties)6 PropertySet (org.apache.poi.hpsf.PropertySet)5 InputStream (java.io.InputStream)4 DirectoryEntry (org.apache.poi.poifs.filesystem.DirectoryEntry)4 FileOutputStream (java.io.FileOutputStream)3 IOException (java.io.IOException)3 DocumentInputStream (org.apache.poi.poifs.filesystem.DocumentInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 OutputStream (java.io.OutputStream)2 HPSFPropertiesOnlyDocument (org.apache.poi.hpsf.HPSFPropertiesOnlyDocument)2 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1