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

The following examples show how to use com.rometools.rome.feed.synd.SyndEntry#setPublishedDate() . 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: ConverterForRSS093.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 Date pubDate = item.getPubDate();
    final Date publishedDate = syndEntry.getPublishedDate();
    if (pubDate != null && publishedDate == null) {
        syndEntry.setPublishedDate(pubDate); // c
    }

    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;
}