use of com.rometools.rome.feed.rss.Item in project wombat by PLOS.
the class CommentFeedView method createRssItem.
@Override
protected Item createRssItem(FeedMetadata feedMetadata, Map<String, Object> comment) {
String commentId = (String) comment.get("commentUri");
Item item = new Item();
item.setTitle((String) comment.get("title"));
item.setLink(getCommentUrl(feedMetadata, commentId));
item.setAuthor(getCreatorDisplayName(comment));
item.setPubDate(getCommentDate(comment));
Guid guid = new Guid();
guid.setValue(commentId);
guid.setPermaLink(false);
item.setGuid(guid);
com.rometools.rome.feed.rss.Content content = new com.rometools.rome.feed.rss.Content();
content.setType(com.rometools.rome.feed.rss.Content.HTML);
content.setValue(createCommentHtml(feedMetadata, comment));
item.setContent(content);
return item;
}
use of com.rometools.rome.feed.rss.Item in project books by aidanwhiteley.
the class SiteRssFeedTest method checkFeedForFeedData.
@Test
void checkFeedForFeedData() {
Channel channel = siteFeed.createSiteRssFeed();
assertEquals(booksFeedsDescription, channel.getDescription());
assertTrue(channel.getItems().size() > 0 && channel.getItems().size() <= booksFeedsMaxEntries);
Item item = channel.getItems().get(0);
assertFalse(item.getContent().getValue().isEmpty());
}
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 tutorials by eugenp.
the class ArticleRssController method buildChannel.
private Channel buildChannel(List<Article> articles) {
Channel channel = new Channel("rss_2.0");
channel.setLink("http://localhost:8080/spring-mvc-simple/rss");
channel.setTitle("Article Feed");
channel.setDescription("Article Feed Description");
channel.setPubDate(new Date());
List<Item> items = new ArrayList<>();
for (Article article : articles) {
Item item = new Item();
item.setLink(article.getLink());
item.setTitle(article.getTitle());
Description description1 = new Description();
description1.setValue(article.getDescription());
item.setDescription(description1);
item.setPubDate(article.getPublishedDate());
item.setAuthor(article.getAuthor());
items.add(item);
}
channel.setItems(items);
return channel;
}
use of com.rometools.rome.feed.rss.Item in project spring-framework by spring-projects.
the class RssChannelHttpMessageConverterTests method write.
@Test
public void write() throws IOException {
Channel channel = new Channel("rss_2.0");
channel.setTitle("title");
channel.setLink("https://example.com");
channel.setDescription("description");
Item item1 = new Item();
item1.setTitle("title1");
Item item2 = new Item();
item2.setTitle("title2");
List<Item> items = new ArrayList<>(2);
items.add(item1);
items.add(item2);
channel.setItems(items);
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
converter.write(channel, null, outputMessage);
assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(RSS_XML_UTF8);
String expected = "<rss version=\"2.0\">" + "<channel><title>title</title><link>https://example.com</link><description>description</description>" + "<item><title>title1</title></item>" + "<item><title>title2</title></item>" + "</channel></rss>";
assertThat(XmlContent.of(outputMessage.getBodyAsString(StandardCharsets.UTF_8))).isSimilarToIgnoringWhitespace(expected);
}
Aggregations