Java Code Examples for com.rometools.rome.feed.rss.Item#setPubDate()

The following examples show how to use com.rometools.rome.feed.rss.Item#setPubDate() . 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: HrmsRssViewBuilder.java    From Spring-MVC-Blueprints with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<Item> buildFeedItems(Map<String, Object> model,
		HttpServletRequest req, HttpServletResponse resp) throws Exception {
	
	// get data model which is passed by the Spring container
	List<HrmsNews> news = (List<HrmsNews>) model.get("allNews");
       List<Item> items = new ArrayList<Item>(news.size());
 	
	for(HrmsNews topic : news ){
	
		Item item = new Item();
		
		Content content = new Content();
		content.setValue(topic.getSummary());
		item.setContent(content);
		
		item.setTitle(topic.getDescription());
		item.setLink(topic.getLink());
		item.setPubDate(new Date());
		
		items.add(item);
	}
	
	return items;
}
 
Example 2
Source File: FoundPodcastsRssFeedView.java    From podcastpedia-web with MIT License 6 votes vote down vote up
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    	
        List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts");
        List<Item> items = new ArrayList<Item>(podcasts.size());

        for (Podcast podcast : podcasts) {
            Item item = new Item();
//            String date = String.format("%1$tY-%1$tm-%1$td", podcast.getLastEpisode().getPublicationDate());
            item.setTitle(podcast.getTitle());
            item.setPubDate(podcast.getPublicationDate());
            item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId() 
            		+ "/" + podcast.getTitleInUrl());
            
            Description podcastDescription = new Description();
            podcastDescription.setValue(podcast.getDescription());
            item.setDescription(podcastDescription);  
                        
            items.add(item);
        }

        return items;
    }
 
Example 3
Source File: RssFeedView.java    From wallride with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<Item> buildFeedItems(
		Map<String, Object> model,
		HttpServletRequest request,
		HttpServletResponse response)
throws Exception {
	Set<Article> articles = (Set<Article>)model.get("articles");
	List<Item> items = new ArrayList<>(articles.size());
	for (Article article : articles) {
		Item item = new Item();
		item.setTitle(article.getTitle());
		item.setPubDate(Date.from(article.getDate().atZone(ZoneId.systemDefault()).toInstant()));
		Description description = new Description();
		description.setType("text/html");
		description.setValue(article.getBody());
		item.setDescription(description);
		item.setLink(link(article));
		items.add(item);
	}
	return items;
}
 
Example 4
Source File: RSS093Parser.java    From rome with Apache License 2.0 6 votes vote down vote up
@Override
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {

    final Item item = super.parseItem(rssRoot, eItem, locale);

    final Element pubDate = eItem.getChild("pubDate", getRSSNamespace());
    if (pubDate != null) {
        item.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
    }

    final Element expirationDate = eItem.getChild("expirationDate", getRSSNamespace());
    if (expirationDate != null) {
        item.setExpirationDate(DateParser.parseDate(expirationDate.getText(), locale));
    }

    final Element description = eItem.getChild("description", getRSSNamespace());
    if (description != null) {
        final String type = description.getAttributeValue("type");
        if (type != null) {
            item.getDescription().setType(type);
        }
    }

    return item;

}
 
Example 5
Source File: ArticleFeedView.java    From tutorials with MIT License 6 votes vote down vote up
@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;
}
 
Example 6
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 7
Source File: ArticleFeedView.java    From tutorials with MIT License 6 votes vote down vote up
@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;
}
 
Example 8
Source File: HotArticleRssContentView.java    From kaif with Apache License 2.0 5 votes vote down vote up
private Item convertArticle(Article article) {
  Item entry = new Item();
  Guid guid = new Guid();
  guid.setValue(article.getArticleId().toString());
  entry.setGuid(guid);
  entry.setTitle(cleanXml10Characters(article.getTitle()));
  entry.setPubDate(Date.from(article.getCreateTime()));
  Description summary = new Description();
  summary.setType("html");
  summary.setValue(buildSummary(article));
  entry.setDescription(summary);
  entry.setLink(articleUrl(article));
  return entry;
}
 
Example 9
Source File: FoundEpisodesRssFeedView.java    From podcastpedia-web with MIT License 5 votes vote down vote up
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
    throws Exception {
	
    List<Episode> episodes = (List<Episode>) model.get("list_of_episodes");
    List<Item> items = new ArrayList<Item>(episodes.size());

    for (Episode episode : episodes) {
        Item item = new Item();
        String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate());
        item.setTitle(episode.getTitle());
        item.setPubDate(episode.getPublicationDate());
        item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + episode.getPodcastId() 
        		+ "/" + episode.getPodcast().getTitleInUrl()+ "/episodes/" + episode.getEpisodeId()
        		+ "/" + episode.getTitleInUrl());
        
        Description episodeDescription = new Description();
        episodeDescription.setValue(episode.getDescription());
        item.setDescription(episodeDescription);  
        
        //set enclosures
        List<Enclosure> enclosures = new ArrayList<Enclosure>();
        Enclosure enclosure = new Enclosure();
        enclosure.setUrl(episode.getMediaUrl());
        if(episode.getLength() != null) enclosure.setLength(episode.getLength());
        if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType()); 
        enclosures.add(enclosure);
        item.setEnclosures(enclosures);
        
        items.add(item);
    }

    return items;
}
 
Example 10
Source File: GenericRssFeedView.java    From podcastpedia-web with MIT License 5 votes vote down vote up
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
    throws Exception {
	
    List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts");
    List<Item> items = new ArrayList<Item>(podcasts.size());

    for (Podcast podcast : podcasts) {
        Episode episode = podcast.getLastEpisode();
        Item item = new Item();
        String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate());
        item.setTitle(podcast.getTitle()+ " - " + episode.getTitle());
        item.setPubDate(podcast.getPublicationDate());
        item.setLink( model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId() 
        		+ "/" + podcast.getTitleInUrl() );
        
        Description episodeDescription = new Description();
        episodeDescription.setValue(episode.getDescription());
        item.setDescription(episodeDescription);  
        
        //set enclosures
        List<Enclosure> enclosures = new ArrayList<Enclosure>();
        Enclosure enclosure = new Enclosure();
        enclosure.setUrl(episode.getMediaUrl());    
        if(episode.getLength() != null) enclosure.setLength(episode.getLength());
        if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType());             
        enclosures.add(enclosure);
        item.setEnclosures(enclosures);
        
        items.add(item);
    }

    return items;
}
 
Example 11
Source File: BasicPodfeedService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * This add a particular podcast to the feed.
 * 
 * @param title
 *            The title for this podcast
 * @param mp3link
 *            The URL where the podcast is stored
 * @param date
 *            The publish date for this podcast
 * @param blogContent
 *            The description of this podcast
 * @param cat
 *            The category of entry this is (Podcast)
 * @param author
 *            The author of this podcast
 * 
 * @return 
 * 			 A SyndEntryImpl for this podcast
 */
private Item addPodcast(Map values) 
{
	final Item item = new Item();

	// set title for this podcast
	item.setTitle((String) values.get("title"));

       // Replace all occurrences of pattern (ie, spaces) in input
       // with hex equivalent (%20)
       Pattern pattern = Pattern.compile(" ");
       String url = (String) values.get("url");
       Matcher matcher = pattern.matcher(url);
       url = matcher.replaceAll("%20");
       item.setLink(url);

       // Set Publish date for this podcast/episode
       // NOTE: date has local time, but when feed rendered,
       // converts it to GMT
	item.setPubDate((Date) values.get("date"));

	// Set description for this podcast/episode
	final Description itemDescription = new Description();
	itemDescription.setType(DESCRIPTION_CONTENT_TYPE);
	itemDescription.setValue((String) values.get("description"));
	item.setDescription(itemDescription);

	// Set guid for this podcast/episode
	item.setGuid(new Guid());
	item.getGuid().setValue((String) values.get("guid"));
	item.getGuid().setPermaLink(false);

	// This creates the enclosure so podcatchers (iTunes) can
	// find the podcasts		
	List enclosures = new ArrayList();

	final Enclosure enc = new Enclosure();
	enc.setUrl(url);
	enc.setType((String) values.get("type"));
	enc.setLength((Long) values.get("len"));

	enclosures.add(enc);

	item.setEnclosures(enclosures);

	// Currently uses 2 modules:
	//  iTunes for podcasting
	//  DCmodule since validators want email with author tag, 
	//    so use dc:creator instead
	List modules = new ArrayList();
	
	// Generate the iTunes tags
	final EntryInformation iTunesModule = new EntryInformationImpl();

	iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING));
	iTunesModule.setSummary((String) values.get("description"));

	// Set dc:creator tag
	final DCModuleImpl dcModule = new DCModuleImpl();
	
	dcModule.setCreator((String) values.get("author"));
	
	modules.add(iTunesModule);
	modules.add(dcModule);
	
	item.setModules(modules);
	
	return item;
}
 
Example 12
Source File: BasicPodfeedService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * This add a particular podcast to the feed.
 * 
 * @param title
 *            The title for this podcast
 * @param mp3link
 *            The URL where the podcast is stored
 * @param date
 *            The publish date for this podcast
 * @param blogContent
 *            The description of this podcast
 * @param cat
 *            The category of entry this is (Podcast)
 * @param author
 *            The author of this podcast
 * 
 * @return 
 * 			 A SyndEntryImpl for this podcast
 */
private Item addPodcast(Map values) 
{
	final Item item = new Item();

	// set title for this podcast
	item.setTitle((String) values.get("title"));

       // Replace all occurrences of pattern (ie, spaces) in input
       // with hex equivalent (%20)
       Pattern pattern = Pattern.compile(" ");
       String url = (String) values.get("url");
       Matcher matcher = pattern.matcher(url);
       url = matcher.replaceAll("%20");
       item.setLink(url);

       // Set Publish date for this podcast/episode
       // NOTE: date has local time, but when feed rendered,
       // converts it to GMT
	item.setPubDate((Date) values.get("date"));

	// Set description for this podcast/episode
	final Description itemDescription = new Description();
	itemDescription.setType(DESCRIPTION_CONTENT_TYPE);
	itemDescription.setValue((String) values.get("description"));
	item.setDescription(itemDescription);

	// Set guid for this podcast/episode
	item.setGuid(new Guid());
	item.getGuid().setValue((String) values.get("guid"));
	item.getGuid().setPermaLink(false);

	// This creates the enclosure so podcatchers (iTunes) can
	// find the podcasts		
	List enclosures = new ArrayList();

	final Enclosure enc = new Enclosure();
	enc.setUrl(url);
	enc.setType((String) values.get("type"));
	enc.setLength((Long) values.get("len"));

	enclosures.add(enc);

	item.setEnclosures(enclosures);

	// Currently uses 2 modules:
	//  iTunes for podcasting
	//  DCmodule since validators want email with author tag, 
	//    so use dc:creator instead
	List modules = new ArrayList();
	
	// Generate the iTunes tags
	final EntryInformation iTunesModule = new EntryInformationImpl();

	iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING));
	iTunesModule.setSummary((String) values.get("description"));

	// Set dc:creator tag
	final DCModuleImpl dcModule = new DCModuleImpl();
	
	dcModule.setCreator((String) values.get("author"));
	
	modules.add(iTunesModule);
	modules.add(dcModule);
	
	item.setModules(modules);
	
	return item;
}
 
Example 13
Source File: ConverterForRSS093.java    From rome with Apache License 2.0 4 votes vote down vote up
@Override
protected Item createRSSItem(final SyndEntry sEntry) {
    final Item item = super.createRSSItem(sEntry);
    item.setPubDate(sEntry.getPublishedDate()); // c
    return item;
}
 
Example 14
Source File: RssFeedView.java    From tutorials with MIT License 4 votes vote down vote up
@Override
protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request,
		HttpServletResponse response) {

	// Builds the single entries.
	Item entryOne = new Item();
	entryOne.setTitle("JUnit 5 @Test Annotation");
	entryOne.setAuthor("[email protected]");
	entryOne.setLink("http://www.baeldung.com/junit-5-test-annotation");
	entryOne.setPubDate(Date.from(Instant.parse("2017-12-19T00:00:00Z")));

	Item entryTwo = new Item();
	entryTwo.setTitle("Creating and Configuring Jetty 9 Server in Java");
	entryTwo.setAuthor("[email protected]");
	entryTwo.setLink("http://www.baeldung.com/jetty-java-programmatic");
	entryTwo.setPubDate(Date.from(Instant.parse("2018-01-23T00:00:00Z")));

	Item entryThree = new Item();
	entryThree.setTitle("Flyweight Pattern in Java");
	entryThree.setAuthor("[email protected]");
	entryThree.setLink("http://www.baeldung.com/java-flyweight");
	entryThree.setPubDate(Date.from(Instant.parse("2018-02-01T00:00:00Z")));

	Item entryFour = new Item();
	entryFour.setTitle("Multi-Swarm Optimization Algorithm in Java");
	entryFour.setAuthor("[email protected]");
	entryFour.setLink("http://www.baeldung.com/java-multi-swarm-algorithm");
	entryFour.setPubDate(Date.from(Instant.parse("2018-03-09T00:00:00Z")));

	Item entryFive = new Item();
	entryFive.setTitle("A Simple Tagging Implementation with MongoDB");
	entryFive.setAuthor("[email protected]");
	entryFive.setLink("http://www.baeldung.com/mongodb-tagging");
	entryFive.setPubDate(Date.from(Instant.parse("2018-03-27T00:00:00Z")));

	Item entrySix = new Item();
	entrySix.setTitle("Double-Checked Locking with Singleton");
	entrySix.setAuthor("[email protected]");
	entrySix.setLink("http://www.baeldung.com/java-singleton-double-checked-locking");
	entrySix.setPubDate(Date.from(Instant.parse("2018-04-23T00:00:00Z")));

	Item entrySeven = new Item();
	entrySeven.setTitle("Introduction to Dagger 2");
	entrySeven.setAuthor("[email protected]");
	entrySeven.setLink("http://www.baeldung.com/dagger-2");
	entrySeven.setPubDate(Date.from(Instant.parse("2018-06-30T00:00:00Z")));

	// Creates the feed.
	return Arrays.asList(entryOne, entryTwo, entryThree, entryFour, entryFive, entrySix, entrySeven);
}