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
Modifier and TypeFieldDescriptionstatic final String
The name of the request attribute providing the resource addressed by the request URL. -
Constructor Summary
ConstructorDescriptionRequestData
(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 TypeMethodDescriptionboolean
Returns the name of the currently active servlet.long
javax.servlet.ServletInputStream
int
static RequestData
getRequestData
(javax.servlet.ServletRequest request) static RequestData
getRequestData
(SlingHttpServletRequest request) int
javax.servlet.http.HttpServletRequest
javax.servlet.http.HttpServletResponse
org.apache.sling.engine.impl.SlingRequestProcessorImpl
initResource
(ResourceResolver resourceResolver) void
initServlet
(Resource resource, ServletResolver sr) boolean
void
boolean
void
resetContent
(ContentData data) static void
service
(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) void
setDispatchingInfo
(DispatchingInfo dispatchingInfo) static SlingHttpServletRequest
toSlingHttpServletRequest
(javax.servlet.ServletRequest request) static SlingHttpServletResponse
toSlingHttpServletResponse
(javax.servlet.ServletResponse response) static SlingHttpServletRequest
unwrap
(javax.servlet.ServletRequest request) Unwraps the ServletRequest to a SlingHttpServletRequest.static SlingHttpServletResponse
unwrap
(javax.servlet.ServletResponse response) Unwraps the ServletRequest to a SlingHttpServletRequest.static org.apache.sling.engine.impl.SlingHttpServletRequestImpl
unwrap
(SlingHttpServletRequest request) Unwraps the SlingHttpServletRequest to a SlingHttpServletRequestImplstatic org.apache.sling.engine.impl.SlingHttpServletResponseImpl
unwrap
(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 therequest
is not aSlingHttpServletRequest
and not aServletRequestWrapper
wrapping 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
- Ifrequest
is not aSlingHttpServletRequestImpl
and notSlingHttpServletRequestWrapper
wrapping aSlingHttpServletRequestImpl
.
-
unwrap
Unwraps the ServletRequest to a SlingHttpServletRequest.- Parameters:
response
- the response- Returns:
- the unwrapped response
- Throws:
IllegalArgumentException
- If theresponse
is not aSlingHttpServletResponse
and not aServletResponseWrapper
wrapping 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
- Ifresponse
is not aSlingHttpServletResponseImpl
and notSlingHttpServletResponseWrapper
wrapping aSlingHttpServletResponseImpl
.
-
getRequestData
- Parameters:
request
- the request- Returns:
- the request data
- Throws:
IllegalArgumentException
- If therequest
is not aSlingHttpServletRequest
and not aServletRequestWrapper
wrapping aSlingHttpServletRequest
.
-
getRequestData
- Parameters:
request
- the request- Returns:
- the request data
- Throws:
IllegalArgumentException
- Ifrequest
is not aSlingHttpServletRequestImpl
and notSlingHttpServletRequestWrapper
wrapping aSlingHttpServletRequestImpl
.
-
toSlingHttpServletRequest
public static SlingHttpServletRequest toSlingHttpServletRequest(javax.servlet.ServletRequest request) - Parameters:
request
- the request- Returns:
- the sling http servlet request
- Throws:
IllegalArgumentException
- ifrequest
is not aHttpServletRequest
of ifrequest
is not backed bySlingHttpServletRequestImpl
.
-
toSlingHttpServletResponse
public static SlingHttpServletResponse toSlingHttpServletResponse(javax.servlet.ServletResponse response) - Parameters:
response
- the response- Returns:
- the sling http servlet response
- Throws:
IllegalArgumentException
- ifresponse
is not aHttpServletResponse
of ifresponse
is 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_NAME
request 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 notnull
at the end of request processing, more precisly in the case of an uncaughtThrowable
at 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()
-