Search in sources :

Example 6 with Item

use of com.rometools.rome.feed.rss.Item in project nixmash-blog by mintster.

the class RssPostFeedView method createItem.

private Item createItem(Post post) {
    Item item = new Item();
    item.setLink(applicationSettings.getBaseUrl() + "/post/" + post.getPostName());
    item.setTitle(post.getPostTitle());
    item.setDescription(createDescription(post));
    item.setPubDate(getPostDate(post));
    return item;
}
Also used : Item(com.rometools.rome.feed.rss.Item)

Example 7 with Item

use of com.rometools.rome.feed.rss.Item in project wombat by PLOS.

the class ArticleFeedView method createRssItem.

@Override
protected Item createRssItem(FeedMetadata feedMetadata, Map<String, Object> article) {
    Item item = new Item();
    item.setTitle(getArticleTitle(article));
    item.setLink(getArticleLink(feedMetadata, article));
    Guid guid = new Guid();
    guid.setValue((String) article.get("id"));
    guid.setPermaLink(false);
    item.setGuid(guid);
    item.setPubDate(getPubDate(feedMetadata, article));
    List<String> authorList = (List<String>) article.get("author_display");
    if (authorList != null) {
        item.setAuthor(AUTHOR_JOINER.join(authorList));
    }
    item.setDescription(buildRssDescription(article));
    return item;
}
Also used : Item(com.rometools.rome.feed.rss.Item) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Guid(com.rometools.rome.feed.rss.Guid)

Example 8 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 9 with Item

use of com.rometools.rome.feed.rss.Item in project spring-framework by spring-projects.

the class RssChannelHttpMessageConverterTests method writeOtherCharset.

@Test
public void writeOtherCharset() throws IOException {
    Channel channel = new Channel("rss_2.0");
    channel.setTitle("title");
    channel.setLink("https://example.com");
    channel.setDescription("description");
    String encoding = "ISO-8859-1";
    channel.setEncoding(encoding);
    Item item1 = new Item();
    item1.setTitle("title1");
    MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
    converter.write(channel, null, outputMessage);
    assertThat(outputMessage.getHeaders().getContentType()).as("Invalid content-type").isEqualTo(new MediaType("application", "rss+xml", Charset.forName(encoding)));
}
Also used : Item(com.rometools.rome.feed.rss.Item) Channel(com.rometools.rome.feed.rss.Channel) MockHttpOutputMessage(org.springframework.http.MockHttpOutputMessage) MediaType(org.springframework.http.MediaType) Test(org.junit.jupiter.api.Test)

Example 10 with Item

use of com.rometools.rome.feed.rss.Item in project spring-framework by spring-projects.

the class RssChannelHttpMessageConverterTests method read.

@Test
public void read() throws IOException {
    InputStream inputStream = getClass().getResourceAsStream("rss.xml");
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(inputStream);
    inputMessage.getHeaders().setContentType(RSS_XML_UTF8);
    Channel result = converter.read(Channel.class, inputMessage);
    assertThat(result.getTitle()).isEqualTo("title");
    assertThat(result.getLink()).isEqualTo("https://example.com");
    assertThat(result.getDescription()).isEqualTo("description");
    List<?> items = result.getItems();
    assertThat(items.size()).isEqualTo(2);
    Item item1 = (Item) items.get(0);
    assertThat(item1.getTitle()).isEqualTo("title1");
    Item item2 = (Item) items.get(1);
    assertThat(item2.getTitle()).isEqualTo("title2");
}
Also used : Item(com.rometools.rome.feed.rss.Item) MockHttpInputMessage(org.springframework.http.MockHttpInputMessage) InputStream(java.io.InputStream) Channel(com.rometools.rome.feed.rss.Channel) 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