Java Code Examples for com.rometools.rome.feed.synd.SyndEntry#setLink()

The following examples show how to use com.rometools.rome.feed.synd.SyndEntry#setLink() . 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: ThreadingModuleTest.java    From rome with Apache License 2.0 5 votes vote down vote up
public void testGenerate() throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
    List<SyndEntry> entries = feed.getEntries();

    // create a new "root" entry that the next entry will reference to
    SyndEntry newRootEntry = new SyndEntryImpl();
    newRootEntry.setTitle("New, 2nd root entry");
    newRootEntry.setUri("tag:example.org,2005:2");
    newRootEntry.setLink("http://www.example.org/entries/2");
    entries.add(newRootEntry);

    // create a new reply entry that will reference the new root entry
    SyndEntry newReplyEntry = new SyndEntryImpl();
    newReplyEntry.setTitle("New test reply entry");
    newReplyEntry.setUri("tag:example.org,2005:2,1");

    ThreadingModule threadingModule = new ThreadingModuleImpl();
    threadingModule.setRef("tag:example.org,2005:2");
    threadingModule.setType("application/xhtml+xml");
    threadingModule.setHref("http://www.example.org/entries/2");
    threadingModule.setSource("http://example.org/entries/2");

    newReplyEntry.getModules().add(threadingModule);
    entries.add(newReplyEntry);

    File outputFile = new File("target/threading-testGenerate.xml");
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, outputFile);

    // read back in and validate
    final SyndFeed generatedFeed = getSyndFeed(outputFile);
    SyndEntry generatedReplyEntry = generatedFeed.getEntries().get(3);
    assertNotNull(generatedReplyEntry);
    ThreadingModule generatedReplyThreadingModule = (ThreadingModule) generatedReplyEntry.getModule(ThreadingModule.URI);
    assertEquals("tag:example.org,2005:2", generatedReplyThreadingModule.getRef());
    assertEquals("application/xhtml+xml", generatedReplyThreadingModule.getType());
    assertEquals("http://www.example.org/entries/2", generatedReplyThreadingModule.getHref());
    assertEquals("http://example.org/entries/2", generatedReplyThreadingModule.getSource());
}
 
Example 5
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 6
Source File: ConverterForRSS094.java    From rome with Apache License 2.0 4 votes vote down vote up
@Override
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {

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

    // adding native feed author to DC creators list
    final String author = item.getAuthor();
    if (author != null) {
        final List<String> creators = ((DCModule) syndEntry.getModule(DCModule.URI)).getCreators();
        if (!creators.contains(author)) {

            // using a set to remove duplicates
            final Set<String> s = new LinkedHashSet<String>();

            // DC creators
            s.addAll(creators);

            // feed native author
            s.add(author);

            creators.clear();
            creators.addAll(s);
        }
    }

    final Guid guid = item.getGuid();
    final String itemLink = item.getLink();
    if (guid != null) {
        final String guidValue = guid.getValue();
        syndEntry.setUri(guidValue);
        if (itemLink == null && guid.isPermaLink()) {
            syndEntry.setLink(guidValue);
        }
    } else {
        syndEntry.setUri(itemLink);
    }

    if (item.getComments() != null) {
        final SyndLinkImpl comments = new SyndLinkImpl();
        comments.setRel("comments");
        comments.setHref(item.getComments());
        comments.setType("text/html");
    }

    return syndEntry;

}