use of org.apache.sling.engine.impl.adapter.SlingServletResponseAdapter in project sling by apache.
the class RequestData method toSlingHttpServletResponse.
/**
* @param response
* @throws IllegalArgumentException if <code>response</code> is not a
* <code>HttpServletResponse</code> of if
* <code>response</code> is not backed by
* <code>SlingHttpServletResponseImpl</code>.
*/
public static SlingHttpServletResponse toSlingHttpServletResponse(ServletResponse response) {
// unwrap to SlingHttpServletResponse
SlingHttpServletResponse cResponse = unwrap(response);
// check type of response, don't care actually for the response itself
RequestData.unwrap(cResponse);
// are done
if (cResponse == response) {
return cResponse;
}
// ensure the response is a HTTP response
if (!(response instanceof HttpServletResponse)) {
throw new IllegalArgumentException("Response is not an HTTP response");
}
// and unwrapped component response
return new SlingServletResponseAdapter(cResponse, (HttpServletResponse) response);
}
Aggregations