Search in sources :

Example 1 with Sitemap

use of org.b3log.solo.model.sitemap.Sitemap in project solo by b3log.

the class SitemapProcessor method sitemap.

/**
     * Returns the sitemap.
     * 
     * @param context the specified context
     */
@RequestProcessing(value = "/sitemap.xml", method = HTTPRequestMethod.GET)
public void sitemap(final HTTPRequestContext context) {
    final TextXMLRenderer renderer = new TextXMLRenderer();
    context.setRenderer(renderer);
    final Sitemap sitemap = new Sitemap();
    try {
        addArticles(sitemap);
        addNavigations(sitemap);
        addTags(sitemap);
        addArchives(sitemap);
        LOGGER.log(Level.INFO, "Generating sitemap....");
        final String content = sitemap.toString();
        LOGGER.log(Level.INFO, "Generated sitemap");
        renderer.setContent(content);
    } catch (final Exception e) {
        LOGGER.log(Level.ERROR, "Get blog article feed error", e);
        try {
            context.getResponse().sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}
Also used : Sitemap(org.b3log.solo.model.sitemap.Sitemap) TextXMLRenderer(org.b3log.latke.servlet.renderer.TextXMLRenderer) IOException(java.io.IOException) IOException(java.io.IOException) RequestProcessing(org.b3log.latke.servlet.annotation.RequestProcessing)

Aggregations

IOException (java.io.IOException)1 RequestProcessing (org.b3log.latke.servlet.annotation.RequestProcessing)1 TextXMLRenderer (org.b3log.latke.servlet.renderer.TextXMLRenderer)1 Sitemap (org.b3log.solo.model.sitemap.Sitemap)1