use of org.intabulas.sandler.elements.Feed in project jspwiki by apache.
the class AtomAPIServlet method doGet.
/**
* Handles HTTP GET. However, we do not respond to GET requests,
* other than to show an explanatory text.
*
* {@inheritDoc}
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
log.debug("Received HTTP GET to AtomAPIServlet");
String blogid = getPageName(request);
log.debug("Requested page " + blogid);
try {
if (blogid == null) {
Feed feed = listBlogs();
response.setContentType("application/x.atom+xml; charset=UTF-8");
response.getWriter().println(Sandler.marshallFeed(feed));
response.getWriter().flush();
} else {
Entry entry = getBlogEntry(blogid);
response.setContentType("application/x.atom+xml; charset=UTF-8");
response.getWriter().println(Sandler.marshallEntry(entry));
response.getWriter().flush();
}
} catch (Exception e) {
log.error("Unable to generate response", e);
throw new ServletException("Internal problem - whack Janne on the head to get a better error report", e);
}
}
use of org.intabulas.sandler.elements.Feed in project jspwiki by apache.
the class AtomAPIServlet method listBlogs.
/**
* Creates and outputs a full list of all available blogs
*/
private Feed listBlogs() throws ProviderException, IOException {
Collection pages = m_engine.getPageManager().getAllPages();
Feed feed = SyndicationFactory.newSyndicationFeed();
feed.setTitle("List of blogs at this site");
feed.setModified(new Date());
for (Iterator i = pages.iterator(); i.hasNext(); ) {
WikiPage p = (WikiPage) i.next();
//
// List only weblogs
// FIXME: Unfortunately, a weblog is not known until it has
// been executed once, because plugins are off during
// the initial startup phase.
//
log.debug(p.getName() + " = " + p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG));
if (!("true".equals(p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG))))
continue;
String encodedName = TextUtil.urlEncodeUTF8(p.getName());
WikiContext context = new WikiContext(m_engine, p);
String title = TextUtil.replaceEntities(org.apache.wiki.rss.Feed.getSiteName(context));
Link postlink = createLink("service.post", m_engine.getBaseURL() + "atom/" + encodedName, title);
Link editlink = createLink("service.edit", m_engine.getBaseURL() + "atom/" + encodedName, title);
Link feedlink = createLink("service.feed", m_engine.getBaseURL() + "atom.jsp?page=" + encodedName, title);
feed.addLink(postlink);
feed.addLink(feedlink);
feed.addLink(editlink);
}
return feed;
}
Aggregations