use of org.apache.sling.engine.impl.adapter.SlingServletRequestAdapter in project sling by apache.
the class RequestData method toSlingHttpServletRequest.
/**
* @param request
* @throws IllegalArgumentException if <code>request</code> is not a
* <code>HttpServletRequest</code> of if <code>request</code>
* is not backed by <code>SlingHttpServletRequestImpl</code>.
*/
public static SlingHttpServletRequest toSlingHttpServletRequest(ServletRequest request) {
// unwrap to SlingHttpServletRequest, may throw if no
// SlingHttpServletRequest is wrapped in request
SlingHttpServletRequest cRequest = unwrap(request);
// ensure the SlingHttpServletRequest is backed by
// SlingHttpServletRequestImpl
RequestData.unwrap(cRequest);
// if the request is not wrapper at all, we are done
if (cRequest == request) {
return cRequest;
}
// ensure the request is a HTTP request
if (!(request instanceof HttpServletRequest)) {
throw new IllegalArgumentException("Request is not an HTTP request");
}
// and unwrapped component response
return new SlingServletRequestAdapter(cRequest, (HttpServletRequest) request);
}
Aggregations