use of com.sun.syndication.feed.synd.SyndFeed in project xwiki-platform by xwiki.
the class FeedPluginApi method getBlogFeed.
/**
* Instantiates the default article feed.
*
* @param list a list of articles (as document instances or document names)
* @param metadata feed meta data (includes the author, description, copyright, encoding, url, title)
* @return a new feed
* @see #getArticleFeed(List, Map)
*/
public SyndFeed getBlogFeed(List<Object> list, Map<String, Object> metadata) {
Map<String, Object> params = Collections.emptyMap();
SyndFeed blogFeed = getFeed(list, getSyndEntrySource(SyndEntryDocumentSource.class.getName(), BLOG_FIELDS_MAPPING), params, fillBlogFeedMetadata(metadata));
if (blogFeed != null) {
blogFeed.setImage(getDefaultFeedImage());
}
return blogFeed;
}
use of com.sun.syndication.feed.synd.SyndFeed in project xwiki-platform by xwiki.
the class FeedPluginApi method getWebFeed.
/**
* Instantiates the default document feed.
*
* @param list a list of {@link com.xpn.xwiki.api.Document} objects, {@link com.xpn.xwiki.doc.XWikiDocument} objects or document names
* @param metadata feed meta data (includes the author, description, copyright, encoding, url, title)
* @return a new feed
* @see #getDocumentFeed(List, Map)
*/
public SyndFeed getWebFeed(List<Object> list, Map<String, Object> metadata) {
Map<String, Object> params = Collections.emptyMap();
SyndFeed webFeed = getDocumentFeed(list, params, fillWebFeedMetadata(metadata));
if (webFeed != null) {
webFeed.setImage(getDefaultFeedImage());
}
return webFeed;
}
use of com.sun.syndication.feed.synd.SyndFeed in project xwiki-platform by xwiki.
the class XWikiFeedFetcher method getFeed.
private SyndFeed getFeed(SyndFeedInfo syndFeedInfo, String urlStr, HttpMethod method, int statusCode) throws IOException, FeedException {
if (statusCode == HttpURLConnection.HTTP_NOT_MODIFIED && syndFeedInfo != null) {
fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, urlStr);
return syndFeedInfo.getSyndFeed();
}
SyndFeed feed = retrieveFeed(urlStr, method);
fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, urlStr, feed);
return feed;
}
use of com.sun.syndication.feed.synd.SyndFeed in project xwiki-platform by xwiki.
the class XWikiFeedFetcher method buildSyndFeedInfo.
/**
* @param feedUrl
* @param urlStr
* @param method
* @param feed
* @return
* @throws MalformedURLException
*/
private SyndFeedInfo buildSyndFeedInfo(URL feedUrl, String urlStr, HttpMethod method, SyndFeed feed, int statusCode) throws MalformedURLException {
SyndFeedInfo syndFeedInfo;
syndFeedInfo = new SyndFeedInfo();
// this may be different to feedURL because of 3XX redirects
syndFeedInfo.setUrl(new URL(urlStr));
syndFeedInfo.setId(feedUrl.toString());
Header imHeader = method.getResponseHeader("IM");
if (imHeader != null && imHeader.getValue().indexOf("feed") >= 0 && isUsingDeltaEncoding()) {
FeedFetcherCache cache = getFeedInfoCache();
if (cache != null && statusCode == 226) {
// client is setup to use http delta encoding and the server supports it and has returned a delta
// encoded response.
// This response only includes new items
SyndFeedInfo cachedInfo = cache.getFeedInfo(feedUrl);
if (cachedInfo != null) {
SyndFeed cachedFeed = cachedInfo.getSyndFeed();
// set the new feed to be the orginal feed plus the new items
feed = combineFeeds(cachedFeed, feed);
}
}
}
Header lastModifiedHeader = method.getResponseHeader("Last-Modified");
if (lastModifiedHeader != null) {
syndFeedInfo.setLastModified(lastModifiedHeader.getValue());
}
Header eTagHeader = method.getResponseHeader("ETag");
if (eTagHeader != null) {
syndFeedInfo.setETag(eTagHeader.getValue());
}
syndFeedInfo.setSyndFeed(feed);
return syndFeedInfo;
}
use of com.sun.syndication.feed.synd.SyndFeed in project liferay-ide by liferay.
the class KBArticleServiceImpl method exportToRSS.
protected String exportToRSS(String rssDisplayStyle, String rssFormat, String name, String description, String feedURL, List<KBArticle> kbArticles, ThemeDisplay themeDisplay) throws SystemException {
SyndFeed syndFeed = new SyndFeedImpl();
syndFeed.setDescription(description);
List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
syndFeed.setEntries(syndEntries);
for (KBArticle kbArticle : kbArticles) {
SyndEntry syndEntry = new SyndEntryImpl();
String author = PortalUtil.getUserName(kbArticle);
syndEntry.setAuthor(author);
SyndContent syndContent = new SyndContentImpl();
syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);
String value = null;
if (rssDisplayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
value = HtmlUtil.extractText(kbArticle.getDescription());
if (Validator.isNull(value)) {
value = StringUtil.shorten(HtmlUtil.extractText(kbArticle.getContent()), 200);
}
} else if (rssDisplayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
value = StringPool.BLANK;
} else {
value = StringUtil.replace(kbArticle.getContent(), new String[] { "href=\"/", "src=\"/" }, new String[] { "href=\"" + themeDisplay.getURLPortal() + "/", "src=\"" + themeDisplay.getURLPortal() + "/" });
}
syndContent.setValue(value);
syndEntry.setDescription(syndContent);
String link = KnowledgeBaseUtil.getKBArticleURL(themeDisplay.getPlid(), kbArticle.getResourcePrimKey(), kbArticle.getStatus(), themeDisplay.getPortalURL(), false);
syndEntry.setLink(link);
syndEntry.setPublishedDate(kbArticle.getCreateDate());
syndEntry.setTitle(kbArticle.getTitle());
syndEntry.setUpdatedDate(kbArticle.getModifiedDate());
syndEntry.setUri(syndEntry.getLink());
syndEntries.add(syndEntry);
}
String feedType = RSSUtil.getFeedType(RSSUtil.getFormatType(rssFormat), RSSUtil.getFormatVersion(rssFormat));
syndFeed.setFeedType(feedType);
List<SyndLink> syndLinks = new ArrayList<SyndLink>();
syndFeed.setLinks(syndLinks);
SyndLink selfSyndLink = new SyndLinkImpl();
syndLinks.add(selfSyndLink);
selfSyndLink.setHref(feedURL);
selfSyndLink.setRel("self");
syndFeed.setPublishedDate(new Date());
syndFeed.setTitle(name);
syndFeed.setUri(feedURL);
try {
return RSSUtil.export(syndFeed);
} catch (FeedException fe) {
throw new SystemException(fe);
}
}
Aggregations