Java Code Examples for com.rometools.rome.feed.rss.Description#setType()

The following examples show how to use com.rometools.rome.feed.rss.Description#setType() . 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: 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 2
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 3
Source File: DocumentRssFeedView.java    From jakduk-api with MIT License 5 votes vote down vote up
private Description createDescription(String content) {
	Description description = new Description();
	description.setType(Content.HTML);
	description.setValue(content);

	return description;
}
 
Example 4
Source File: RSS092Parser.java    From rome with Apache License 2.0 5 votes vote down vote up
@Override
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
    final Description desc = new Description();
    final StringBuilder sb = new StringBuilder();
    final XMLOutputter xmlOut = new XMLOutputter();
    for (final Content c : eDesc.getContent()) {
        switch (c.getCType()) {
            case Text:
            case CDATA:
                sb.append(c.getValue());
                break;
            case EntityRef:
                LOG.debug("Entity: {}", c.getValue());
                sb.append(c.getValue());
                break;
            case Element:
                sb.append(xmlOut.outputString((Element) c));
                break;
            default:
                // ignore
                break;
        }
    }
    desc.setValue(sb.toString());
    String att = eDesc.getAttributeValue("type");
    if (att == null) {
        att = "text/html";
    }
    desc.setType(att);
    return desc;
}
 
Example 5
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 6
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 7
Source File: ConverterForRSS10.java    From rome with Apache License 2.0 4 votes vote down vote up
protected Description createItemDescription(final SyndContent sContent) {
    final Description desc = new Description();
    desc.setValue(sContent.getValue());
    desc.setType(sContent.getType());
    return desc;
}
 
Example 8
Source File: ConverterForRSS091Userland.java    From rome with Apache License 2.0 4 votes vote down vote up
protected Description createItemDescription(final SyndContent sContent) {
    final Description desc = new Description();
    desc.setValue(sContent.getValue());
    desc.setType(sContent.getType());
    return desc;
}
 
Example 9
Source File: RSS10Parser.java    From rome with Apache License 2.0 4 votes vote down vote up
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
    final Description desc = new Description();
    desc.setType("text/plain");
    desc.setValue(eDesc.getText());
    return desc;
}