logger.warn("Unexpected MimeTypeException", e);
}
}
if ("application/vnd.openxmlformats-officedocument.oleObject".equals(contentType)) {
POIFSFileSystem poifs = new POIFSFileSystem(new ByteArrayInputStream(data));
OfficeParser.POIFSDocumentType type = OfficeParser.POIFSDocumentType.detectType(poifs);
if (type == OfficeParser.POIFSDocumentType.OLE10_NATIVE) {
try {
Ole10Native ole = Ole10Native.createFromEmbeddedOleObject(poifs);
if (ole.getDataSize()>0) {
String label = ole.getLabel();
if (label.startsWith("ole-")) {
label = Integer.toString(count.intValue()) + '-' + label;
}
name = label;
data = ole.getDataBuffer();
}
} catch (Ole10NativeException ex) {
logger.warn("Skipping invalid part", ex);
}
} else {
name += '.' + type.getExtension();
}
}
final String finalName = name;
if (data.length > 0) {
zout.put(finalName, data);
count.increment();
} else {
if (inputStream instanceof TikaInputStream) {
TikaInputStream tin = (TikaInputStream) inputStream;
if (tin.getOpenContainer()!=null && tin.getOpenContainer() instanceof DirectoryEntry) {
POIFSFileSystem fs = new POIFSFileSystem();
copy((DirectoryEntry) tin.getOpenContainer(), fs.getRoot());
ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
fs.writeFilesystem(bos2);
bos2.close();
zout.put(finalName, bos2.toByteArray());
}
}