You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2016/04/21 02:55:06 UTC

[1/7] tika git commit: Skip PooledTimeSeriesParser if it's not available

Repository: tika
Updated Branches:
  refs/heads/master 483c16260 -> 8487fa73d


Skip PooledTimeSeriesParser if it's not available


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/2e0c9bdc
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/2e0c9bdc
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/2e0c9bdc

Branch: refs/heads/master
Commit: 2e0c9bdc83af8659c01848886bdfc80e055a5f2a
Parents: 3d49131
Author: Aditya Dhulipala <ad...@usc.edu>
Authored: Mon Apr 18 22:34:40 2016 -0400
Committer: Aditya Dhulipala <ad...@usc.edu>
Committed: Mon Apr 18 22:34:40 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java   | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/2e0c9bdc/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
----------------------------------------------------------------------
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
index e601747..deedfeb 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
@@ -85,6 +85,9 @@ public class PooledTimeSeriesParser extends AbstractParser {
    */
   @Override
   public Set<MediaType> getSupportedTypes(ParseContext context) {
+    if (!isAvailable()) {
+      return Collections.emptySet();
+    }
     return SUPPORTED_TYPES;
   }
 


[3/7] tika git commit: Added imports

Posted by ta...@apache.org.
Added imports


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/9f3a32a1
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/9f3a32a1
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/9f3a32a1

Branch: refs/heads/master
Commit: 9f3a32a171d2f45b057bb1f7bf8be5c28daa45d9
Parents: 1e2bd89
Author: Aditya Dhulipala <ad...@usc.edu>
Authored: Wed Apr 20 19:54:56 2016 -0400
Committer: Aditya Dhulipala <ad...@usc.edu>
Committed: Wed Apr 20 19:54:56 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/9f3a32a1/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
----------------------------------------------------------------------
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
index 81466c4..28c1104 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
@@ -22,9 +22,13 @@ import org.apache.tika.io.TemporaryResources;
 import org.apache.tika.io.TikaInputStream;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.mime.MediaType;
+import org.apache.tika.mime.MediaTypeRegistry;
 import org.apache.tika.parser.AbstractParser;
+import org.apache.tika.parser.CompositeParser;
 import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
 import org.apache.tika.parser.external.ExternalParser;
+import org.apache.tika.parser.mp4.MP4Parser;
 import org.apache.tika.sax.XHTMLContentHandler;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -46,6 +50,7 @@ import org.xml.sax.helpers.AttributesImpl;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.List;
 import java.util.HashSet;
 import java.util.Set;
 


[6/7] tika git commit: TIKA-1844 clean up indentation, clean up streams in case of exceptions, make isAvailable check happen only once. This closes #107.

Posted by ta...@apache.org.
TIKA-1844 clean up indentation, clean up streams in case of exceptions, make isAvailable check happen only once. This closes #107.


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/2ec36ff4
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/2ec36ff4
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/2ec36ff4

Branch: refs/heads/master
Commit: 2ec36ff4b817d1378b75f0654648a260c3d5928f
Parents: 72d76f8
Author: tballison <ta...@mitre.org>
Authored: Wed Apr 20 20:50:16 2016 -0400
Committer: tballison <ta...@mitre.org>
Committed: Wed Apr 20 20:50:16 2016 -0400

----------------------------------------------------------------------
 .../tika/parser/pot/PooledTimeSeriesParser.java | 341 +++++++++----------
 1 file changed, 163 insertions(+), 178 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/2ec36ff4/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
----------------------------------------------------------------------
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
index 3b9b854..eb81587 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
@@ -57,208 +57,193 @@ import org.xml.sax.helpers.AttributesImpl;
 
 /**
  * Uses the Pooled Time Series algorithm + command line tool, to
- *  generate a numeric representation of the video suitable for
- *  similarity searches.
+ * generate a numeric representation of the video suitable for
+ * similarity searches.
  * <p>See https://wiki.apache.org/tika/PooledTimeSeriesParser for
- *  more details and setup instructions.
+ * more details and setup instructions.
  */
 public class PooledTimeSeriesParser extends AbstractParser {
 
-  private static final long serialVersionUID = -2855917932512164988L;
-
-  static final boolean isAvailable = ExternalParser.check(
-          new String[] { "pooled-time-series", "--help" }, -1);
-
-  private static final Set<MediaType> SUPPORTED_TYPES =
-          isAvailable ? Collections.unmodifiableSet(
-                  new HashSet<>(Arrays.asList(new MediaType[]{
-                                  MediaType.video("avi"), MediaType.video("mp4")
-                          }))) : Collections.EMPTY_SET;;
-                          // TODO: Add all supported video types
-
-  private static final Logger LOG = Logger.getLogger(PooledTimeSeriesParser.class.getName());
-
-  public boolean isAvailable() {
-    return isAvailable;
-  }
-
-  /**
-   * Returns the set of media types supported by this parser when used with the
-   * given parse context.
-   *
-   * @param context
-   *          parse context
-   * @return immutable set of media types
-   * @since Apache Tika 0.7
-   */
-  @Override
-  public Set<MediaType> getSupportedTypes(ParseContext context) {
-    return SUPPORTED_TYPES;
-  }
-
-  /**
-   * Parses a document stream into a sequence of XHTML SAX events. Fills in
-   * related document metadata in the given metadata object.
-   * <p>
-   * The given document stream is consumed but not closed by this method. The
-   * responsibility to close the stream remains on the caller.
-   * <p>
-   * Information about the parsing context can be passed in the context
-   * parameter. See the parser implementations for the kinds of context
-   * information they expect.
-   *
-   * @param stream
-   *          the document stream (input)
-   * @param handler
-   *          handler for the XHTML SAX events (output)
-   * @param metadata
-   *          document metadata (input and output)
-   * @param context
-   *          parse context
-   * @throws IOException
-   *           if the document stream could not be read
-   * @throws SAXException
-   *           if the SAX events could not be processed
-   * @throws TikaException
-   *           if the document could not be parsed
-   * @since Apache Tika 0.5
-   */
-  @Override
-  public void parse(InputStream stream, ContentHandler handler,
-      Metadata metadata, ParseContext context) throws IOException,
-      SAXException, TikaException {
-
-    if (!isAvailable()) {
-      LOG.warning(
-          "PooledTimeSeries not installed!");
-      return;
+    private static final long serialVersionUID = -2855917932512164988L;
+
+    static final boolean isAvailable = ExternalParser.check(
+            new String[]{"pooled-time-series", "--help"}, -1);
+
+    private static final Set<MediaType> SUPPORTED_TYPES =
+            isAvailable ? Collections.unmodifiableSet(
+                    new HashSet<>(Arrays.asList(new MediaType[]{
+                            MediaType.video("avi"), MediaType.video("mp4")
+                    }))) : Collections.EMPTY_SET;
+    ;
+    // TODO: Add all supported video types
+
+    private static final Logger LOG = Logger.getLogger(PooledTimeSeriesParser.class.getName());
+
+    /**
+     * Returns the set of media types supported by this parser when used with the
+     * given parse context.
+     *
+     * @param context parse context
+     * @return immutable set of media types
+     * @since Apache Tika 0.7
+     */
+    @Override
+    public Set<MediaType> getSupportedTypes(ParseContext context) {
+        return SUPPORTED_TYPES;
     }
 
-    XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-
-    TemporaryResources tmp = new TemporaryResources();
-    File output = null;
-    try {
-      TikaInputStream tikaStream = TikaInputStream.get(stream, tmp);
-      File input = tikaStream.getFile();
-      String cmdOutput = computePoT(input);
-      FileInputStream ofStream = new FileInputStream(new File(
-          input.getAbsoluteFile() + ".of.txt"));
-      FileInputStream ogStream = new FileInputStream(new File(
-          input.getAbsoluteFile() + ".hog.txt"));
-      extractHeaderOutput(ofStream, metadata, "of");
-      extractHeaderOutput(ogStream, metadata, "og");
-      xhtml.startDocument();
-      doExtract(ofStream, xhtml, "Histogram of Optical Flows (HOF)",
-          metadata.get("of_frames"), metadata.get("of_vecSize"));
-      doExtract(ogStream, xhtml, "Histogram of Oriented Gradients (HOG)",
-          metadata.get("og_frames"), metadata.get("og_vecSize"));
-      xhtml.endDocument();
-
-      // Temporary workaround for TIKA-1445 - until we can specify
-      //  composite parsers with strategies (eg Composite, Try In Turn),
-      //  always send the image onwards to the regular parser to have
-      //  the metadata for them extracted as well
-      _TMP_VIDEO_METADATA_PARSER.parse(tikaStream, handler, metadata, context);
+    /**
+     * Parses a document stream into a sequence of XHTML SAX events. Fills in
+     * related document metadata in the given metadata object.
+     * <p>
+     * The given document stream is consumed but not closed by this method. The
+     * responsibility to close the stream remains on the caller.
+     * <p>
+     * Information about the parsing context can be passed in the context
+     * parameter. See the parser implementations for the kinds of context
+     * information they expect.
+     *
+     * @param stream   the document stream (input)
+     * @param handler  handler for the XHTML SAX events (output)
+     * @param metadata document metadata (input and output)
+     * @param context  parse context
+     * @throws IOException   if the document stream could not be read
+     * @throws SAXException  if the SAX events could not be processed
+     * @throws TikaException if the document could not be parsed
+     * @since Apache Tika 0.5
+     */
+    @Override
+    public void parse(InputStream stream, ContentHandler handler,
+                      Metadata metadata, ParseContext context) throws IOException,
+            SAXException, TikaException {
+
+        if (!isAvailable) {
+            LOG.warning(
+                    "PooledTimeSeries not installed!");
+            return;
+        }
 
-    } finally {
-      tmp.dispose();
-      if (output != null) {
-        output.delete();
-      }
+        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+
+        TemporaryResources tmp = new TemporaryResources();
+        try {
+            TikaInputStream tikaStream = TikaInputStream.get(stream, tmp);
+            File input = tikaStream.getFile();
+            String cmdOutput = computePoT(input);
+            try(InputStream ofStream = new FileInputStream(new File(
+                    input.getAbsoluteFile() + ".of.txt"))) {
+                try(InputStream ogStream = new FileInputStream(new File(
+                        input.getAbsoluteFile() + ".hog.txt"))) {
+
+                    extractHeaderOutput(ofStream, metadata, "of");
+                    extractHeaderOutput(ogStream, metadata, "og");
+                    xhtml.startDocument();
+                    doExtract(ofStream, xhtml, "Histogram of Optical Flows (HOF)",
+                            metadata.get("of_frames"), metadata.get("of_vecSize"));
+                    doExtract(ogStream, xhtml, "Histogram of Oriented Gradients (HOG)",
+                            metadata.get("og_frames"), metadata.get("og_vecSize"));
+                    xhtml.endDocument();
+                }
+            }
+            // Temporary workaround for TIKA-1445 - until we can specify
+            //  composite parsers with strategies (eg Composite, Try In Turn),
+            //  always send the image onwards to the regular parser to have
+            //  the metadata for them extracted as well
+            _TMP_VIDEO_METADATA_PARSER.parse(tikaStream, handler, metadata, context);
+
+        } finally {
+            tmp.dispose();
+        }
     }
-  }
 
     // TIKA-1445 workaround parser
     private static Parser _TMP_VIDEO_METADATA_PARSER = new CompositeVideoParser();
+
     private static class CompositeVideoParser extends CompositeParser {
         private static final long serialVersionUID = -2398203965206381382L;
         private static List<Parser> videoParsers = Arrays.asList(new Parser[]{
-          new MP4Parser()
+                new MP4Parser()
         });
+
         CompositeVideoParser() {
             super(new MediaTypeRegistry(), videoParsers);
         }
     }
-  private String computePoT(File input)
-      throws IOException, TikaException {
-
-    CommandLine cmdLine = new CommandLine("pooled-time-series");
-    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-    cmdLine.addArgument("-f");
-    cmdLine.addArgument(input.getAbsolutePath());
-    LOG.fine("Executing: " + cmdLine);
-    DefaultExecutor exec = new DefaultExecutor();
-    exec.setExitValue(0);
-    ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
-    exec.setWatchdog(watchdog);
-    PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
-    exec.setStreamHandler(streamHandler);
-    int exitValue = exec
-        .execute(cmdLine, EnvironmentUtils.getProcEnvironment());
-    return outputStream.toString("UTF-8");
 
-  }
+    private String computePoT(File input)
+            throws IOException, TikaException {
+
+        CommandLine cmdLine = new CommandLine("pooled-time-series");
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        cmdLine.addArgument("-f");
+        cmdLine.addArgument(input.getAbsolutePath());
+        LOG.fine("Executing: " + cmdLine);
+        DefaultExecutor exec = new DefaultExecutor();
+        exec.setExitValue(0);
+        ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
+        exec.setWatchdog(watchdog);
+        PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
+        exec.setStreamHandler(streamHandler);
+        int exitValue = exec
+                .execute(cmdLine, EnvironmentUtils.getProcEnvironment());
+        return outputStream.toString("UTF-8");
 
-  /**
-   * Reads the contents of the given stream and write it to the given XHTML
-   * content handler. The stream is closed once fully processed.
-   *
-   * @param stream
-   *          Stream where is the result of ocr
-   * @param xhtml
-   *          XHTML content handler
-   * @param tableTitle
-   *          The name of the matrix/table to display.
-   * @param frames
-   *          Number of frames read from the video.
-   * @param vecSize
-   *          Size of the OF or HOG vector.
-   * @throws SAXException
-   *           if the XHTML SAX events could not be handled
-   * @throws IOException
-   *           if an input error occurred
-   */
-  private void doExtract(InputStream stream, XHTMLContentHandler xhtml,
-      String tableTitle, String frames, String vecSize) throws SAXException,
-      IOException {
-    BufferedReader reader = new BufferedReader(new InputStreamReader(stream,
-        UTF_8));
-    String line = null;
-    AttributesImpl attributes = new AttributesImpl();
-    attributes.addAttribute("", "", "rows", "CDATA", frames);
-    attributes.addAttribute("", "", "cols", "CDATA", vecSize);
-
-    xhtml.startElement("h3");
-    xhtml.characters(tableTitle);
-    xhtml.endElement("h3");
-    xhtml.startElement("table", attributes);
-    while ((line = reader.readLine()) != null) {
-      xhtml.startElement("tr");
-      for (String val : line.split(" ")) {
-        xhtml.startElement("td");
-        xhtml.characters(val);
-        xhtml.endElement("td");
-      }
-      xhtml.endElement("tr");
     }
-    xhtml.endElement("table");
-  }
 
-  private void extractHeaderOutput(InputStream stream, Metadata metadata,
-      String prefix) throws IOException {
-    BufferedReader reader = new BufferedReader(new InputStreamReader(stream,
-        UTF_8));
-    String line = reader.readLine();
-    String[] firstLine = line.split(" ");
-    String frames = firstLine[0];
-    String vecSize = firstLine[1];
+    /**
+     * Reads the contents of the given stream and write it to the given XHTML
+     * content handler. The stream is closed once fully processed.
+     *
+     * @param stream     Stream where is the result of ocr
+     * @param xhtml      XHTML content handler
+     * @param tableTitle The name of the matrix/table to display.
+     * @param frames     Number of frames read from the video.
+     * @param vecSize    Size of the OF or HOG vector.
+     * @throws SAXException if the XHTML SAX events could not be handled
+     * @throws IOException  if an input error occurred
+     */
+    private void doExtract(InputStream stream, XHTMLContentHandler xhtml,
+                           String tableTitle, String frames, String vecSize) throws SAXException,
+            IOException {
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream,
+                UTF_8))) {
+            String line = null;
+            AttributesImpl attributes = new AttributesImpl();
+            attributes.addAttribute("", "", "rows", "CDATA", frames);
+            attributes.addAttribute("", "", "cols", "CDATA", vecSize);
+
+            xhtml.startElement("h3");
+            xhtml.characters(tableTitle);
+            xhtml.endElement("h3");
+            xhtml.startElement("table", attributes);
+            while ((line = reader.readLine()) != null) {
+                xhtml.startElement("tr");
+                for (String val : line.split(" ")) {
+                    xhtml.startElement("td");
+                    xhtml.characters(val);
+                    xhtml.endElement("td");
+                }
+                xhtml.endElement("tr");
+            }
+            xhtml.endElement("table");
+        }
+    }
 
-    if (prefix == null) {
-      prefix = "";
+    private void extractHeaderOutput(InputStream stream, Metadata metadata,
+                                     String prefix) throws IOException {
+        try(BufferedReader reader = new BufferedReader(new InputStreamReader(stream,
+                UTF_8))) {
+            String line = reader.readLine();
+            String[] firstLine = line.split(" ");
+            String frames = firstLine[0];
+            String vecSize = firstLine[1];
+
+            if (prefix == null) {
+                prefix = "";
+            }
+            metadata.add(prefix + "_frames", frames);
+            metadata.add(prefix + "_vecSize", vecSize);
+        }
     }
-    metadata.add(prefix + "_frames", frames);
-    metadata.add(prefix + "_vecSize", vecSize);
-  }
 
 }


[4/7] tika git commit: Merge branch 'TIKA-1844' of https://github.com/cafed00d4j/tika

Posted by ta...@apache.org.
Merge branch 'TIKA-1844' of https://github.com/cafed00d4j/tika


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/443ecd35
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/443ecd35
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/443ecd35

Branch: refs/heads/master
Commit: 443ecd352deae04f650b2e3dddb534bb19734806
Parents: 483c162 9f3a32a
Author: tballison <ta...@mitre.org>
Authored: Wed Apr 20 20:33:36 2016 -0400
Committer: tballison <ta...@mitre.org>
Committed: Wed Apr 20 20:33:36 2016 -0400

----------------------------------------------------------------------
 .../tika/parser/pot/PooledTimeSeriesParser.java | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------



[2/7] tika git commit: Added CompositeParser workaround

Posted by ta...@apache.org.
Added CompositeParser workaround

Added a workaround to include collate metadata
from multiple parsers (such as MP4Parser)


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/1e2bd89e
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/1e2bd89e
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/1e2bd89e

Branch: refs/heads/master
Commit: 1e2bd89e73888ed293d820d2bf33fb56a5402ce7
Parents: 2e0c9bd
Author: Aditya Dhulipala <ad...@usc.edu>
Authored: Mon Apr 18 22:46:28 2016 -0400
Committer: Aditya Dhulipala <ad...@usc.edu>
Committed: Mon Apr 18 22:46:28 2016 -0400

----------------------------------------------------------------------
 .../tika/parser/pot/PooledTimeSeriesParser.java    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/1e2bd89e/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
----------------------------------------------------------------------
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
index deedfeb..81466c4 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
@@ -150,6 +150,12 @@ public class PooledTimeSeriesParser extends AbstractParser {
           metadata.get("og_frames"), metadata.get("og_vecSize"));
       xhtml.endDocument();
 
+      // Temporary workaround for TIKA-1445 - until we can specify
+      //  composite parsers with strategies (eg Composite, Try In Turn),
+      //  always send the image onwards to the regular parser to have
+      //  the metadata for them extracted as well
+      _TMP_VIDEO_METADATA_PARSER.parse(tikaStream, handler, metadata, context);
+
     } finally {
       tmp.dispose();
       if (output != null) {
@@ -158,6 +164,17 @@ public class PooledTimeSeriesParser extends AbstractParser {
     }
   }
 
+    // TIKA-1445 workaround parser
+    private static Parser _TMP_VIDEO_METADATA_PARSER = new CompositeVideoParser();
+    private static class CompositeVideoParser extends CompositeParser {
+        private static final long serialVersionUID = -2398203965206381382L;
+        private static List<Parser> videoParsers = Arrays.asList(new Parser[]{
+          new MP4Parser()
+        });
+        CompositeVideoParser() {
+            super(new MediaTypeRegistry(), videoParsers);
+        }
+    }
   private String computePoT(File input)
       throws IOException, TikaException {
 


[5/7] tika git commit: TIKA-1844 pass through POT if it isn't available -- via Aditya Dhulipala. This closes #107.

Posted by ta...@apache.org.
TIKA-1844 pass through POT if it isn't available -- via Aditya Dhulipala. This closes #107.


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/72d76f88
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/72d76f88
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/72d76f88

Branch: refs/heads/master
Commit: 72d76f884e3997ecee322e8327f51053d0a34bad
Parents: 443ecd3
Author: tballison <ta...@mitre.org>
Authored: Wed Apr 20 20:41:08 2016 -0400
Committer: tballison <ta...@mitre.org>
Committed: Wed Apr 20 20:41:08 2016 -0400

----------------------------------------------------------------------
 .../tika/parser/pot/PooledTimeSeriesParser.java | 64 ++++++++++----------
 1 file changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/72d76f88/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
----------------------------------------------------------------------
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
index 28c1104..3b9b854 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java
@@ -17,6 +17,27 @@
 
 package org.apache.tika.parser.pot;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.exec.environment.EnvironmentUtils;
 import org.apache.tika.exception.TikaException;
 import org.apache.tika.io.TemporaryResources;
 import org.apache.tika.io.TikaInputStream;
@@ -32,30 +53,8 @@ import org.apache.tika.parser.mp4.MP4Parser;
 import org.apache.tika.sax.XHTMLContentHandler;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.BufferedReader;
-import java.util.logging.Logger;
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.exec.environment.EnvironmentUtils;
 import org.xml.sax.helpers.AttributesImpl;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.HashSet;
-import java.util.Set;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
 /**
  * Uses the Pooled Time Series algorithm + command line tool, to
  *  generate a numeric representation of the video suitable for
@@ -66,17 +65,21 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 public class PooledTimeSeriesParser extends AbstractParser {
 
   private static final long serialVersionUID = -2855917932512164988L;
-  private static final Set<MediaType> SUPPORTED_TYPES = Collections
-      .unmodifiableSet(new HashSet<MediaType>(Arrays.asList(new MediaType[] {
-          MediaType.video("avi"), MediaType.video("mp4")
-      // TODO: Add all supported video types
-          })));
+
+  static final boolean isAvailable = ExternalParser.check(
+          new String[] { "pooled-time-series", "--help" }, -1);
+
+  private static final Set<MediaType> SUPPORTED_TYPES =
+          isAvailable ? Collections.unmodifiableSet(
+                  new HashSet<>(Arrays.asList(new MediaType[]{
+                                  MediaType.video("avi"), MediaType.video("mp4")
+                          }))) : Collections.EMPTY_SET;;
+                          // TODO: Add all supported video types
 
   private static final Logger LOG = Logger.getLogger(PooledTimeSeriesParser.class.getName());
 
   public boolean isAvailable() {
-    return ExternalParser.check(
-        new String[] { "pooled-time-series", "--help" }, -1);
+    return isAvailable;
   }
 
   /**
@@ -90,9 +93,6 @@ public class PooledTimeSeriesParser extends AbstractParser {
    */
   @Override
   public Set<MediaType> getSupportedTypes(ParseContext context) {
-    if (!isAvailable()) {
-      return Collections.emptySet();
-    }
     return SUPPORTED_TYPES;
   }
 


[7/7] tika git commit: TIKA-1844 clean up indentation, clean up streams in case of exceptions, make isAvailable check happen only once. This closes #107.

Posted by ta...@apache.org.
TIKA-1844 clean up indentation, clean up streams in case of exceptions, make isAvailable check happen only once. This closes #107.


Project: http://git-wip-us.apache.org/repos/asf/tika/repo
Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/8487fa73
Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/8487fa73
Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/8487fa73

Branch: refs/heads/master
Commit: 8487fa73d0110fdead3475b2980425b1ef6662fe
Parents: 2ec36ff
Author: tballison <ta...@mitre.org>
Authored: Wed Apr 20 20:53:23 2016 -0400
Committer: tballison <ta...@mitre.org>
Committed: Wed Apr 20 20:53:23 2016 -0400

----------------------------------------------------------------------
 CHANGES.txt | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tika/blob/8487fa73/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f8e830c..67014f4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,9 @@
 Release 1.13 - ???
 
+  * Extract metadata from MP4 videos whether or not the
+    PooledTimeSeries parser is available via Aditya Dhulipala
+    (TIKA-1844).
+
   * Fix NPE when trying to get embedded image identifier in
     WordParser (TIKA-1956).