tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1306411 - /tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java
Date Wed, 28 Mar 2012 15:26:10 GMT
Author: nick
Date: Wed Mar 28 15:26:10 2012
New Revision: 1306411

URL: http://svn.apache.org/viewvc?rev=1306411&view=rev
Log:
TIKA-886 If we open the OPCPackage from a File on a TikaInputStream, have it tracked (+closed)
by the TikaInputStream the same way that ZipContainerDetector opened ones are

Modified:
    tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java

Modified: tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java?rev=1306411&r1=1306410&r2=1306411&view=diff
==============================================================================
--- tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java
(original)
+++ tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/microsoft/ooxml/OOXMLExtractorFactory.java
Wed Mar 28 15:26:10 2012
@@ -26,6 +26,7 @@ import org.apache.poi.extractor.Extracto
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
 import org.apache.poi.xslf.usermodel.XMLSlideShow;
 import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor;
@@ -61,12 +62,13 @@ public class OOXMLExtractorFactory {
             OOXMLExtractor extractor;
             OPCPackage pkg;
 
-            // Open the OPCPackage for the file
+            // Locate or Open the OPCPackage for the file
             TikaInputStream tis = TikaInputStream.cast(stream);
             if (tis != null && tis.getOpenContainer() instanceof OPCPackage) {
                 pkg = (OPCPackage) tis.getOpenContainer();
             } else if (tis != null && tis.hasFile()) {
-                pkg = OPCPackage.open( tis.getFile().getPath() );
+                pkg = OPCPackage.open( tis.getFile().getPath(), PackageAccess.READ );
+                tis.setOpenContainer(pkg);
             } else {
                 InputStream shield = new CloseShieldInputStream(stream);
                 pkg = OPCPackage.open(shield); 



Mime
View raw message