org.apache.sling.jackrabbit.usermanager.post
Class AbstractAuthorizablePostServlet

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.jackrabbit.usermanager.post.AbstractAuthorizablePostServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
AbstractGroupPostServlet, AbstractUserPostServlet, DeleteAuthorizableServlet

public abstract class AbstractAuthorizablePostServlet
extends SlingAllMethodsServlet

Base class for all the POST servlets for the UserManager operations

See Also:
Serialized Form

Constructor Summary
AbstractAuthorizablePostServlet()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext context)
           
protected  java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> collectContent(SlingHttpServletRequest request, HtmlResponse response)
          Collects the properties that form the content to be written back to the repository.
protected  void deactivate(org.osgi.service.component.ComponentContext context)
           
protected  void doPost(SlingHttpServletRequest request, SlingHttpServletResponse httpResponse)
          Called by the SlingAllMethodsServlet.mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to handle an HTTP POST request.
protected  java.lang.String externalizePath(SlingHttpServletRequest request, java.lang.String path)
          Returns an external form of the given path prepending the context path and appending a display extension.
protected  java.lang.String getItemPath(SlingHttpServletRequest request)
          Returns the path of the resource of the request as the item path.
protected  java.lang.String getRedirectUrl(javax.servlet.http.HttpServletRequest request, HtmlResponse ctx)
          compute redirect URL (SLING-126)
protected abstract  void handleOperation(SlingHttpServletRequest request, HtmlResponse htmlResponse, java.util.List<Modification> changes)
          Extending Servlet should implement this operation to do the work
protected  boolean hasItemPathPrefix(java.lang.String name)
          Returns true if the name starts with either of the prefixes {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT .
protected  boolean isSetStatus(SlingHttpServletRequest request)
           
protected  void processDeletes(org.apache.jackrabbit.api.security.user.Authorizable resource, java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> reqProperties, java.util.List<Modification> changes)
          Removes all properties listed as RequestProperty.isDelete() from the authorizable.
protected  boolean requireItemPathPrefix(SlingHttpServletRequest request)
          Returns true if any of the request parameters starts with {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT .
protected  void writeContent(javax.jcr.Session session, org.apache.jackrabbit.api.security.user.Authorizable authorizable, java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> reqProperties, java.util.List<Modification> changes)
          Writes back the content
 
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

AbstractAuthorizablePostServlet

public AbstractAuthorizablePostServlet()
Method Detail

activate

protected void activate(org.osgi.service.component.ComponentContext context)

deactivate

protected void deactivate(org.osgi.service.component.ComponentContext context)

doPost

protected void doPost(SlingHttpServletRequest request,
                      SlingHttpServletResponse httpResponse)
               throws javax.servlet.ServletException,
                      java.io.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.
java.io.IOException - If the error status cannot be reported back to the client.

handleOperation

protected abstract void handleOperation(SlingHttpServletRequest request,
                                        HtmlResponse htmlResponse,
                                        java.util.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 java.lang.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)

collectContent

protected java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> collectContent(SlingHttpServletRequest request,
                                                                                                                           HtmlResponse response)
Collects the properties that form the content to be written back to the repository. NOTE: In the returned map, the key is the property name not a path.

Throws:
javax.jcr.RepositoryException - if a repository error occurs
javax.servlet.ServletException - if an internal error occurs

processDeletes

protected void processDeletes(org.apache.jackrabbit.api.security.user.Authorizable resource,
                              java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> reqProperties,
                              java.util.List<Modification> changes)
                       throws javax.jcr.RepositoryException
Removes all properties listed as RequestProperty.isDelete() from the authorizable.

Parameters:
authorizable - The org.apache.jackrabbit.api.security.user.Authorizable that should have properties deleted.
reqProperties - The map of request properties to check for properties to be removed.
response - The HtmlResponse to be updated with information on deleted properties.
Throws:
javax.jcr.RepositoryException - Is thrown if an error occurrs checking or removing properties.

writeContent

protected void writeContent(javax.jcr.Session session,
                            org.apache.jackrabbit.api.security.user.Authorizable authorizable,
                            java.util.Map<java.lang.String,org.apache.sling.jackrabbit.usermanager.post.impl.RequestProperty> reqProperties,
                            java.util.List<Modification> changes)
                     throws javax.jcr.RepositoryException
Writes back the content

Throws:
javax.jcr.RepositoryException - if a repository error occurs
javax.servlet.ServletException - if an internal error occurs

getItemPath

protected java.lang.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 java.lang.String externalizePath(SlingHttpServletRequest request,
                                                 java.lang.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

hasItemPathPrefix

protected boolean hasItemPathPrefix(java.lang.String name)
Returns true if the name starts with either of the prefixes ./, ../ and /.


requireItemPathPrefix

protected final boolean requireItemPathPrefix(SlingHttpServletRequest request)
Returns true if any of the request parameters starts with ./. In this case only parameters starting with either of the prefixes ./, ../ and / are considered as providing content to be stored. Otherwise all parameters not starting with the command prefix : are considered as parameters to be stored.



Copyright © 2007-2009. All Rights Reserved.