@Test public void parse() throws FileNotFoundException, IOException { File path = new File(System.getProperty("user.dir"), "src"); path = new File(path, "test"); path = new File(path, "resources"); Set<Link> links = fixture.parse(new ParseContext(null, path.getAbsolutePath() + "/places.sqlite", "/places.sqlite")); assertNotNull(links); assertTrue(links.size() == 1); Link link = links.iterator().next(); assertEquals("http: assertEquals("Example Domain", link.getTitle()); assertEquals("Some Description On This Url", link.getDescription()); }
@Override public Set<Link> parse(ParseContext context) throws IOException { List<LinkDto> list = new ArrayList<>(); try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + context.getTemporaryFileName())) { Statement statement = connection.createStatement(); statement.setQueryTimeout(30); try (ResultSet rs = statement.executeQuery( "select b.parent, b.title, p.url, b.dateAdded, p.last_visit_date, a.content from moz_bookmarks b " + "left join moz_places p on b.fk = p.id " + "left join moz_items_annos a on b.id = a.item_id " + "where b.type = 1 and b.guid not in (\"menu________\",\"toolbar_____\",\"tags________\",\"unfiled_____\")")) { while (rs.next()) { LinkDto dto = new LinkDto(); dto.setUrl(rs.getString("url")); dto.setTitle(rs.getString("title")); dto.setDescription(rs.getString("content")); dto.setDateAdded(convertEpochToTimestamp(rs.getLong("dateAdded"))); dto.setDateVisited(convertEpochToTimestamp(rs.getLong("last_visit_date"))); dto.setParent(rs.getInt("parent")); if (dto.isValid()) { list.add(dto); } } } list.forEach(l -> { try { l.addLabels(getLabels(statement, l.getParent())); } catch (SQLException ex) { } }); } catch (SQLException e) { throw new IOException(e); } list.forEach(l -> { addLink(l.getTitle(), l.getUrl(), l.getLabels(), l.getDescription(), l.getDateAdded(), l.getDateVisited()); }); return getLinks(); }
FireFoxParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { List<LinkDto> list = new ArrayList<>(); try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + context.getTemporaryFileName())) { Statement statement = connection.createStatement(); statement.setQueryTimeout(30); try (ResultSet rs = statement.executeQuery( "select b.parent, b.title, p.url, b.dateAdded, p.last_visit_date, a.content from moz_bookmarks b " + "left join moz_places p on b.fk = p.id " + "left join moz_items_annos a on b.id = a.item_id " + "where b.type = 1 and b.guid not in (\"menu________\",\"toolbar_____\",\"tags________\",\"unfiled_____\")")) { while (rs.next()) { LinkDto dto = new LinkDto(); dto.setUrl(rs.getString("url")); dto.setTitle(rs.getString("title")); dto.setDescription(rs.getString("content")); dto.setDateAdded(convertEpochToTimestamp(rs.getLong("dateAdded"))); dto.setDateVisited(convertEpochToTimestamp(rs.getLong("last_visit_date"))); dto.setParent(rs.getInt("parent")); if (dto.isValid()) { list.add(dto); } } } list.forEach(l -> { try { l.addLabels(getLabels(statement, l.getParent())); } catch (SQLException ex) { } }); } catch (SQLException e) { throw new IOException(e); } list.forEach(l -> { addLink(l.getTitle(), l.getUrl(), l.getLabels(), l.getDescription(), l.getDateAdded(), l.getDateVisited()); }); return getLinks(); } }
FireFoxParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { List<LinkDto> list = new ArrayList<>(); try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + context.getTemporaryFileName())) { Statement statement = connection.createStatement(); statement.setQueryTimeout(30); try (ResultSet rs = statement.executeQuery( "select b.parent, b.title, p.url, b.dateAdded, p.last_visit_date, a.content from moz_bookmarks b " + "left join moz_places p on b.fk = p.id " + "left join moz_items_annos a on b.id = a.item_id " + "where b.type = 1 and b.guid not in (\"menu________\",\"toolbar_____\",\"tags________\",\"unfiled_____\")")) { while (rs.next()) { LinkDto dto = new LinkDto(); dto.setUrl(rs.getString("url")); dto.setTitle(rs.getString("title")); dto.setDescription(rs.getString("content")); dto.setDateAdded(convertEpochToTimestamp(rs.getLong("dateAdded"))); dto.setDateVisited(convertEpochToTimestamp(rs.getLong("last_visit_date"))); dto.setParent(rs.getInt("parent")); if (dto.isValid()) { list.add(dto); } } } list.forEach(l -> { try { l.addLabels(getLabels(statement, l.getParent())); } catch (SQLException ex) { } }); } catch (SQLException e) { throw new IOException(e); } list.forEach(l -> { addLink(l.getTitle(), l.getUrl(), l.getLabels(), l.getDescription(), l.getDateAdded(), l.getDateVisited()); }); return getLinks(); } FireFoxParser(); }
FireFoxParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { List<LinkDto> list = new ArrayList<>(); try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + context.getTemporaryFileName())) { Statement statement = connection.createStatement(); statement.setQueryTimeout(30); try (ResultSet rs = statement.executeQuery( "select b.parent, b.title, p.url, b.dateAdded, p.last_visit_date, a.content from moz_bookmarks b " + "left join moz_places p on b.fk = p.id " + "left join moz_items_annos a on b.id = a.item_id " + "where b.type = 1 and b.guid not in (\"menu________\",\"toolbar_____\",\"tags________\",\"unfiled_____\")")) { while (rs.next()) { LinkDto dto = new LinkDto(); dto.setUrl(rs.getString("url")); dto.setTitle(rs.getString("title")); dto.setDescription(rs.getString("content")); dto.setDateAdded(convertEpochToTimestamp(rs.getLong("dateAdded"))); dto.setDateVisited(convertEpochToTimestamp(rs.getLong("last_visit_date"))); dto.setParent(rs.getInt("parent")); if (dto.isValid()) { list.add(dto); } } } list.forEach(l -> { try { l.addLabels(getLabels(statement, l.getParent())); } catch (SQLException ex) { } }); } catch (SQLException e) { throw new IOException(e); } list.forEach(l -> { addLink(l.getTitle(), l.getUrl(), l.getLabels(), l.getDescription(), l.getDateAdded(), l.getDateVisited()); }); return getLinks(); } FireFoxParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context); }
FireFoxParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { List<LinkDto> list = new ArrayList<>(); try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + context.getTemporaryFileName())) { Statement statement = connection.createStatement(); statement.setQueryTimeout(30); try (ResultSet rs = statement.executeQuery( "select b.parent, b.title, p.url, b.dateAdded, p.last_visit_date, a.content from moz_bookmarks b " + "left join moz_places p on b.fk = p.id " + "left join moz_items_annos a on b.id = a.item_id " + "where b.type = 1 and b.guid not in (\"menu________\",\"toolbar_____\",\"tags________\",\"unfiled_____\")")) { while (rs.next()) { LinkDto dto = new LinkDto(); dto.setUrl(rs.getString("url")); dto.setTitle(rs.getString("title")); dto.setDescription(rs.getString("content")); dto.setDateAdded(convertEpochToTimestamp(rs.getLong("dateAdded"))); dto.setDateVisited(convertEpochToTimestamp(rs.getLong("last_visit_date"))); dto.setParent(rs.getInt("parent")); if (dto.isValid()) { list.add(dto); } } } list.forEach(l -> { try { l.addLabels(getLabels(statement, l.getParent())); } catch (SQLException ex) { } }); } catch (SQLException e) { throw new IOException(e); } list.forEach(l -> { addLink(l.getTitle(), l.getUrl(), l.getLabels(), l.getDescription(), l.getDateAdded(), l.getDateVisited()); }); return getLinks(); } FireFoxParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context);  }