private static final Logger log = LoggerFactory.getLogger(RomeRssControllerBean.class);
public static List<RssTitleBean> getFeedTitles(URL source, int headsize) throws IOException, FeedException {
List<RssTitleBean> rssTitleBeanList = new ArrayList<RssTitleBean>();
XmlReader reader = null;
try {
reader = new XmlReader(source);
SyndFeed feed = new SyndFeedInput().build(reader);
for (Iterator i = feed.getEntries().iterator(); i.hasNext() && (headsize-- > 0);) {
SyndEntry entry = (SyndEntry) i.next();
RssTitleBean rssTitleBean = new RssTitleBean();
rssTitleBean.setTitle(entry.getTitle());
rssTitleBean.setLink(entry.getLink());
rssTitleBean.setPublishedDate(entry.getPublishedDate());
List<RssAuthorBean> rssAuthors = new ArrayList<RssAuthorBean>();
for (SyndPerson author : (List<SyndPerson>) entry.getAuthors()) {
RssAuthorBean rssAuthorBean = new RssAuthorBean();
rssAuthorBean.setName(author.getName());
rssAuthorBean.setUri(author.getUri());
rssAuthors.add(rssAuthorBean);
}
rssTitleBean.setAuthors(rssAuthors);
rssTitleBeanList.add(rssTitleBean);
}
} finally {
if (reader != null) {
reader.close();
}
}
return rssTitleBeanList;
}