use of com.rometools.rome.feed.rss.Content in project books by aidanwhiteley.
the class SiteRssFeed method createSiteRssFeed.
public Channel createSiteRssFeed() {
PageRequest pageObj = PageRequest.of(0, booksFeedsMaxEntries);
Page<Book> recentBooks = bookRepository.findAllByOrderByCreatedDateTimeDesc(pageObj);
Channel channel = new Channel(FEED_TYPE_RSS_2_0);
channel.setTitle(booksFeedsTitles);
channel.setLink(booksFeedsDomain);
channel.setDescription(booksFeedsDescription);
channel.setPubDate(new Date());
channel.setItems(recentBooks.stream().map(b -> {
Item item = new Item();
item.setTitle(b.getTitle() + " by " + b.getAuthor());
item.setLink(booksFeedsDomain + "#/book/" + b.getId());
Guid guid = new Guid();
guid.setPermaLink(true);
guid.setValue(booksFeedsDomain + "#/book/" + b.getId());
item.setGuid(guid);
ZonedDateTime zdt = b.getCreatedDateTime().atZone(ZoneId.systemDefault());
item.setPubDate(Date.from(zdt.toInstant()));
Content content = new Content();
content.setType("text/html");
content.setValue(b.getSummary() + "\r\n \r\nRating: " + b.getRating());
item.setContent(content);
return item;
}).collect(Collectors.toList()));
return channel;
}
Aggregations