Java Code Examples for com.rometools.rome.feed.rss.Channel#setDescription()

The following examples show how to use com.rometools.rome.feed.rss.Channel#setDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RssChannelHttpMessageConverterTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void writeOtherCharset() throws IOException, SAXException {
	Channel channel = new Channel("rss_2.0");
	channel.setTitle("title");
	channel.setLink("http://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);

	assertEquals("Invalid content-type", new MediaType("application", "rss+xml", Charset.forName(encoding)),
			outputMessage.getHeaders().getContentType());
}
 
Example 2
Source File: ArticleRssController.java    From tutorials with MIT License 6 votes vote down vote up
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;
}
 
Example 3
Source File: HotArticleRssContentView.java    From kaif with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model,
    Channel feed,
    HttpServletRequest request) {
  ZoneInfo zoneInfo = (ZoneInfo) model.get("zoneInfo");
  @SuppressWarnings("unchecked")
  List<Article> articles = (List<Article>) model.get("articles");
  if (zoneInfo != null) {
    feed.setTitle(zoneInfo.getName() + " kaif.io");
    feed.setLink(zoneUrl(zoneInfo.getZone()));
    feed.setDescription(zoneInfo.getAliasName() + " 熱門");
    feed.setPubDate(buildFeedUpdateTime(articles, zoneInfo.getCreateTime()));
  } else {
    feed.setTitle("熱門 kaif.io");
    feed.setLink(SCHEME_AND_HOST);
    feed.setDescription("綜合熱門");
    feed.setPubDate(buildFeedUpdateTime(articles, DEFAULT_INSTANT));
  }
}
 
Example 4
Source File: RssChannelHttpMessageConverterTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void writeOtherCharset() throws IOException, SAXException {
	Channel channel = new Channel("rss_2.0");
	channel.setTitle("title");
	channel.setLink("http://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);

	assertEquals("Invalid content-type", new MediaType("application", "rss+xml", Charset.forName(encoding)),
			outputMessage.getHeaders().getContentType());
}
 
Example 5
Source File: MessageConvertersController.java    From spring-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@RequestMapping(value = "/rss", method = RequestMethod.GET)
public @ResponseBody
Channel writeChannel() {
	Channel channel = new Channel();
	channel.setFeedType("rss_2.0");
	channel.setTitle("My RSS feed");
	channel.setDescription("Description");
	channel.setLink("http://localhost:8080/mvc-showcase/rss");
	return channel;
}
 
Example 6
Source File: ConverterForRSS090.java    From rome with Apache License 2.0 5 votes vote down vote up
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
    final Channel channel = new Channel(type);
    channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
    channel.setStyleSheet(syndFeed.getStyleSheet());
    channel.setEncoding(syndFeed.getEncoding());

    channel.setTitle(syndFeed.getTitle());
    final String link = syndFeed.getLink();
    final List<SyndLink> links = syndFeed.getLinks();
    if (link != null) {
        channel.setLink(link);
    } else if (!links.isEmpty()) {
        channel.setLink(links.get(0).getHref());
    }

    channel.setDescription(syndFeed.getDescription());

    final SyndImage sImage = syndFeed.getImage();
    if (sImage != null) {
        channel.setImage(createRSSImage(sImage));
    }

    final List<SyndEntry> sEntries = syndFeed.getEntries();
    if (sEntries != null) {
        channel.setItems(createRSSItems(sEntries));
    }

    final List<Element> foreignMarkup = syndFeed.getForeignMarkup();
    if (!foreignMarkup.isEmpty()) {
        channel.setForeignMarkup(foreignMarkup);
    }

    return channel;
}
 
Example 7
Source File: DocumentRssFeedView.java    From jakduk-api with MIT License 5 votes vote down vote up
/**
 * Create a new Channel instance to hold the entries.
 * <p>By default returns an RSS 2.0 channel, but the subclass can specify any channel.
 */
@Override protected Channel newFeed() {
	Channel channel = new Channel("rss_2.0");
	channel.setLink(String.format("%s/%s", jakdukProperties.getWebServerUrl(), "/rss"));
	channel.setTitle(JakdukUtils.getMessageSource("common.jakduk"));
	channel.setDescription(JakdukUtils.getMessageSource("common.jakduk.rss.description"));

	return channel;
}
 
Example 8
Source File: BasicPodfeedService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This puts the pieces together to generate the actual feed.
 * 
 * @param title
 *            The global title for the podcast
 * @param link
 *            The URL for the feed
 * @param description_loc
 *            Global description of the feed
 * @param copyright
 *            Copyright information
 * @param entries
 *            The list of individual podcasts
 * @param feedTyle
 * 			 The output feed type (for potential future development). Set to rss_2.0
 * @param pubDate
 * 			 The date to set the publish date for this feed
 * 
 * @eturn SyndFeed
 * 			The entire podcast stuffed into a SyndFeed object
 */
private Channel doSyndication(Map feedInfo, List entries,
		String feedType, Date pubDate, Date lastBuildDate) {

	final Channel channel = new Channel();

	// FUTURE: How to determine what podcatcher supports and feed that to them
	channel.setFeedType(feedType);
	channel.setTitle((String) feedInfo.get("title"));
	channel.setLanguage(LANGUAGE);

	channel.setPubDate(pubDate);
	channel.setLastBuildDate(lastBuildDate);

	channel.setLink((String) feedInfo.get("url"));
	channel.setDescription((String) feedInfo.get("desc"));		
	channel.setCopyright((String) feedInfo.get("copyright"));
	channel.setGenerator((String) feedInfo.get("gen"));

	channel.setItems(entries);

	// Used to remove the dc: tags from the channel level info
	List modules = new ArrayList();
	
	channel.setModules(modules);

	return channel;
}
 
Example 9
Source File: RssFeedView.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Override
protected void buildFeedMetadata(
		Map<String, Object> model, 
		Channel feed,
		HttpServletRequest request) {
	Blog blog = blogService.getBlogById(Blog.DEFAULT_ID);
	String language = LocaleContextHolder.getLocale().getLanguage();

	feed.setTitle(blog.getTitle(language));
	feed.setDescription(blog.getTitle(language));

	UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentContextPath();
	feed.setLink(builder.buildAndExpand().toUriString());
}
 
Example 10
Source File: BasicPodfeedService.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This puts the pieces together to generate the actual feed.
 * 
 * @param title
 *            The global title for the podcast
 * @param link
 *            The URL for the feed
 * @param description_loc
 *            Global description of the feed
 * @param copyright
 *            Copyright information
 * @param entries
 *            The list of individual podcasts
 * @param feedTyle
 * 			 The output feed type (for potential future development). Set to rss_2.0
 * @param pubDate
 * 			 The date to set the publish date for this feed
 * 
 * @eturn SyndFeed
 * 			The entire podcast stuffed into a SyndFeed object
 */
private Channel doSyndication(Map feedInfo, List entries,
		String feedType, Date pubDate, Date lastBuildDate) {

	final Channel channel = new Channel();

	// FUTURE: How to determine what podcatcher supports and feed that to them
	channel.setFeedType(feedType);
	channel.setTitle((String) feedInfo.get("title"));
	channel.setLanguage(LANGUAGE);

	channel.setPubDate(pubDate);
	channel.setLastBuildDate(lastBuildDate);

	channel.setLink((String) feedInfo.get("url"));
	channel.setDescription((String) feedInfo.get("desc"));		
	channel.setCopyright((String) feedInfo.get("copyright"));
	channel.setGenerator((String) feedInfo.get("gen"));

	channel.setItems(entries);

	// Used to remove the dc: tags from the channel level info
	List modules = new ArrayList();
	
	channel.setModules(modules);

	return channel;
}
 
Example 11
Source File: RssChannelHttpMessageConverterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void write() throws IOException, SAXException {
	Channel channel = new Channel("rss_2.0");
	channel.setTitle("title");
	channel.setLink("http://example.com");
	channel.setDescription("description");

	Item item1 = new Item();
	item1.setTitle("title1");

	Item item2 = new Item();
	item2.setTitle("title2");

	List<Item> items = new ArrayList<Item>(2);
	items.add(item1);
	items.add(item2);
	channel.setItems(items);

	MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
	converter.write(channel, null, outputMessage);

	assertEquals("Invalid content-type", new MediaType("application", "rss+xml", utf8),
			outputMessage.getHeaders().getContentType());
	String expected = "<rss version=\"2.0\">" +
			"<channel><title>title</title><link>http://example.com</link><description>description</description>" +
			"<item><title>title1</title></item>" +
			"<item><title>title2</title></item>" +
			"</channel></rss>";
	assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
}
 
Example 12
Source File: RssChannelHttpMessageConverterTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void write() throws IOException, SAXException {
	Channel channel = new Channel("rss_2.0");
	channel.setTitle("title");
	channel.setLink("http://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);

	assertEquals("Invalid content-type", new MediaType("application", "rss+xml", StandardCharsets.UTF_8),
			outputMessage.getHeaders().getContentType());
	String expected = "<rss version=\"2.0\">" +
			"<channel><title>title</title><link>http://example.com</link><description>description</description>" +
			"<item><title>title1</title></item>" +
			"<item><title>title2</title></item>" +
			"</channel></rss>";
	assertThat(outputMessage.getBodyAsString(StandardCharsets.UTF_8), isSimilarTo(expected));
}
 
Example 13
Source File: ArticleFeedView.java    From tutorials with MIT License 5 votes vote down vote up
protected Channel newFeed() {
    Channel channel = new Channel("rss_2.0");
    channel.setLink("http://localhost:8080/rss");
    channel.setTitle("Article Feed");
    channel.setDescription("Article Feed Description");
    channel.setPubDate(new Date());
    return channel;
}
 
Example 14
Source File: RssChannelHttpMessageConverterTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void write() throws IOException, SAXException {
	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);

	assertEquals("Invalid content-type", new MediaType("application", "rss+xml", StandardCharsets.UTF_8),
			outputMessage.getHeaders().getContentType());
	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(outputMessage.getBodyAsString(StandardCharsets.UTF_8), isSimilarTo(expected));
}
 
Example 15
Source File: RssFeedViewTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel channel, HttpServletRequest request) {
	channel.setTitle("Test Feed");
	channel.setDescription("Test feed description");
	channel.setLink("https://example.com");
}
 
Example 16
Source File: RssFeedViewTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected void buildFeedMetadata(Map model, Channel channel, HttpServletRequest request) {
	channel.setTitle("Test Feed");
	channel.setDescription("Test feed description");
	channel.setLink("http://example.com");
}
 
Example 17
Source File: FoundEpisodesRssFeedView.java    From podcastpedia-web with MIT License 4 votes vote down vote up
protected void buildFeedMetadata(Map model, Channel feed, HttpServletRequest request) {
    feed.setTitle("" + model.get("feed_title"));
    feed.setDescription(" " + model.get("feed_description"));
    feed.setLink("" + model.get("feed_link"));
}
 
Example 18
Source File: GenericRssFeedView.java    From podcastpedia-web with MIT License 4 votes vote down vote up
protected void buildFeedMetadata(Map model, Channel feed, HttpServletRequest request) {
    feed.setTitle("" + model.get("feed_title"));
    feed.setDescription(" " + model.get("feed_description"));
    feed.setLink("" + model.get("feed_link"));
}
 
Example 19
Source File: FoundPodcastsRssFeedView.java    From podcastpedia-web with MIT License 4 votes vote down vote up
protected void buildFeedMetadata(Map model, Channel feed, HttpServletRequest request) {
    feed.setTitle("" + model.get("feed_title"));
    feed.setDescription(" " + model.get("feed_description"));
    feed.setLink("" + model.get("feed_link"));
}
 
Example 20
Source File: RssFeedView.java    From tutorials with MIT License 4 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel feed, HttpServletRequest request) {
	feed.setTitle("Baeldung RSS Feed");
	feed.setDescription("Learn how to program in Java");
	feed.setLink("http://www.baeldung.com");
}