Class RequestData
java.lang.Object
org.apache.sling.engine.impl.request.RequestData
The
RequestData class provides access to objects which are set
on a Servlet Request wide basis such as the repository session, the
persistence manager, etc.
The setup order is:
- Invoke constructor
- Invoke initResource()
- Invoke initServlet()
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the request attribute providing the resource addressed by the request URL. -
Constructor Summary
ConstructorsConstructorDescriptionRequestData(org.apache.sling.engine.impl.SlingRequestProcessorImpl slingRequestProcessor, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean protectHeadersOnInclude, boolean checkContentTypeOnInclude, boolean disableCheckCompliantGetUserPrincipal) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the name of the currently active servlet.longjavax.servlet.ServletInputStreamintstatic RequestDatagetRequestData(javax.servlet.ServletRequest request) static RequestDatagetRequestData(SlingHttpServletRequest request) intjavax.servlet.http.HttpServletRequestjavax.servlet.http.HttpServletResponseorg.apache.sling.engine.impl.SlingRequestProcessorImplinitResource(ResourceResolver resourceResolver) voidinitServlet(Resource resource, ServletResolver sr) booleanvoidbooleanvoidresetContent(ContentData data) static voidservice(SlingHttpServletRequest request, SlingHttpServletResponse response) Helper method to call the servlet for the current content data.setActiveServletName(String servletName) Sets the name of the currently active servlet and returns the name of the previously active servlet.setContent(Resource resource, RequestPathInfo requestPathInfo) voidsetDispatchingInfo(DispatchingInfo dispatchingInfo) static SlingHttpServletRequesttoSlingHttpServletRequest(javax.servlet.ServletRequest request) static SlingHttpServletResponsetoSlingHttpServletResponse(javax.servlet.ServletResponse response) static SlingHttpServletRequestunwrap(javax.servlet.ServletRequest request) Unwraps the ServletRequest to a SlingHttpServletRequest.static SlingHttpServletResponseunwrap(javax.servlet.ServletResponse response) Unwraps the ServletRequest to a SlingHttpServletRequest.static org.apache.sling.engine.impl.SlingHttpServletRequestImplunwrap(SlingHttpServletRequest request) Unwraps the SlingHttpServletRequest to a SlingHttpServletRequestImplstatic org.apache.sling.engine.impl.SlingHttpServletResponseImplunwrap(SlingHttpServletResponse response) Unwraps a SlingHttpServletResponse to a SlingHttpServletResponseImpl
-
Field Details
-
REQUEST_RESOURCE_PATH_ATTR
The name of the request attribute providing the resource addressed by the request URL.- See Also:
-
-
Constructor Details
-
RequestData
public RequestData(org.apache.sling.engine.impl.SlingRequestProcessorImpl slingRequestProcessor, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean protectHeadersOnInclude, boolean checkContentTypeOnInclude, boolean disableCheckCompliantGetUserPrincipal)
-
-
Method Details
-
initResource
-
initServlet
-
getSlingRequestProcessor
public org.apache.sling.engine.impl.SlingRequestProcessorImpl getSlingRequestProcessor() -
getServletRequest
public javax.servlet.http.HttpServletRequest getServletRequest() -
getServletResponse
public javax.servlet.http.HttpServletResponse getServletResponse() -
getSlingRequest
-
getSlingResponse
-
getDispatchingInfo
-
setDispatchingInfo
-
unwrap
Unwraps the ServletRequest to a SlingHttpServletRequest.- Parameters:
request- the request- Returns:
- the unwrapped request
- Throws:
IllegalArgumentException- If therequestis not aSlingHttpServletRequestand not aServletRequestWrapperwrapping aSlingHttpServletRequest.
-
unwrap
public static org.apache.sling.engine.impl.SlingHttpServletRequestImpl unwrap(SlingHttpServletRequest request) Unwraps the SlingHttpServletRequest to a SlingHttpServletRequestImpl- Parameters:
request- the request- Returns:
- the unwrapped request
- Throws:
IllegalArgumentException- Ifrequestis not aSlingHttpServletRequestImpland notSlingHttpServletRequestWrapperwrapping aSlingHttpServletRequestImpl.
-
unwrap
Unwraps the ServletRequest to a SlingHttpServletRequest.- Parameters:
response- the response- Returns:
- the unwrapped response
- Throws:
IllegalArgumentException- If theresponseis not aSlingHttpServletResponseand not aServletResponseWrapperwrapping aSlingHttpServletResponse.
-
unwrap
public static org.apache.sling.engine.impl.SlingHttpServletResponseImpl unwrap(SlingHttpServletResponse response) Unwraps a SlingHttpServletResponse to a SlingHttpServletResponseImpl- Parameters:
response- the response- Returns:
- the unwrapped response
- Throws:
IllegalArgumentException- Ifresponseis not aSlingHttpServletResponseImpland notSlingHttpServletResponseWrapperwrapping aSlingHttpServletResponseImpl.
-
getRequestData
- Parameters:
request- the request- Returns:
- the request data
- Throws:
IllegalArgumentException- If therequestis not aSlingHttpServletRequestand not aServletRequestWrapperwrapping aSlingHttpServletRequest.
-
getRequestData
- Parameters:
request- the request- Returns:
- the request data
- Throws:
IllegalArgumentException- Ifrequestis not aSlingHttpServletRequestImpland notSlingHttpServletRequestWrapperwrapping aSlingHttpServletRequestImpl.
-
toSlingHttpServletRequest
public static SlingHttpServletRequest toSlingHttpServletRequest(javax.servlet.ServletRequest request) - Parameters:
request- the request- Returns:
- the sling http servlet request
- Throws:
IllegalArgumentException- ifrequestis not aHttpServletRequestof ifrequestis not backed bySlingHttpServletRequestImpl.
-
toSlingHttpServletResponse
public static SlingHttpServletResponse toSlingHttpServletResponse(javax.servlet.ServletResponse response) - Parameters:
response- the response- Returns:
- the sling http servlet response
- Throws:
IllegalArgumentException- ifresponseis not aHttpServletResponseof ifresponseis not backed bySlingHttpServletResponseImpl.
-
service
public static void service(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, javax.servlet.ServletException Helper method to call the servlet for the current content data. If the current content data has no servlet, NOT_FOUND (404) error is sent and the method terminates.If the the servlet exists, the
SlingConstants.SLING_CURRENT_SERVLET_NAMErequest attribute is set to the name of that servlet and that servlet name is also set as thecurrently active servlet. After the termination of the servlet (normal or throwing a Throwable) the request attribute is reset to the previous value. The name of the currently active servlet is only reset to the previous value if the servlet terminates normally. In case of a Throwable, the active servlet name is not reset and indicates which servlet caused the potential abort of the request.- Parameters:
request- The request object for the service methodresponse- The response object for the service method- Throws:
IOException- May be thrown by the servlet's service methodjavax.servlet.ServletException- May be thrown by the servlet's service method
-
setContent
-
resetContent
-
getContentData
-
getResourceResolver
-
getRequestProgressTracker
-
getPeakRecusionDepth
public int getPeakRecusionDepth() -
getServletCallCount
public int getServletCallCount() -
protectHeadersOnInclude
public boolean protectHeadersOnInclude() -
checkContentTypeOnInclude
public boolean checkContentTypeOnInclude() -
getElapsedTimeMsec
public long getElapsedTimeMsec() -
setActiveServletName
Sets the name of the currently active servlet and returns the name of the previously active servlet.- Parameters:
servletName- the servlet name- Returns:
- the previous servlet name
-
getActiveServletName
Returns the name of the currently active servlet. If this name is notnullat the end of request processing, more precisly in the case of an uncaughtThrowableat the end of request processing, this is the name of the servlet causing the uncaughtThrowable.- Returns:
- the current servlet name
-
getInputStream
- Throws:
IOException
-
getReader
-
getParameterSupport
-
isDisableCheckCompliantGetUserPrincipal
public boolean isDisableCheckCompliantGetUserPrincipal() -
logNonCompliantGetUserPrincipalWarning
public void logNonCompliantGetUserPrincipalWarning()
-