@Test public void readRSS() throws StudyImporterException, IOException { final Dataset dataset = getDatasetGroup(); List<Dataset> datasets = DatasetImporterForRSS.getDatasetsForFeed(dataset); assertThat(datasets.size(), is(3)); assertThat(datasets.get(0).getOrDefault("hasDependencies", null), is("false")); }
static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRSSEndpoint(datasetOrig); try { URI rssURI = URI.create(StringUtils.isBlank(rss) ? "rss" : rss); feed = input.build(new XmlReader(datasetOrig.retrieve(rssURI))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { String title = StringUtils.trim(((SyndEntry) entry).getTitle()); if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) { Dataset e = datasetFor(datasetOrig, (SyndEntry) entry); LOG.info("including [" + title + "]."); if (e != null) { datasets.add(e); } ; } else { LOG.info("skipping [" + title + "] : was not included or excluded."); } } } return datasets; }
DatasetImporterForRSS extends NodeBasedImporter { static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRSSEndpoint(datasetOrig); try { URI rssURI = URI.create(StringUtils.isBlank(rss) ? "rss" : rss); feed = input.build(new XmlReader(datasetOrig.retrieve(rssURI))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { String title = StringUtils.trim(((SyndEntry) entry).getTitle()); if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) { Dataset e = datasetFor(datasetOrig, (SyndEntry) entry); LOG.info("including [" + title + "]."); if (e != null) { datasets.add(e); } ; } else { LOG.info("skipping [" + title + "] : was not included or excluded."); } } } return datasets; } }
DatasetImporterForRSS extends NodeBasedImporter { static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRSSEndpoint(datasetOrig); try { URI rssURI = URI.create(StringUtils.isBlank(rss) ? "rss" : rss); feed = input.build(new XmlReader(datasetOrig.retrieve(rssURI))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { String title = StringUtils.trim(((SyndEntry) entry).getTitle()); if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) { Dataset e = datasetFor(datasetOrig, (SyndEntry) entry); LOG.info("including [" + title + "]."); if (e != null) { datasets.add(e); } ; } else { LOG.info("skipping [" + title + "] : was not included or excluded."); } } } return datasets; } DatasetImporterForRSS(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForRSS extends NodeBasedImporter { static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRSSEndpoint(datasetOrig); try { URI rssURI = URI.create(StringUtils.isBlank(rss) ? "rss" : rss); feed = input.build(new XmlReader(datasetOrig.retrieve(rssURI))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { String title = StringUtils.trim(((SyndEntry) entry).getTitle()); if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) { Dataset e = datasetFor(datasetOrig, (SyndEntry) entry); LOG.info("including [" + title + "]."); if (e != null) { datasets.add(e); } ; } else { LOG.info("skipping [" + title + "] : was not included or excluded."); } } } return datasets; } DatasetImporterForRSS(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); String getRssFeedUrlString(); static Dataset datasetFor(Dataset datasetOrig, SyndEntry entry); }
DatasetImporterForRSS extends NodeBasedImporter { static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRSSEndpoint(datasetOrig); try { URI rssURI = URI.create(StringUtils.isBlank(rss) ? "rss" : rss); feed = input.build(new XmlReader(datasetOrig.retrieve(rssURI))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { String title = StringUtils.trim(((SyndEntry) entry).getTitle()); if (shouldIncludeTitleInDatasetCollection(title, datasetOrig)) { Dataset e = datasetFor(datasetOrig, (SyndEntry) entry); LOG.info("including [" + title + "]."); if (e != null) { datasets.add(e); } ; } else { LOG.info("skipping [" + title + "] : was not included or excluded."); } } } return datasets; } DatasetImporterForRSS(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); String getRssFeedUrlString(); static Dataset datasetFor(Dataset datasetOrig, SyndEntry entry); static final String HAS_DEPENDENCIES; }