org.xwiki.portlet.controller
Class DispatchedRequest

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.xwiki.portlet.controller.DispatchedRequest
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class DispatchedRequest
extends javax.servlet.http.HttpServletRequestWrapper

Wraps a servlet request object dispatched from a portlet.

Version:
$Id: 049f2b008a45526f46977a3ab567f399b7203c1d $

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
DispatchedRequest(javax.servlet.http.HttpServletRequest request, boolean exposeInitialQueryStringParameters)
          Wraps the given request that has been dispatched from a portlet, exposing the query string parameters of the initial request.
DispatchedRequest(javax.servlet.http.HttpServletRequest request, String redirectURL)
          Wraps the given request and behaves as if it was redirected to the specified URL.
 
Method Summary
 String getCharacterEncoding()
          
 String getParameter(String name)
           
 Map<String,String[]> getParameterMap()
           
 Enumeration<String> getParameterNames()
           
 String[] getParameterValues(String name)
           
 String getPathInfo()
           
 String getQueryString()
           
 javax.servlet.RequestDispatcher getRequestDispatcher(String path)
          
 String getRequestURI()
           
 StringBuffer getRequestURL()
          
 String getServletPath()
           
 void setCharacterEncoding(String characterEncoding)
          
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathTranslated, getRemoteUser, getRequestedSessionId, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute
 

Constructor Detail

DispatchedRequest

public DispatchedRequest(javax.servlet.http.HttpServletRequest request,
                         boolean exposeInitialQueryStringParameters)
                  throws javax.servlet.ServletException
Wraps the given request that has been dispatched from a portlet, exposing the query string parameters of the initial request.

Parameters:
request - the request to be wrapped
exposeInitialQueryStringParameters - true to expose the initial query string parameters, false otherwise
Throws:
javax.servlet.ServletException - if wrapping the given request fails

DispatchedRequest

public DispatchedRequest(javax.servlet.http.HttpServletRequest request,
                         String redirectURL)
                  throws javax.servlet.ServletException
Wraps the given request and behaves as if it was redirected to the specified URL.

Parameters:
request - the request to be wrapped
redirectURL - the redirect URL
Throws:
javax.servlet.ServletException - if wrapping the given request fails
Method Detail

getRequestURL

public StringBuffer getRequestURL()

We override the default implementation to overcome the fact that calling getRequestURL() on a servlet request dispatched from a portlet returns null. See chapter "PLT.19.3.4 Request and Response Objects for Included Servlets/JSPs from within the Render Method" in JSR286 Portlet Specification.

Specified by:
getRequestURL in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestURL in class javax.servlet.http.HttpServletRequestWrapper
See Also:
HttpServletRequestWrapper.getRequestURL(), org.apache.catalina.connector.Request#getRequestURL()

getCharacterEncoding

public String getCharacterEncoding()

Default implementation returns null if the request was dispatched from a portlet's render method. We override this method to return either the value set through setCharacterEncoding(String) or the value passed from a portlet's action processing method.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletRequest
Overrides:
getCharacterEncoding in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequestWrapper.getCharacterEncoding(), ServletRequestWrapper.setCharacterEncoding(String)

setCharacterEncoding

public void setCharacterEncoding(String characterEncoding)
                          throws UnsupportedEncodingException

Default implementation does nothing if the request was dispatched from a portlet's render method. We override this method to store the given character encoding. This way the behavior is consistent with what happens when the request is not dispatched from a portlet.

Specified by:
setCharacterEncoding in interface javax.servlet.ServletRequest
Overrides:
setCharacterEncoding in class javax.servlet.ServletRequestWrapper
Throws:
UnsupportedEncodingException
See Also:
ServletRequestWrapper.setCharacterEncoding(String)

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(String path)

We wrap the request dispatcher to be notified whenever this request is forwarded or included. We have to do this in order to update the path info.

Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest
Overrides:
getRequestDispatcher in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequestWrapper.getRequestDispatcher(String)

getRequestURI

public String getRequestURI()
Specified by:
getRequestURI in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestURI in class javax.servlet.http.HttpServletRequestWrapper

getServletPath

public String getServletPath()
Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest
Overrides:
getServletPath in class javax.servlet.http.HttpServletRequestWrapper

getPathInfo

public String getPathInfo()
Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest
Overrides:
getPathInfo in class javax.servlet.http.HttpServletRequestWrapper

getQueryString

public String getQueryString()
Specified by:
getQueryString in interface javax.servlet.http.HttpServletRequest
Overrides:
getQueryString in class javax.servlet.http.HttpServletRequestWrapper

getParameter

public String getParameter(String name)
Specified by:
getParameter in interface javax.servlet.ServletRequest
Overrides:
getParameter in class javax.servlet.ServletRequestWrapper

getParameterMap

public Map<String,String[]> getParameterMap()
Specified by:
getParameterMap in interface javax.servlet.ServletRequest
Overrides:
getParameterMap in class javax.servlet.ServletRequestWrapper

getParameterNames

public Enumeration<String> getParameterNames()
Specified by:
getParameterNames in interface javax.servlet.ServletRequest
Overrides:
getParameterNames in class javax.servlet.ServletRequestWrapper

getParameterValues

public String[] getParameterValues(String name)
Specified by:
getParameterValues in interface javax.servlet.ServletRequest
Overrides:
getParameterValues in class javax.servlet.ServletRequestWrapper


Copyright © 2004-2013 XWiki. All Rights Reserved.