use of com.rometools.rome.feed.synd.SyndContentImpl in project BIMserver by opensourceBIM.
the class SyndicationServlet method writeCheckoutsFeed.
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());
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project BIMserver by opensourceBIM.
the class SyndicationServlet method writeProjectsFeed.
private void writeProjectsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws UserException, IOException, FeedException, PublicInterfaceNotFoundException {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(FEED_TYPE);
feed.setTitle("BIMserver.org projects feed");
feed.setLink(request.getContextPath());
feed.setDescription("This feed represents all your available projects within this BIMserver");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
List<SProject> allProjects = serviceMap.getServiceInterface().getAllProjects(false, true);
for (SProject sProject : allProjects) {
SyndEntry entry = new SyndEntryImpl();
entry.setAuthor(serviceMap.getServiceInterface().getUserByUoid(sProject.getCreatedById()).getName());
entry.setTitle(sProject.getName());
entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
entry.setPublishedDate(sProject.getCreatedDate());
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description.setValue(sProject.getDescription());
entry.setDescription(description);
entries.add(entry);
}
if (allProjects.size() == 0) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle("No projects found");
entry.setLink(request.getContextPath() + "/main.jsp");
entry.setPublishedDate(new Date());
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description.setValue("No projects found");
entry.setDescription(description);
entries.add(entry);
}
} catch (ServiceException e) {
LOGGER.error("", e);
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project blogwt by billy1380.
the class FeedServlet method getFeed.
protected SyndFeed getFeed(HttpServletRequest request) throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
String url = ServletHelper.constructBaseUrl(request);
feed.setTitle(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.TITLE).value);
feed.setLink(url + "/feed");
feed.setDescription(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.EXTENDED_TITLE).value);
List<Post> posts;
Pager pager = PagerHelper.createDefaultPager();
List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry;
SyndContent description;
MarkdownProcessor processor = new MarkdownProcessor();
do {
posts = PostServiceProvider.provide().getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
if (posts != null) {
PagerHelper.moveForward(pager);
for (Post post : posts) {
entry = new SyndEntryImpl();
entry.setTitle(post.title);
entry.setLink(url + "/#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug));
entry.setPublishedDate(post.published);
description = new SyndContentImpl();
description.setType("text/HTML");
description.setValue(processor.process(post.summary));
entry.setDescription(description);
entries.add(entry);
}
}
} while (posts != null && posts.size() >= pager.count.intValue());
feed.setEntries(entries);
return feed;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project xwiki-platform by xwiki.
the class DefaultNotificationRSSRenderer method renderNotification.
@Override
public SyndEntry renderNotification(CompositeEvent eventNotification) throws NotificationException {
SyndEntry entry = new SyndEntryImpl();
SyndContent entryDescription = new SyndContentImpl();
// The users contained in the CompositeEvent are already stored in a Set, they are therefore necessarily unique
List<SyndPerson> eventAuthors = new ArrayList<SyndPerson>();
// Convert every author of the CompositeEvent to a SyndPerson and add it to the new entry
for (DocumentReference author : eventNotification.getUsers()) {
SyndPerson person = new SyndPersonImpl();
person.setName(author.getName());
eventAuthors.add(person);
}
entry.setAuthors(eventAuthors);
// Define the GUID of the event
entry.setUri(String.join("-", eventNotification.getEventIds()));
// Set the entry title
entry.setTitle(this.contextualLocalizationManager.getTranslationPlain(eventNotification.getEvents().get(0).getTitle(), eventNotification.getEvents().get(0).getDocumentTitle()));
// Render the description (the main part) of the feed entry
try {
this.scriptContextManager.getCurrentScriptContext().setAttribute(COMPOSITE_EVENT_BUILDING_NAME, eventNotification, ScriptContext.ENGINE_SCOPE);
// Try to get a template associated with the composite event
Template template = this.templateManager.getTemplate(String.format("notification/rss/%s.vm", eventNotification.getType().replaceAll("\\/", ".")));
// If no template is found, fallback on the default one
if (template == null) {
template = this.templateManager.getTemplate("notification/rss/default.vm");
}
XDOM descriptionXDOM = this.templateManager.execute(template);
WikiPrinter printer = new DefaultWikiPrinter();
blockRenderer.render(descriptionXDOM, printer);
// Add the description to the entry
entryDescription.setType("text/html");
entryDescription.setValue(printer.toString());
entry.setDescription(entryDescription);
} catch (Exception e) {
throw new NotificationException(String.format("Unable to render the description of the event [%s].", eventNotification), e);
} finally {
this.scriptContextManager.getCurrentScriptContext().removeAttribute(COMPOSITE_EVENT_BUILDING_NAME, ScriptContext.ENGINE_SCOPE);
}
// Dates are sorted in descending order in a CompositeEvent, the first date is then the most recent one
entry.setUpdatedDate(eventNotification.getDates().get(0));
return entry;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project opencast by opencast.
the class RomeRssFeed method toRomeContent.
/**
* Converts the content to a <code>ROME</code> object.
*
* @param content
* original content
* @return <code>ROME</code> content object
*/
private SyndContent toRomeContent(Content content) {
if (content == null)
return null;
SyndContentImpl romeContent = new SyndContentImpl();
romeContent.setMode(content.getMode().toString().toLowerCase());
romeContent.setType(content.getType());
romeContent.setValue(content.getValue());
return romeContent;
}
Aggregations