Search in sources :

Example 1 with Item

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;
}
Also used : Item(com.rometools.rome.feed.rss.Item) Guid(com.rometools.rome.feed.rss.Guid)

Example 2 with 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());
}
Also used : Item(com.rometools.rome.feed.rss.Item) Channel(com.rometools.rome.feed.rss.Channel) Test(org.junit.jupiter.api.Test)

Example 3 with 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;
}
Also used : Item(com.rometools.rome.feed.rss.Item) Description(com.rometools.rome.feed.rss.Description) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 4 with Item

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;
}
Also used : Item(com.rometools.rome.feed.rss.Item) Description(com.rometools.rome.feed.rss.Description) Channel(com.rometools.rome.feed.rss.Channel) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 5 with Item

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);
}
Also used : Item(com.rometools.rome.feed.rss.Item) Channel(com.rometools.rome.feed.rss.Channel) MockHttpOutputMessage(org.springframework.http.MockHttpOutputMessage) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

Item (com.rometools.rome.feed.rss.Item)11 Channel (com.rometools.rome.feed.rss.Channel)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Test (org.junit.jupiter.api.Test)4 Description (com.rometools.rome.feed.rss.Description)3 Guid (com.rometools.rome.feed.rss.Guid)3 List (java.util.List)3 MockHttpOutputMessage (org.springframework.http.MockHttpOutputMessage)2 Book (com.aidanwhiteley.books.domain.Book)1 ImmutableList (com.google.common.collect.ImmutableList)1 Content (com.rometools.rome.feed.rss.Content)1 InputStream (java.io.InputStream)1 ZonedDateTime (java.time.ZonedDateTime)1 PageRequest (org.springframework.data.domain.PageRequest)1 MediaType (org.springframework.http.MediaType)1 MockHttpInputMessage (org.springframework.http.MockHttpInputMessage)1