Search in sources :

Example 1 with Feed

use of org.finos.symphony.rssbot.feed.Feed in project spring-bot by finos.

the class FeedLoader method createFeed.

public Feed createFeed(String url, String name) throws FeedException {
    Exception last = null;
    for (ProxyProperties proxyProperties : pp) {
        try {
            SyndFeedInput input = new SyndFeedInput();
            input.setAllowDoctypes(true);
            SyndFeed feed = input.build(new XmlReader(downloadContent(url, proxyProperties)));
            Feed f = new Feed();
            if (!StringUtils.hasText(name)) {
                f.setName(feed.getTitle());
            } else {
                f.setName(name);
            }
            f.setDescription(feed.getDescription());
            f.setUrl(url);
            f.setProxy(proxyProperties);
            return f;
        } catch (Exception e) {
            LOG.info("Couldn't get feed " + url + " with " + proxyProperties.getHost());
            last = e;
        }
    }
    throw new FeedException("Couldn't download feed with any proxy", last);
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) ProxyProperties(org.finos.symphony.toolkit.spring.api.properties.ProxyProperties) SyndFeedInput(com.rometools.rome.io.SyndFeedInput) FeedException(com.rometools.rome.io.FeedException) XmlReader(com.rometools.rome.io.XmlReader) MalformedURLException(java.net.MalformedURLException) FeedException(com.rometools.rome.io.FeedException) Feed(org.finos.symphony.rssbot.feed.Feed) SyndFeed(com.rometools.rome.feed.synd.SyndFeed)

Example 2 with Feed

use of org.finos.symphony.rssbot.feed.Feed in project spring-bot by finos.

the class TimedAlerter method allItems.

public int allItems(Addressable a, FeedList fl) {
    int count = 0;
    for (Feed f : fl.getFeeds()) {
        try {
            count += allItemsInFeed(f, a, fl);
            flc.setNextReportTime(fl);
        } catch (Exception e) {
            LOG.error("AllItems failed: ", e);
            responseHandler.accept(new ErrorResponse(a, e));
        }
    }
    return count;
}
Also used : Feed(org.finos.symphony.rssbot.feed.Feed) ErrorResponse(org.finos.symphony.toolkit.workflow.response.ErrorResponse)

Aggregations

Feed (org.finos.symphony.rssbot.feed.Feed)2 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 FeedException (com.rometools.rome.io.FeedException)1 SyndFeedInput (com.rometools.rome.io.SyndFeedInput)1 XmlReader (com.rometools.rome.io.XmlReader)1 MalformedURLException (java.net.MalformedURLException)1 ProxyProperties (org.finos.symphony.toolkit.spring.api.properties.ProxyProperties)1 ErrorResponse (org.finos.symphony.toolkit.workflow.response.ErrorResponse)1