org.apache.sling.jcr.jackrabbit.accessmanager.post
Class AbstractAccessPostServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by org.apache.sling.api.servlets.SlingSafeMethodsServlet
          extended by org.apache.sling.api.servlets.SlingAllMethodsServlet
              extended by org.apache.sling.jcr.jackrabbit.accessmanager.post.AbstractAccessPostServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
DeleteAcesServlet, ModifyAceServlet

public abstract class AbstractAccessPostServlet
extends SlingAllMethodsServlet

Base class for all the POST servlets for the AccessManager operations

See Also:
Serialized Form

Constructor Summary
AbstractAccessPostServlet()
           
 
Method Summary
protected  HtmlResponse createHtmlResponse(SlingHttpServletRequest req)
          Creates an instance of a HtmlResponse.
protected  void doPost(SlingHttpServletRequest request, SlingHttpServletResponse httpResponse)
          Called by the SlingAllMethodsServlet.mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to handle an HTTP POST request.
protected  String externalizePath(SlingHttpServletRequest request, String path)
          Returns an external form of the given path prepending the context path and appending a display extension.
protected  javax.jcr.security.AccessControlList getAccessControlList(javax.jcr.security.AccessControlManager accessControlManager, String resourcePath, boolean mayCreate)
          Returns an AccessControlList to edit for the node at the given resourcePath.
protected  String getItemPath(SlingHttpServletRequest request)
          Returns the path of the resource of the request as the item path.
protected  String getRedirectUrl(javax.servlet.http.HttpServletRequest request, HtmlResponse ctx)
          compute redirect URL (SLING-126)
protected abstract  void handleOperation(SlingHttpServletRequest request, HtmlResponse htmlResponse, List<Modification> changes)
          Extending Servlet should implement this operation to do the work
protected  boolean isSetStatus(SlingHttpServletRequest request)
           
 
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServlet
doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayService
 
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAccessPostServlet

public AbstractAccessPostServlet()
Method Detail

doPost

protected void doPost(SlingHttpServletRequest request,
                      SlingHttpServletResponse httpResponse)
               throws javax.servlet.ServletException,
                      IOException
Description copied from class: SlingAllMethodsServlet
Called by the SlingAllMethodsServlet.mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to handle an HTTP POST request.

This default implementation reports back to the client that the method is not supported.

Implementations of this class should overwrite this method with their implementation for the HTTP POST method support.

Overrides:
doPost in class SlingAllMethodsServlet
Parameters:
request - The HTTP request
httpResponse - The HTTP response
Throws:
javax.servlet.ServletException - Not thrown by this implementation.
IOException - If the error status cannot be reported back to the client.

createHtmlResponse

protected HtmlResponse createHtmlResponse(SlingHttpServletRequest req)
Creates an instance of a HtmlResponse.

Parameters:
req - The request being serviced
Returns:
a JSONResponse if any of these conditions are true:
  • the response content type is application/json
or a HtmlResponse otherwise

handleOperation

protected abstract void handleOperation(SlingHttpServletRequest request,
                                        HtmlResponse htmlResponse,
                                        List<Modification> changes)
                                 throws javax.jcr.RepositoryException
Extending Servlet should implement this operation to do the work

Parameters:
request - the sling http request to process
htmlResponse - the response
changes -
Throws:
javax.jcr.RepositoryException

getRedirectUrl

protected String getRedirectUrl(javax.servlet.http.HttpServletRequest request,
                                HtmlResponse ctx)
compute redirect URL (SLING-126)

Parameters:
ctx - the post processor
Returns:
the redirect location or null

isSetStatus

protected boolean isSetStatus(SlingHttpServletRequest request)

getItemPath

protected String getItemPath(SlingHttpServletRequest request)
Returns the path of the resource of the request as the item path.

This method may be overwritten by extension if the operation has different requirements on path processing.


externalizePath

protected final String externalizePath(SlingHttpServletRequest request,
                                       String path)
Returns an external form of the given path prepending the context path and appending a display extension.

Parameters:
path - the path to externalize
Returns:
the url

getAccessControlList

protected javax.jcr.security.AccessControlList getAccessControlList(javax.jcr.security.AccessControlManager accessControlManager,
                                                                    String resourcePath,
                                                                    boolean mayCreate)
                                                             throws javax.jcr.RepositoryException
Returns an AccessControlList to edit for the node at the given resourcePath.

Parameters:
accessControlManager - The manager providing access control lists
resourcePath - The node path for which to return an access control list
mayCreate - true if an access control list should be created if the node does not have one yet.
Returns:
The AccessControlList to modify to control access to the node.
Throws:
javax.jcr.RepositoryException - If the access control manager does not provide a AccessControlPolicy which is an AccessControlList.


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.