use of com.rometools.rome.feed.rss.Item in project nixmash-blog by mintster.
the class RssPostFeedView method createItem.
private Item createItem(Post post) {
Item item = new Item();
item.setLink(applicationSettings.getBaseUrl() + "/post/" + post.getPostName());
item.setTitle(post.getPostTitle());
item.setDescription(createDescription(post));
item.setPubDate(getPostDate(post));
return item;
}
use of com.rometools.rome.feed.rss.Item in project wombat by PLOS.
the class ArticleFeedView method createRssItem.
@Override
protected Item createRssItem(FeedMetadata feedMetadata, Map<String, Object> article) {
Item item = new Item();
item.setTitle(getArticleTitle(article));
item.setLink(getArticleLink(feedMetadata, article));
Guid guid = new Guid();
guid.setValue((String) article.get("id"));
guid.setPermaLink(false);
item.setGuid(guid);
item.setPubDate(getPubDate(feedMetadata, article));
List<String> authorList = (List<String>) article.get("author_display");
if (authorList != null) {
item.setAuthor(AUTHOR_JOINER.join(authorList));
}
item.setDescription(buildRssDescription(article));
return item;
}
use of com.rometools.rome.feed.rss.Item in project tutorials by eugenp.
the class ArticleFeedView method buildFeedItems.
@Override
protected List<Item> buildFeedItems(Map<String, Object> map, HttpServletRequest httpStRequest, HttpServletResponse httpStResponse) throws Exception {
List list = new ArrayList<Item>();
Item item1 = new Item();
item1.setLink("http://www.baeldung.com/netty-exception-handling");
item1.setTitle("Exceptions in Netty");
Description description1 = new Description();
description1.setValue("In this quick article, we’ll be looking at exception handling in Netty.");
item1.setDescription(description1);
item1.setPubDate(new Date());
item1.setAuthor("Carlos");
Item item2 = new Item();
item2.setLink("http://www.baeldung.com/cockroachdb-java");
item2.setTitle("Guide to CockroachDB in Java");
Description description2 = new Description();
description2.setValue("This tutorial is an introductory guide to using CockroachDB with Java.");
item2.setDescription(description2);
item2.setPubDate(new Date());
item2.setAuthor("Baeldung");
list.add(item1);
list.add(item2);
return list;
}
use of com.rometools.rome.feed.rss.Item in project spring-framework by spring-projects.
the class RssChannelHttpMessageConverterTests method writeOtherCharset.
@Test
public void writeOtherCharset() throws IOException {
Channel channel = new Channel("rss_2.0");
channel.setTitle("title");
channel.setLink("https://example.com");
channel.setDescription("description");
String encoding = "ISO-8859-1";
channel.setEncoding(encoding);
Item item1 = new Item();
item1.setTitle("title1");
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
converter.write(channel, null, outputMessage);
assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "rss+xml", Charset.forName(encoding)));
}
use of com.rometools.rome.feed.rss.Item in project spring-framework by spring-projects.
the class RssChannelHttpMessageConverterTests method read.
@Test
public void read() throws IOException {
InputStream inputStream = getClass().getResourceAsStream("rss.xml");
MockHttpInputMessage inputMessage = new MockHttpInputMessage(inputStream);
inputMessage.getHeaders().setContentType(RSS_XML_UTF8);
Channel result = converter.read(Channel.class, inputMessage);
assertThat(result.getTitle()).isEqualTo("title");
assertThat(result.getLink()).isEqualTo("https://example.com");
assertThat(result.getDescription()).isEqualTo("description");
List<?> items = result.getItems();
assertThat(items.size()).isEqualTo(2);
Item item1 = (Item) items.get(0);
assertThat(item1.getTitle()).isEqualTo("title1");
Item item2 = (Item) items.get(1);
assertThat(item2.getTitle()).isEqualTo("title2");
}
Aggregations