Search code examples
servletsaemjcrsling

How to hide page from siteadmin in AEM?


I have a Sling Servlet with resourceType="this/is/a/test".

@SlingServlet(methods = { "GET" })
@Properties({ @Property(name = "service.pid", value = "com.test.TestServlet", propertyPrivate = false),
    @Property(name = "sling.servlet.resourceTypes", value = {"this/is/a/test"})})
public class TestServlet extends SlingSafeMethodsServlet {

I have an MSM structure with brand and locale in blueprint.

    SampleBlueprint
        Organization One
            en_US
               Home Page
               Contact US
               bin
                  test-servlet

   SampleLiveCopies
        Organization One
           America
              en_US
                 Home Page
                 Contact US
                 bin
                    test-servlet
              fr_US
                 Home Page
                 Contact US
                 bin
                    test-servlet
           Canada
              en_CA
                 Home Page
                 Contact US
                 bin
                    test-servlet

The test-servlet has sling:resourceType="this/is/a/test".

In the servlet I am utilizing the path to determine the response. Ex: If path is /content/SampleLiveCopies/OrganizationOne/America/en_US/bin/test-servlet I would return data which is America related in English language.

But as Page "bin/test-servlet" is visible in siteadmin, author has the control to edit it.

Hence I want to hide the bin/test-servlet page in siteadmin.


Solution

  • When you want to hide page - you use property hidden with value true on jcr:content of the page. I bet, there would be similar approach. Give it a try.