com.day.cq.commons.servlets
Class AbstractCommandServlet
java.lang.Object
javax.servlet.GenericServlet
org.apache.sling.api.servlets.SlingSafeMethodsServlet
org.apache.sling.api.servlets.SlingAllMethodsServlet
com.day.cq.commons.servlets.AbstractPredicateServlet
com.day.cq.commons.servlets.AbstractCommandServlet
- All Implemented Interfaces:
- Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- Direct Known Subclasses:
- AbstractServlet, SendNewsletterCommandServlet, TagCommandServlet, WCMCommandServlet
public abstract class AbstractCommandServlet
- extends AbstractPredicateServlet
Abstract servlet to use for the client/server command interface.
Note: due to a problem in SCR plugin, this class cannot extend from the
AbstractPredicateServlet because the predicate provider
reference would be double defined.
- See Also:
- Serialized Form
|
Method Summary |
protected void |
doPost(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response)
|
protected boolean |
hasCommand(org.apache.sling.api.SlingHttpServletRequest request)
Checks if the command in the request is supported. |
protected abstract void |
performCommand(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response)
Perform the command of the current request. |
protected String |
requireParameter(org.apache.sling.api.SlingHttpServletRequest request,
String name)
Get value of specified parameter, trim and verify that it's provided |
| 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, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, init, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PATH_PARAM
public static final String PATH_PARAM
- default path parameter name
- See Also:
- Constant Field Values
ACTION_PARAM
public static final String ACTION_PARAM
- default action parameter name
- See Also:
- Constant Field Values
AbstractCommandServlet
public AbstractCommandServlet()
doPost
protected void doPost(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response)
throws javax.servlet.ServletException,
IOException
- Overrides:
doPost in class org.apache.sling.api.servlets.SlingAllMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
hasCommand
protected boolean hasCommand(org.apache.sling.api.SlingHttpServletRequest request)
throws javax.servlet.ServletException
- Checks if the command in the request is supported.
Returns
false by default.
- Parameters:
request - servlet request
- Returns:
true if the command is supported.
- Throws:
javax.servlet.ServletException - if a servlet error occurs
performCommand
protected abstract void performCommand(org.apache.sling.api.SlingHttpServletRequest request,
org.apache.sling.api.SlingHttpServletResponse response)
throws javax.servlet.ServletException,
IOException
- Perform the command of the current request.
This method is invoked if
hasCommand(SlingHttpServletRequest) returns true
for a POST request.
- Parameters:
request - servlet requestresponse - servlet response
- Throws:
javax.servlet.ServletException - if an error occurs.
IOException - if an I/O error occurs.
requireParameter
protected String requireParameter(org.apache.sling.api.SlingHttpServletRequest request,
String name)
throws javax.servlet.ServletException
- Get value of specified parameter, trim and verify that it's provided
- Parameters:
request - the servlet requestname - the name of the parameter
- Returns:
- the value of the parameter
- Throws:
javax.servlet.ServletException - if the parameter is missing or empty.
Copyright © 2008 Day Management AG. All Rights Reserved.