@Test public void testParseFITS() { String fitsFilename = "/test-documents/WFPC2u5780205r_c0fx.fits"; assumeTrue(canRun()); String[] fitsCommand = {"gdalinfo", TestGDALParser.class.getResource(fitsFilename).getPath()}; assumeTrue(ExternalParser.check(fitsCommand, 1)); String expectedAllgMin = "-7.319537E1"; String expectedAtodcorr = "COMPLETE"; String expectedAtodfile = "uref$dbu1405iu.r1h"; String expectedCalVersion = " "; String expectedCalibDef = "1466"; GDALParser parser = new GDALParser(); InputStream stream = TestGDALParser.class .getResourceAsStream(fitsFilename); Metadata met = new Metadata(); BodyContentHandler handler = new BodyContentHandler(); try { parser.parse(stream, handler, met, new ParseContext()); assertNotNull(met); assertNotNull(met.get("ALLG-MIN")); assertEquals(expectedAllgMin, met.get("ALLG-MIN")); assertNotNull(met.get("ATODCORR")); assertEquals(expectedAtodcorr, met.get("ATODCORR")); assertNotNull(met.get("ATODFILE")); assertEquals(expectedAtodfile, met.get("ATODFILE")); assertNotNull(met.get("CAL_VER")); assertEquals(expectedCalVersion, met.get("CAL_VER")); assertNotNull(met.get("CALIBDEF")); assertEquals(expectedCalibDef, met.get("CALIBDEF")); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); void setCommand(String command); String getCommand(); String processCommand(InputStream stream); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
                      Metadata metadata, ParseContext context); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); void setCommand(String command); String getCommand(); String processCommand(InputStream stream); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
                      Metadata metadata, ParseContext context);  }