All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.causecode.seo.sitemap.SitemapController.groovy Maven / Gradle / Ivy

Go to download

nucleus is a Grails-Groovy plugin which contains utility methods, classes and endpoints.

The newest version!
package com.causecode.seo.sitemap

import grails.converters.XML
import grails.plugin.springsecurity.annotation.Secured

/**
 * Defines end point for Sitemap
 */
@Secured(['ROLE_ADMIN'])
class SitemapController {

    private static final Sitemap EMPTY_SITEMAP = new Sitemap()

    /**
     * Dependency injection for the sitemapService.
     */
    def sitemapService

    /**
     * Generate Sitemap object and redirects to dashboard.
     */
    def generate() {
        sitemapService.generate()
        redirect uri: '/dashboard'
    }

   /**
     * Default action : Responds Sitemap first object or new sitemap Object.
     * Reverting back the commit:
     * https://bitbucket.org/causecode/nucleus/commits/a4500461f761f69bcf39372d03a5b3fe58b84dce
     * Replaced respond with render, since it was adding an extra xml  element to the generated
     * sitemap.xml
     */
    @Secured(['permitAll'])
    def index() {
        render((Sitemap.first() ?: EMPTY_SITEMAP) as XML)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy