use of com.rometools.rome.feed.rss.Channel in project nixmash-blog by mintster.
the class RssPostFeedView method newFeed.
@Override
protected Channel newFeed() {
Channel channel = new Channel("rss_2.0");
channel.setLink(applicationSettings.getBaseUrl() + "/posts/feed/");
channel.setTitle(applicationSettings.getRssChannelTitle());
channel.setDescription(applicationSettings.getRssChannelDescription());
postService.getOneMostRecent().ifPresent(p -> channel.setPubDate(Date.from(p.getPostDate().toInstant())));
return channel;
}
use of com.rometools.rome.feed.rss.Channel 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.Channel in project tutorials by eugenp.
the class ArticleRssController method articleHttpFeed.
@GetMapping(value = "/rss2", produces = { "application/rss+xml", "application/rss+json" })
@ResponseBody
public Channel articleHttpFeed() {
List<Article> items = new ArrayList<>();
Article item1 = new Article();
item1.setLink("http://www.baeldung.com/netty-exception-handling");
item1.setTitle("Exceptions in Netty");
item1.setDescription("In this quick article, we’ll be looking at exception handling in Netty.");
item1.setPublishedDate(new Date());
item1.setAuthor("Carlos");
Article item2 = new Article();
item2.setLink("http://www.baeldung.com/cockroachdb-java");
item2.setTitle("Guide to CockroachDB in Java");
item2.setDescription("This tutorial is an introductory guide to using CockroachDB with Java.");
item2.setPublishedDate(new Date());
item2.setAuthor("Baeldung");
items.add(item1);
items.add(item2);
Channel channelData = buildChannel(items);
return channelData;
}
use of com.rometools.rome.feed.rss.Channel 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);
}
use of com.rometools.rome.feed.rss.Channel 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());
}
Aggregations