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();
}
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);
}
}
Aggregations