JackcessParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { TikaInputStream tis = TikaInputStream.get(stream); Database db = null; XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); String password = null; PasswordProvider passwordProvider = context.get(PasswordProvider.class); if (passwordProvider != null) { password = passwordProvider.getPassword(metadata); } try { if (password == null) { db = new DatabaseBuilder(tis.getFile()) .setCodecProvider(new CryptCodecProvider()) .setReadOnly(true).open(); } else { db = new DatabaseBuilder(tis.getFile()) .setCodecProvider(new CryptCodecProvider(password)) .setReadOnly(true).open(); } db.setLinkResolver(IGNORE_LINK_RESOLVER); JackcessExtractor ex = new JackcessExtractor(metadata, context, locale); ex.parse(db, xhtml); } catch (IllegalStateException e) { if (e.getMessage() != null && e.getMessage().contains("Incorrect password")) { throw new EncryptedDocumentException(e); } throw e; } finally { if (db != null) { try { db.close(); } catch (IOException e) { } } } xhtml.endDocument(); }  @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler, Metadata metadata,
                      ParseContext context); static final String SUMMARY_PROPERTY_PREFIX; static String MDB_PROPERTY_PREFIX; static String USER_DEFINED_PROPERTY_PREFIX; static Property MDB_PW; }
@Test public void testBasic() throws Exception { RecursiveParserWrapper w = new RecursiveParserWrapper(AUTO_DETECT_PARSER); for (String fName : new String[]{"testAccess2.accdb", "testAccess2_2000.mdb", "testAccess2_2002-2003.mdb"}) { InputStream is = null; RecursiveParserWrapperHandler handler = new RecursiveParserWrapperHandler( new BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE.XML, -1) ); try { is = this.getResourceAsStream("/test-documents/" + fName); Metadata meta = new Metadata(); ParseContext c = new ParseContext(); w.parse(is, handler, meta, c); } finally { IOUtils.closeQuietly(is); } List<Metadata> list = handler.getMetadataList(); assertEquals(4, list.size()); String mainContent = list.get(0).get(RecursiveParserWrapperHandler.TIKA_CONTENT); assertContains("</thead><tbody>", mainContent); assertContains("<th>ShortTextField</th>", mainContent); assertTrue (mainContent.contains("6/24/15") || mainContent.contains("2015-06-24")); assertContains("over the bold italic dog", mainContent); assertContains("\u666E\u6797\u65AF\u987F\u5927\u5B66", mainContent); assertContains("Test Document with embedded pdf", list.get(3).get(RecursiveParserWrapperHandler.TIKA_CONTENT)); } }