use of com.sun.syndication.io.WireFeedOutput in project ofbiz-framework by apache.
the class RomeEventHandler method init.
public void init(ServletContext context) throws EventHandlerException {
// get the service event handler
this.service = new ServiceEventHandler();
this.service.init(context);
this.out = new WireFeedOutput();
}
use of com.sun.syndication.io.WireFeedOutput in project halo by ruibaby.
the class HaloUtil method getRss.
/**
* 生成rss
* @param posts posts
* @return string
* @throws FeedException
*/
public static String getRss(List<Post> posts) throws FeedException {
Channel channel = new Channel("rss_2.0");
if (null == HaloConst.OPTIONS.get("site_title")) {
channel.setTitle("");
} else {
channel.setTitle(HaloConst.OPTIONS.get("site_title"));
}
if (null == HaloConst.OPTIONS.get("site_url")) {
channel.setLink("");
} else {
channel.setLink(HaloConst.OPTIONS.get("site_url"));
}
if (null == HaloConst.OPTIONS.get("seo_desc")) {
channel.setDescription("");
} else {
channel.setDescription(HaloConst.OPTIONS.get("seo_desc"));
}
channel.setLanguage("zh-CN");
List<Item> items = new ArrayList<>();
for (Post post : posts) {
Item item = new Item();
item.setTitle(post.getPostTitle());
Content content = new Content();
String value = post.getPostContent();
char[] xmlChar = value.toCharArray();
for (int i = 0; i < xmlChar.length; ++i) {
if (xmlChar[i] > 0xFFFD) {
xmlChar[i] = ' ';
} else if (xmlChar[i] < 0x20 && xmlChar[i] != 't' & xmlChar[i] != 'n' & xmlChar[i] != 'r') {
xmlChar[i] = ' ';
}
}
value = new String(xmlChar);
content.setValue(value);
item.setContent(content);
item.setLink(HaloConst.OPTIONS.get("site_url") + "/article/" + post.getPostUrl());
item.setPubDate(post.getPostDate());
items.add(item);
}
channel.setItems(items);
WireFeedOutput out = new WireFeedOutput();
return out.outputString(channel);
}
use of com.sun.syndication.io.WireFeedOutput in project tale by otale.
the class TaleUtils method getRssXml.
/**
* 获取RSS输出
*/
public static String getRssXml(java.util.List<Contents> articles) throws FeedException {
Channel channel = new Channel("rss_2.0");
channel.setTitle(TaleConst.OPTIONS.get("site_title", ""));
channel.setLink(Commons.site_url());
channel.setDescription(TaleConst.OPTIONS.get("site_description", ""));
channel.setLanguage("zh-CN");
java.util.List<Item> items = new ArrayList<>();
articles.forEach(post -> {
Item item = new Item();
item.setTitle(post.getTitle());
Content content = new Content();
String value = Theme.article(post.getContent());
char[] xmlChar = value.toCharArray();
for (int i = 0; i < xmlChar.length; ++i) {
if (xmlChar[i] > 0xFFFD) {
// 直接替换掉0xb
xmlChar[i] = ' ';
} else if (xmlChar[i] < 0x20 && xmlChar[i] != 't' & xmlChar[i] != 'n' & xmlChar[i] != 'r') {
// 直接替换掉0xb
xmlChar[i] = ' ';
}
}
value = new String(xmlChar);
content.setValue(value);
item.setContent(content);
item.setLink(Theme.permalink(post.getCid(), post.getSlug()));
item.setPubDate(DateKit.toDate(post.getCreated()));
items.add(item);
});
channel.setItems(items);
WireFeedOutput out = new WireFeedOutput();
return out.outputString(channel);
}