I'm looking for a way to set my RSS Feed with ROMETools. I have a spring boot blog web app. want to embed the RSS feed URL into an email marketing app to read that feed. The problem is I couldn't find anywhere in the net setting the feed items automatically, for example, everyone setting the URL and description manually like "hi this my description" and also they have the post URL entered manually like "www.domain.postId?id=20"! what I need is the blog URL detected automatically with title, body, etc... Any ideas, anyone has implemented that earlier would be a big favourite. Thanks in advance.
What I have learned is: 1- embed the dependency in POM:
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
<version>1.12.2</version>
</dependency>
2-Expose the RSS Feed URL:
@RestController
public class RssFeedRestController {
@Autowired
private RssFeedView view;
@GetMapping("/rss")
public View getFeed() {
return view;
}
}
3-Extend the AbstractRssFeedView as a @Component
@Component
public class RssFeedView extends AbstractRssFeedView {
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel channel, HttpServletRequest request) {
channel.setTitle("Title"); //Here is my Concern
channel.setDescription("Description"); //Here is my Concern
channel.setLink("www.mydomain.com"); //Here is my Concern
channel.setUri("www.mydomain.com"); //Here is my Concern
}
@Override
protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
Item item = new Item();
Date postDate = new Date();
item.setTitle("title"); //Here is my Concern
item.setLink("www.mydomain.com/"); //Here is my Concern
item.setUri("/www.mydomain.com/"); //Here is my Concern
item.setPubDate(postDate);
item.setAuthor("Me");
Description description = new Description();
description.setValue("Description"); //Here is my Concern
item.setDescription(description);
return Arrays.asList(item);
}
}