use of com.rometools.rome.feed.synd.SyndFeed in project books by aidanwhiteley.
the class FeedsControllerTest method checkRssFeedsHasEntries.
@Test
void checkRssFeedsHasEntries() throws Exception {
// Find the port the test is running on
String rootUri = this.testRestTemplate.getRootUri();
String url = rootUri + "/feeds/rss";
XmlReader reader = new XmlReader(new URL(url));
SyndFeed feed = new SyndFeedInput().build(reader);
assertEquals(booksFeedsTitles, feed.getTitle());
assertTrue(feed.getEntries().size() > 0);
for (SyndEntry entry : feed.getEntries()) {
assertFalse(entry.getContents().get(0).getValue().isEmpty());
}
}
use of com.rometools.rome.feed.synd.SyndFeed in project MtgDesktopCompanion by nicho92.
the class RSSNewsProvider method listNews.
@Override
public List<MagicNewsContent> listNews(MagicNews rssBean) throws IOException {
InputStream is = null;
SyndFeed feed;
List<MagicNewsContent> ret = new ArrayList<>();
try {
HttpURLConnection openConnection = (HttpURLConnection) new URL(rssBean.getUrl()).openConnection();
logger.debug("reading " + rssBean.getUrl());
openConnection.setRequestProperty("User-Agent", MTGConstants.USER_AGENT);
openConnection.setInstanceFollowRedirects(true);
is = openConnection.getInputStream();
InputSource source = new InputSource(is);
feed = input.build(source);
String baseURI = feed.getLink();
for (SyndEntry s : feed.getEntries()) {
MagicNewsContent content = new MagicNewsContent();
content.setTitle(s.getTitle());
content.setAuthor(s.getAuthor());
content.setDate(s.getPublishedDate());
URL link;
if (!s.getLink().startsWith(baseURI))
link = new URL(baseURI + s.getLink());
else
link = new URL(s.getLink());
content.setLink(link);
ret.add(content);
}
return ret;
} catch (IllegalArgumentException | FeedException e) {
throw new IOException(e);
} finally {
if (is != null)
is.close();
}
}
use of com.rometools.rome.feed.synd.SyndFeed in project mycore by MyCoRe-Org.
the class MCRRSSFeedImporter method importPublications.
public void importPublications(String projectID) throws Exception {
LOGGER.info("Getting new publications from {} RSS feed...", sourceSystemID);
SyndFeed feed = retrieveFeed();
List<MCRObject> importedObjects = new ArrayList<>();
for (SyndEntry entry : feed.getEntries()) {
MCRObject importedObject = handleFeedEntry(entry, projectID);
if (importedObject != null) {
importedObjects.add(importedObject);
}
}
int numPublicationsImported = importedObjects.size();
LOGGER.info("imported {} publications.", numPublicationsImported);
if ((numPublicationsImported > 0) && (xsl2BuildNotificationMail != null)) {
sendNotificationMail(importedObjects);
}
}
use of com.rometools.rome.feed.synd.SyndFeed in project openolat by klemens.
the class FeedManagerImpl method createFeedFile.
@Override
public MediaResource createFeedFile(OLATResourceable ores, Identity identity, Long courseId, String nodeId) {
MediaResource media = null;
Feed feed = loadFeed(ores);
if (feed != null) {
SyndFeed rssFeed = new RSSFeed(feed, identity, courseId, nodeId);
media = new SyndFeedMediaResource(rssFeed);
}
return media;
}
use of com.rometools.rome.feed.synd.SyndFeed in project openolat by klemens.
the class RomeFeedFetcher method fetchSyndFeed.
/**
* Fetches the SyndFeed of an URL.
* @param feedURL
* @return
*/
protected SyndFeed fetchSyndFeed(String feedURL) {
SyndFeed syndFeed = null;
try (Reader xmlReader = new XmlReader(new URL(feedURL))) {
syndFeed = syndFeedInput.build(xmlReader);
log.info("Read external feed: " + feedURL);
} catch (Exception e) {
log.warn("Cannot read external feed: : " + feedURL);
}
return syndFeed;
}
Aggregations