public class PortletRequestWrapper extends RenderStateWrapper implements PortletRequest
PortletRequestWrapper
provides a convenient
implementation of the PortletRequest
interface
and is extended by other request wrappers.
This class implements the Wrapper or Decorator pattern.
Methods default to calling through to the wrapped request object.PortletRequest
PortletRequest.P3PUserInfos
wrapped
ACTION_PHASE, ACTION_SCOPE_ID, BASIC_AUTH, CCPP_PROFILE, CLIENT_CERT_AUTH, DIGEST_AUTH, EVENT_PHASE, FORM_AUTH, HEADER_PHASE, LIFECYCLE_PHASE, RENDER_HEADERS, RENDER_MARKUP, RENDER_PART, RENDER_PHASE, RESOURCE_PHASE, USER_INFO
Constructor and Description |
---|
PortletRequestWrapper(PortletRequest request)
Creates an
PortletRequest adaptor
wrapping the given request object. |
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String name)
Returns the value of the named attribute as an
Object ,
or null if no attribute of the given name exists. |
Enumeration<String> |
getAttributeNames()
Returns an
Enumeration containing the
names of the attributes available to this request. |
String |
getAuthType()
Returns the name of the authentication scheme used for the
connection between client and portal,
for example,
BASIC_AUTH , CLIENT_CERT_AUTH ,
a custom one or null if there was no authentication. |
String |
getContextPath()
Returns the context path which is the path prefix associated with the deployed
portlet application.
|
javax.servlet.http.Cookie[] |
getCookies()
Returns an array containing all of the Cookie properties.
|
Locale |
getLocale()
Returns the preferred Locale in which the portal will accept content.
|
Enumeration<Locale> |
getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing
order starting with the preferred locale in which the portal will
accept content for this request.
|
String |
getParameter(String name)
Deprecated.
|
Map<String,String[]> |
getParameterMap()
Deprecated.
|
Enumeration<String> |
getParameterNames()
Deprecated.
|
String[] |
getParameterValues(String name)
Deprecated.
|
PortalContext |
getPortalContext()
Returns the context of the calling portal.
|
PortletContext |
getPortletContext()
Returns the
PortletContext of the portlet application
the portlet is in. |
PortletMode |
getPortletMode()
Returns the current portlet mode of the portlet.
|
PortletSession |
getPortletSession()
Returns
the current portlet session or, if there is no current session,
creates one and returns the new session.
|
PortletSession |
getPortletSession(boolean create)
Returns
the current portlet session or, if there is no current session
and the given flag is
true , creates one and returns
the new session. |
PortletPreferences |
getPreferences()
Returns the preferences object associated with the portlet.
|
Map<String,String[]> |
getPrivateParameterMap()
Deprecated.
|
Enumeration<String> |
getProperties(String name)
Returns all the values of the specified request property
as a
Enumeration of String objects. |
String |
getProperty(String name)
Returns the value of the specified request property
as a
String . |
Enumeration<String> |
getPropertyNames()
Returns a
Enumeration of all the property names
this request contains. |
Map<String,String[]> |
getPublicParameterMap()
Deprecated.
|
String |
getRemoteUser()
Returns the login of the user making this request, if the user
has been authenticated, or null if the user has not been authenticated.
|
RenderParameters |
getRenderParameters()
Gets the render parameters.
|
PortletRequest |
getRequest()
Return the wrapped request object.
|
String |
getRequestedSessionId()
Returns the session ID indicated in the client request.
|
String |
getResponseContentType()
Returns the portal preferred content type for the response.
|
Enumeration<String> |
getResponseContentTypes()
Gets a list of content types which the portal accepts for the response.
|
String |
getScheme()
Returns the name of the scheme used to make this request.
|
String |
getServerName()
Returns the host name of the server that received the request.
|
int |
getServerPort()
Returns the port number on which this request was received.
|
String |
getUserAgent()
Returns the user agent for the request.
|
Principal |
getUserPrincipal()
Returns a java.security.Principal object containing the name of the
current authenticated user.
|
String |
getWindowID()
Returns the portlet window ID.
|
WindowState |
getWindowState()
Returns the current window state of the portlet.
|
boolean |
isPortletModeAllowed(PortletMode mode)
Returns true, if the given portlet mode is a valid
one to set for this portlet in the context
of the current request.
|
boolean |
isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.
|
boolean |
isSecure()
Returns a boolean indicating whether this request was made
using a secure channel between client and the portal, such as HTTPS.
|
boolean |
isUserInRole(String role)
Returns a boolean indicating whether the authenticated user is
included in the specified logical "role".
|
boolean |
isWindowStateAllowed(WindowState state)
Returns true, if the given window state is valid
to be set for this portlet in the context
of the current request.
|
void |
removeAttribute(String name)
Removes an attribute from this request.
|
void |
setAttribute(String name,
Object o)
Stores an attribute in this request.
|
void |
setRequest(PortletRequest request)
Sets the request object being wrapped.
|
getWrapped, setWrapped
public PortletRequestWrapper(PortletRequest request)
PortletRequest
adaptor
wrapping the given request object.request
- the portlet request to wrapIllegalArgumentException
- if the request is null
public PortletRequest getRequest()
public void setRequest(PortletRequest request)
request
- the request to setIllegalArgumentException
- if the request is null.public Object getAttribute(String name)
PortletRequest
Object
,
or null
if no attribute of the given name exists.
Attribute names should follow the same conventions as package
names. This specification reserves names matching java.*
,
and javax.*
.
In a distributed portlet web application the Object
needs to be serializable.
getAttribute
in interface PortletRequest
name
- a String
specifying the name of
the attributeObject
containing the value
of the attribute, or null
if
the attribute does not exist.public Enumeration<String> getAttributeNames()
PortletRequest
Enumeration
containing the
names of the attributes available to this request.
This method returns an empty Enumeration
if the request has no attributes available to it.getAttributeNames
in interface PortletRequest
Enumeration
of strings
containing the names
of the request attributes, or an empty
Enumeration
if the request
has no attributes available to it.public String getAuthType()
PortletRequest
BASIC_AUTH
, CLIENT_CERT_AUTH
,
a custom one or null
if there was no authentication.getAuthType
in interface PortletRequest
BASIC_AUTH
,
FORM_AUTH
, CLIENT_CERT_AUTH
,
DIGEST_AUTH
(suitable for == comparison)
indicating the authentication scheme,
a custom one, or
null
if the request was
not authenticated.public String getContextPath()
PortletRequest
To encode a URL the PortletResponse.encodeURL(java.lang.String)
method must be used.
getContextPath
in interface PortletRequest
String
specifying the
portion of the request URL that indicates the context
of the requestPortletResponse.encodeURL(java.lang.String)
public Locale getLocale()
PortletRequest
getLocale
in interface PortletRequest
public Enumeration<Locale> getLocales()
PortletRequest
getLocales
in interface PortletRequest
public RenderParameters getRenderParameters()
RenderState
getRenderParameters
in interface RenderState
getRenderParameters
in class RenderStateWrapper
RenderParameters
object representing
the private and public render parametersPortletParameters
,
RenderParameters
@Deprecated public String getParameter(String name)
PortletRequest
String
,
or null
if the parameter does not exist. Request parameters
are extra information sent with the request. The returned parameter
are "x-www-form-urlencoded" decoded.
Only parameters targeted to the current portlet are accessible.
This method should only be used if the
parameter has only one value. If the parameter might have
more than one value, use PortletRequest.getParameterValues(java.lang.String)
.
If this method is used with a multivalued
parameter, the value returned is equal to the first value
in the array returned by getParameterValues
.
getParameter
in interface PortletRequest
name
- a String
specifying the
name of the parameterString
representing the
single value of the parameterPortletRequest.getParameterValues(java.lang.String)
@Deprecated public Map<String,String[]> getParameterMap()
PortletRequest
Map
of
all public and private parameters
of this request.
Request parameters are extra information sent with the request.
The returned parameters are "x-www-form-urlencoded" decoded.
The values in the returned Map
are from type
String array (String[]
).
If no parameters exist this method returns an empty Map
.
getParameterMap
in interface PortletRequest
Map
containing parameter names as
keys and parameter values as map values, or an empty Map
if no parameters exist. The keys in the parameter
map are of type String. The values in the parameter map are of type
String array (String[]
).@Deprecated public Enumeration<String> getParameterNames()
PortletRequest
Enumeration
of String
objects containing the names of the parameters contained
in this request. If the request has
no parameters, the method returns an
empty Enumeration
.
Only parameters targeted to the current portlet are returned.
getParameterNames
in interface PortletRequest
Enumeration
of String
objects, each String
containing
the name of a request parameter; or an
empty Enumeration
if the
request has no parameters.@Deprecated public String[] getParameterValues(String name)
PortletRequest
String
objects containing
all of the values the given request parameter has, or
null
if the parameter does not exist.
The returned parameters are "x-www-form-urlencoded" decoded.
If the parameter has a single value, the array has a length of 1.
getParameterValues
in interface PortletRequest
name
- a String
containing the name of
the parameter the value of which is requestedString
objects
containing the parameter values.PortletRequest.getParameter(java.lang.String)
public PortalContext getPortalContext()
PortletRequest
getPortalContext
in interface PortletRequest
public PortletContext getPortletContext()
PortletRequest
PortletContext
of the portlet application
the portlet is in.
getPortletContext
in interface PortletRequest
PortletContext
object, used by the
caller to interact with its portlet containerPortletContext
public PortletMode getPortletMode()
RenderState
getPortletMode
in interface RenderState
getPortletMode
in class RenderStateWrapper
PortletMode.UNDEFINED
is returned.PortletMode
public PortletSession getPortletSession()
PortletRequest
Creating a new portlet session will result in creating
a new HttpSession
on which the portlet session is based.
To make sure the session is properly maintained, you must call this method before
the response is committed. If the container is using cookies to maintain session
integrity and is asked to create a new session when the response is committed,
an IllegalStateException
is thrown.
getPortletSession
in interface PortletRequest
public PortletSession getPortletSession(boolean create)
PortletRequest
true
, creates one and returns
the new session.
If the given flag is false
and there is no current
portlet session, this method returns null
.
Creating a new portlet session will result in creating
a new HttpSession
on which the portlet session is based.
To make sure the session is properly maintained, you must call this method before
the response is committed. If the container is using cookies to maintain session
integrity and is asked to create a new session when the response is committed,
an IllegalStateException
is thrown.
getPortletSession
in interface PortletRequest
create
- true
to create a new session, false
to return null
if there
is no current sessionpublic PortletPreferences getPreferences()
PortletRequest
getPreferences
in interface PortletRequest
public Enumeration<String> getProperties(String name)
PortletRequest
Enumeration
of String
objects.
If the request did not include any properties
of the specified name, this method returns an empty
Enumeration
.
The property name is case insensitive. You can use
this method with any request property.
getProperties
in interface PortletRequest
name
- a String
specifying the
property nameEnumeration
containing
the values of the requested property. If
the request does not have any properties of
that name return an empty Enumeration
.public String getProperty(String name)
PortletRequest
String
. If the request did not include a property
of the specified name, this method returns null
.
A portlet can access portal/portlet-container specific properties through this method and, if available, the headers of the HTTP client request.
This method should only be used if the
property has only one value. If the property might have
more than one value, use PortletRequest.getProperties(java.lang.String)
.
If this method is used with a multivalued
parameter, the value returned is equal to the first value
in the Enumeration returned by getProperties
.
getProperty
in interface PortletRequest
name
- a String
specifying the
property nameString
containing the
value of the requested
property, or null
if the request does not
have a property of that name.public Enumeration<String> getPropertyNames()
PortletRequest
Enumeration
of all the property names
this request contains. If the request has no
properties, this method returns an empty Enumeration
.getPropertyNames
in interface PortletRequest
Enumeration
of all the
property names sent with this
request; if the request has
no properties, an empty Enumeration
.public String getRemoteUser()
PortletRequest
getRemoteUser
in interface PortletRequest
String
specifying the login
of the user making this request, or null
if the user login is not known.public String getRequestedSessionId()
PortletRequest
null
.getRequestedSessionId
in interface PortletRequest
String
specifying the session
ID, or null
if the request did
not specify a session IDPortletRequest.isRequestedSessionIdValid()
public String getResponseContentType()
PortletRequest
The following restrictions apply:
MimeResponse.getCharacterEncoding()
.'*'
or '*/*'
as supported content
types in the portlet configuration, these may also be valid return values.
getResponseContentType
in interface PortletRequest
public Enumeration<String> getResponseContentTypes()
PortletRequest
The following restrictions apply:
'*'
or '*/*'
as supported content
types in the portlet configuration, these may also be valid return values.
getResponseContentTypes
in interface PortletRequest
public String getScheme()
PortletRequest
http
, https
, or ftp
.
Different schemes have different rules for constructing URLs,
as noted in RFC 1738.getScheme
in interface PortletRequest
String
containing the name
of the scheme used to make this requestpublic String getServerName()
PortletRequest
getServerName
in interface PortletRequest
String
containing the name
of the server to which the request was sentpublic int getServerPort()
PortletRequest
getServerPort
in interface PortletRequest
public Principal getUserPrincipal()
PortletRequest
getUserPrincipal
in interface PortletRequest
java.security.Principal
containing
the name of the user making this request, or
null
if the user has not been
authenticated.public String getWindowID()
PortletRequest
This ID is the same that is used by the portlet container for scoping the portlet-scope session attributes.
getWindowID
in interface PortletRequest
public WindowState getWindowState()
RenderState
getWindowState
in interface RenderState
getWindowState
in class RenderStateWrapper
WindowState.UNDEFINED
is returned.WindowState
public boolean isPortletModeAllowed(PortletMode mode)
PortletRequest
isPortletModeAllowed
in interface PortletRequest
mode
- portlet mode to checkpublic boolean isRequestedSessionIdValid()
PortletRequest
isRequestedSessionIdValid
in interface PortletRequest
true
if this
request has an id for a valid session
in the current session context;
false
otherwisePortletRequest.getRequestedSessionId()
,
PortletRequest.getPortletSession()
public boolean isSecure()
PortletRequest
isSecure
in interface PortletRequest
public boolean isUserInRole(String role)
PortletRequest
false
.isUserInRole
in interface PortletRequest
role
- a String
specifying the name
of the roleboolean
indicating whether
the user making this request belongs to a given role;
false
if the user has not been
authenticated.public boolean isWindowStateAllowed(WindowState state)
PortletRequest
isWindowStateAllowed
in interface PortletRequest
state
- window state to checkedpublic void removeAttribute(String name)
PortletRequest
Attribute names should follow the same conventions as
package names. Names beginning with java.*
,
javax.*
, and com.sun.*
are
reserved.
removeAttribute
in interface PortletRequest
name
- a String
specifying
the name of the attribute to be removedpublic void setAttribute(String name, Object o)
PortletRequest
Attribute names should follow the same conventions as
package names. Names beginning with java.*
,
javax.*
, and com.sun.*
are
reserved.
If the value passed into this method is null
,
the effect is the same as calling PortletRequest.removeAttribute(java.lang.String)
.
setAttribute
in interface PortletRequest
name
- a String
specifying
the name of the attributeo
- the Object
to be storedpublic javax.servlet.http.Cookie[] getCookies()
PortletRequest
This method returns null
if no cookies exist.
getCookies
in interface PortletRequest
null
if no cookies exist.PortletResponse.addProperty(Cookie)
@Deprecated public Map<String,String[]> getPrivateParameterMap()
PortletRequest
Map
of the private parameters of this request.
Private parameters are all those not declared to be public parameters
in the portlet deployment descriptor. They are not shared with other
portlets or components.
The returned parameters are "x-www-form-urlencoded" decoded.
The values in the returned Map
are from type
String array (String[]
).
If no private parameters exist this method returns an empty Map
.
getPrivateParameterMap
in interface PortletRequest
Map
containing private parameter names as
keys and private parameter values as map values, or an empty Map
if no private parameters exist. The keys in the parameter
map are of type String. The values in the parameter map are of type
String array (String[]
).@Deprecated public Map<String,String[]> getPublicParameterMap()
PortletRequest
Map
of the public parameters of this request.
Public parameters may be shared with other portlets or components as
defined in the portlet deployment descriptor with the
supported-public-render-parameter
element.
The returned parameters are "x-www-form-urlencoded" decoded.
The values in the returned Map
are from type
String array (String[]
).
If no public parameters exist this method returns an empty Map
.
getPublicParameterMap
in interface PortletRequest
Map
containing public parameter names as
keys and public parameter values as map values, or an empty Map
if no public parameters exist. The keys in the parameter
map are of type String. The values in the parameter map are of type
String array (String[]
).public String getUserAgent()
PortletRequest
getUserAgent
in interface PortletRequest
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.