com.rometools.rome.feed.synd.SyndContentImpl Java Examples

The following examples show how to use com.rometools.rome.feed.synd.SyndContentImpl. 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: Entry.java    From commafeed with Apache License 2.0 6 votes vote down vote up
public SyndEntry asRss() {
	SyndEntry entry = new SyndEntryImpl();

	entry.setUri(getGuid());
	entry.setTitle(getTitle());
	entry.setAuthor(getAuthor());

	SyndContentImpl content = new SyndContentImpl();
	content.setValue(getContent());
	entry.setContents(Arrays.<SyndContent> asList(content));

	if (getEnclosureUrl() != null) {
		SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
		enclosure.setType(getEnclosureType());
		enclosure.setUrl(getEnclosureUrl());
		entry.setEnclosures(Arrays.<SyndEnclosure> asList(enclosure));
	}

	entry.setLink(getUrl());
	entry.setPublishedDate(getDate());
	return entry;
}
 
Example #2
Source File: SyndicationServlet.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void writeRevisionsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws IOException, FeedException, ServiceException, PublicInterfaceNotFoundException {
	long poid = Long.parseLong(request.getParameter("poid"));
	SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);

	SyndFeed feed = new SyndFeedImpl();
	feed.setFeedType(FEED_TYPE);

	feed.setTitle("BIMserver.org revisions feed for project '" + sProject.getName() + "'");
	feed.setLink(request.getContextPath());
	feed.setDescription("This feed represents all the revisions of project '" + sProject.getName() + "'");

	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	try {
		List<SRevision> allRevisionsOfProject = serviceMap.getServiceInterface().getAllRevisionsOfProject(poid);
		Collections.sort(allRevisionsOfProject, new SRevisionIdComparator(false));
		for (SRevision sVirtualRevision : allRevisionsOfProject) {
			SUser user = serviceMap.getServiceInterface().getUserByUoid(sVirtualRevision.getUserId());
			SyndEntry entry = new SyndEntryImpl();
			entry.setTitle("Revision " + sVirtualRevision.getOid());
			entry.setLink(request.getContextPath() + "/revision.jsp?poid=" + sVirtualRevision.getOid() + "&roid=" + sVirtualRevision.getOid());
			entry.setPublishedDate(sVirtualRevision.getDate());
			SyndContent description = new SyndContentImpl();
			description.setType("text/html");
			description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Comment</td><td>" + sVirtualRevision.getComment()
					+ "</td></tr></table>");
			entry.setDescription(description);
			entries.add(entry);
		}
	} catch (ServiceException e) {
		LOGGER.error("", e);
	}
	feed.setEntries(entries);
	SyndFeedOutput output = new SyndFeedOutput();
	output.output(feed, response.getWriter());
}
 
Example #3
Source File: SyndicationServlet.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException {
	long poid = Long.parseLong(request.getParameter("poid"));
	SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);

	SyndFeed feed = new SyndFeedImpl();
	feed.setFeedType(FEED_TYPE);

	feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'");
	feed.setLink(request.getContextPath());
	feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");

	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	try {
		List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
		for (SCheckout sCheckout : allCheckoutsOfProject) {
			SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
			SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
			SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
			SyndEntry entry = new SyndEntryImpl();
			entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
			entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
			entry.setPublishedDate(sCheckout.getDate());
			SyndContent description = new SyndContentImpl();
			description.setType("text/plain");
			description
					.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
			entry.setDescription(description);
			entries.add(entry);
		}
	} catch (UserException e) {
		LOGGER.error("", e);
	}
	feed.setEntries(entries);
	SyndFeedOutput output = new SyndFeedOutput();
	output.output(feed, response.getWriter());
}
 
Example #4
Source File: ConverterForRSS10.java    From rome with Apache License 2.0 5 votes vote down vote up
@Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {

    final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);

    final Description desc = item.getDescription();
    if (desc != null) {
        final SyndContent descContent = new SyndContentImpl();
        descContent.setType(desc.getType());
        descContent.setValue(desc.getValue());
        syndEntry.setDescription(descContent);
    }

    final Content cont = item.getContent();
    if (cont != null) {

        final SyndContent contContent = new SyndContentImpl();
        contContent.setType(cont.getType());
        contContent.setValue(cont.getValue());

        final List<SyndContent> contents = new ArrayList<SyndContent>();
        contents.add(contContent);
        syndEntry.setContents(contents);

    }

    return syndEntry;

}
 
Example #5
Source File: ConverterForRSS091Userland.java    From rome with Apache License 2.0 5 votes vote down vote up
@Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {

    final SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);

    final Description desc = item.getDescription();

    syndEntry.setComments(item.getComments());

    // DublinCoreTest will be failed without this row
    // I don't have better solution
    if (syndEntry.getPublishedDate() == null)
        syndEntry.setPublishedDate(item.getPubDate());

    if (desc != null) {
        final SyndContent descContent = new SyndContentImpl();
        descContent.setType(desc.getType());
        descContent.setValue(desc.getValue());
        syndEntry.setDescription(descContent);
    }

    final Content cont = item.getContent();

    if (cont != null) {
        final SyndContent content = new SyndContentImpl();
        content.setType(cont.getType());
        content.setValue(cont.getValue());

        final List<SyndContent> syndContents = new ArrayList<SyndContent>();
        syndContents.add(content);
        syndEntry.setContents(syndContents);
    }

    return syndEntry;
}
 
Example #6
Source File: RSSFeedServlet.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private SyndEntry createFeedEntry(String title, String content, int index) {
    SyndEntry entry = new SyndEntryImpl();
    entry.setTitle(title + index);
    entry.setLink("http://localhost:8080/rss-tests/" + index);
    entry.setPublishedDate(new Date());

    SyndContent description = new SyndContentImpl();
    description.setType("text/plain");
    description.setValue(content + index);
    entry.setDescription(description);
    return entry;
}
 
Example #7
Source File: RSS090DescriptionConverter.java    From commafeed with Apache License 2.0 5 votes vote down vote up
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
	SyndEntry entry = super.createSyndEntry(item, preserveWireItem);
	Description desc = item.getDescription();
	if (desc != null) {
		SyndContentImpl syndDesc = new SyndContentImpl();
		syndDesc.setValue(desc.getValue());
		entry.setDescription(syndDesc);
	}
	return entry;
}
 
Example #8
Source File: ConverterForAtom10.java    From rome with Apache License 2.0 4 votes vote down vote up
protected SyndContent createSyndContent(final Content content) {
    final SyndContent sContent = new SyndContentImpl();
    sContent.setType(content.getType());
    sContent.setValue(content.getValue());
    return sContent;
}