Class PortletRequestWrapper
- java.lang.Object
-
- jakarta.portlet.filter.RenderStateWrapper
-
- jakarta.portlet.filter.PortletRequestWrapper
-
- All Implemented Interfaces:
PortletRequest,RenderState
- Direct Known Subclasses:
ClientDataRequestWrapper,EventRequestWrapper,RenderRequestWrapper
public class PortletRequestWrapper extends RenderStateWrapper implements PortletRequest
ThePortletRequestWrapperprovides a convenient implementation of thePortletRequestinterface 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.- Since:
- 2.0
- See Also:
PortletRequest
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.portlet.PortletRequest
PortletRequest.P3PUserInfos
-
-
Field Summary
-
Fields inherited from class jakarta.portlet.filter.RenderStateWrapper
wrapped
-
Fields inherited from interface jakarta.portlet.PortletRequest
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 Summary
Constructors Constructor Description PortletRequestWrapper(PortletRequest request)Creates anPortletRequestadaptor wrapping the given request object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ObjectgetAttribute(String name)Returns the value of the named attribute as anObject, ornullif no attribute of the given name exists.Enumeration<String>getAttributeNames()Returns anEnumerationcontaining the names of the attributes available to this request.StringgetAuthType()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 ornullif there was no authentication.StringgetContextPath()Returns the context path which is the path prefix associated with the deployed portlet application.jakarta.servlet.http.Cookie[]getCookies()Returns an array containing all of the Cookie properties.LocalegetLocale()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.StringgetParameter(String name)Deprecated.Map<String,String[]>getParameterMap()Deprecated.Enumeration<String>getParameterNames()Deprecated.String[]getParameterValues(String name)Deprecated.PortalContextgetPortalContext()Returns the context of the calling portal.PortletContextgetPortletContext()Returns thePortletContextof the portlet application the portlet is in.PortletModegetPortletMode()Returns the current portlet mode of the portlet.PortletSessiongetPortletSession()Returns the current portlet session or, if there is no current session, creates one and returns the new session.PortletSessiongetPortletSession(boolean create)Returns the current portlet session or, if there is no current session and the given flag istrue, creates one and returns the new session.PortletPreferencesgetPreferences()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 aEnumerationofStringobjects.StringgetProperty(String name)Returns the value of the specified request property as aString.Enumeration<String>getPropertyNames()Returns aEnumerationof all the property names this request contains.Map<String,String[]>getPublicParameterMap()Deprecated.StringgetRemoteUser()Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.RenderParametersgetRenderParameters()Gets the render parameters.PortletRequestgetRequest()Return the wrapped request object.StringgetRequestedSessionId()Returns the session ID indicated in the client request.StringgetResponseContentType()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.StringgetScheme()Returns the name of the scheme used to make this request.StringgetServerName()Returns the host name of the server that received the request.intgetServerPort()Returns the port number on which this request was received.StringgetUserAgent()Returns the user agent for the request.PrincipalgetUserPrincipal()Returns a java.security.Principal object containing the name of the current authenticated user.StringgetWindowID()Returns the portlet window ID.WindowStategetWindowState()Returns the current window state of the portlet.booleanisPortletModeAllowed(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.booleanisRequestedSessionIdValid()Checks whether the requested session ID is still valid.booleanisSecure()Returns a boolean indicating whether this request was made using a secure channel between client and the portal, such as HTTPS.booleanisUserInRole(String role)Returns a boolean indicating whether the authenticated user is included in the specified logical "role".booleanisWindowStateAllowed(WindowState state)Returns true, if the given window state is valid to be set for this portlet in the context of the current request.voidremoveAttribute(String name)Removes an attribute from this request.voidsetAttribute(String name, Object o)Stores an attribute in this request.voidsetRequest(PortletRequest request)Sets the request object being wrapped.-
Methods inherited from class jakarta.portlet.filter.RenderStateWrapper
getWrapped, setWrapped
-
-
-
-
Constructor Detail
-
PortletRequestWrapper
public PortletRequestWrapper(PortletRequest request)
Creates anPortletRequestadaptor wrapping the given request object.- Parameters:
request- the portlet request to wrap- Throws:
IllegalArgumentException- if the request isnull
-
-
Method Detail
-
getRequest
public PortletRequest getRequest()
Return the wrapped request object.- Returns:
- the wrapped request
-
setRequest
public void setRequest(PortletRequest request)
Sets the request object being wrapped.- Parameters:
request- the request to set- Throws:
IllegalArgumentException- if the request is null.
-
getAttribute
public Object getAttribute(String name)
Description copied from interface:PortletRequestReturns the value of the named attribute as anObject, ornullif no attribute of the given name exists.Attribute names should follow the same conventions as package names. This specification reserves names matching
java.*, andjakarta.*.In a distributed portlet web application the
Objectneeds to be serializable.- Specified by:
getAttributein interfacePortletRequest- Parameters:
name- aStringspecifying the name of the attribute- Returns:
- an
Objectcontaining the value of the attribute, ornullif the attribute does not exist.
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Description copied from interface:PortletRequestReturns anEnumerationcontaining the names of the attributes available to this request. This method returns an emptyEnumerationif the request has no attributes available to it.- Specified by:
getAttributeNamesin interfacePortletRequest- Returns:
- an
Enumerationof strings containing the names of the request attributes, or an emptyEnumerationif the request has no attributes available to it.
-
getAuthType
public String getAuthType()
Description copied from interface:PortletRequestReturns the name of the authentication scheme used for the connection between client and portal, for example,BASIC_AUTH,CLIENT_CERT_AUTH, a custom one ornullif there was no authentication.- Specified by:
getAuthTypein interfacePortletRequest- Returns:
- one of the static members
BASIC_AUTH,FORM_AUTH,CLIENT_CERT_AUTH,DIGEST_AUTH(suitable for == comparison) indicating the authentication scheme, a custom one, ornullif the request was not authenticated.
-
getContextPath
public String getContextPath()
Description copied from interface:PortletRequestReturns the context path which is the path prefix associated with the deployed portlet application. If the portlet application is rooted at the base of the web server URL namespace (also known as "default" context), this path must be an empty string. Otherwise, it must be the path the portlet application is rooted to, the path must start with a '/' and it must not end with a '/' character.To encode a URL the
PortletResponse.encodeURL(java.lang.String)method must be used.- Specified by:
getContextPathin interfacePortletRequest- Returns:
- a
Stringspecifying the portion of the request URL that indicates the context of the request - See Also:
PortletResponse.encodeURL(java.lang.String)
-
getLocale
public Locale getLocale()
Description copied from interface:PortletRequestReturns the preferred Locale in which the portal will accept content. The Locale may be based on the Accept-Language header of the client.- Specified by:
getLocalein interfacePortletRequest- Returns:
- the preferred Locale in which the portal will accept content.
-
getLocales
public Enumeration<Locale> getLocales()
Description copied from interface:PortletRequestReturns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale in which the portal will accept content for this request. The Locales may be based on the Accept-Language header of the client.- Specified by:
getLocalesin interfacePortletRequest- Returns:
- an Enumeration of Locales, in decreasing order, in which the portal will accept content for this request
-
getRenderParameters
public RenderParameters getRenderParameters()
Description copied from interface:RenderStateGets the render parameters.- Specified by:
getRenderParametersin interfaceRenderState- Overrides:
getRenderParametersin classRenderStateWrapper- Returns:
- an immutable
RenderParametersobject representing the private and public render parameters - See Also:
PortletParameters,RenderParameters
-
getParameter
@Deprecated public String getParameter(String name)
Deprecated.Description copied from interface:PortletRequestReturns the value of a request parameter as aString, ornullif 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.- Specified by:
getParameterin interfacePortletRequest- Parameters:
name- aStringspecifying the name of the parameter- Returns:
- a
Stringrepresenting the single value of the parameter - See Also:
PortletRequest.getParameterValues(java.lang.String)
-
getParameterMap
@Deprecated public Map<String,String[]> getParameterMap()
Deprecated.Description copied from interface:PortletRequestReturns aMapof 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
Mapare from type String array (String[]).If no parameters exist this method returns an empty
Map.- Specified by:
getParameterMapin interfacePortletRequest- Returns:
- an immutable
Mapcontaining parameter names as keys and parameter values as map values, or an emptyMapif 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[]).
-
getParameterNames
@Deprecated public Enumeration<String> getParameterNames()
Deprecated.Description copied from interface:PortletRequestReturns anEnumerationofStringobjects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an emptyEnumeration.Only parameters targeted to the current portlet are returned.
- Specified by:
getParameterNamesin interfacePortletRequest- Returns:
- an
EnumerationofStringobjects, eachStringcontaining the name of a request parameter; or an emptyEnumerationif the request has no parameters.
-
getParameterValues
@Deprecated public String[] getParameterValues(String name)
Deprecated.Description copied from interface:PortletRequestReturns an array ofStringobjects containing all of the values the given request parameter has, ornullif 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.
- Specified by:
getParameterValuesin interfacePortletRequest- Parameters:
name- aStringcontaining the name of the parameter the value of which is requested- Returns:
- an array of
Stringobjects containing the parameter values. - See Also:
PortletRequest.getParameter(java.lang.String)
-
getPortalContext
public PortalContext getPortalContext()
Description copied from interface:PortletRequestReturns the context of the calling portal.- Specified by:
getPortalContextin interfacePortletRequest- Returns:
- the context of the calling portal
-
getPortletContext
public PortletContext getPortletContext()
Description copied from interface:PortletRequestReturns thePortletContextof the portlet application the portlet is in.- Specified by:
getPortletContextin interfacePortletRequest- Returns:
- a
PortletContextobject, used by the caller to interact with its portlet container - See Also:
PortletContext
-
getPortletMode
public PortletMode getPortletMode()
Description copied from interface:RenderStateReturns the current portlet mode of the portlet.- Specified by:
getPortletModein interfaceRenderState- Overrides:
getPortletModein classRenderStateWrapper- Returns:
- the portlet mode. If the portlet mode is not available,
PortletMode.UNDEFINEDis returned. - See Also:
PortletMode
-
getPortletSession
public PortletSession getPortletSession()
Description copied from interface:PortletRequestReturns the current portlet session or, if there is no current session, creates one and returns the new session.Creating a new portlet session will result in creating a new
HttpSessionon 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
IllegalStateExceptionis thrown.- Specified by:
getPortletSessionin interfacePortletRequest- Returns:
- the portlet session
-
getPortletSession
public PortletSession getPortletSession(boolean create)
Description copied from interface:PortletRequestReturns the current portlet session or, if there is no current session and the given flag istrue, creates one and returns the new session.If the given flag is
falseand there is no current portlet session, this method returnsnull.Creating a new portlet session will result in creating a new
HttpSessionon 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
IllegalStateExceptionis thrown.- Specified by:
getPortletSessionin interfacePortletRequest- Parameters:
create-trueto create a new session,
falseto returnnullif there is no current session- Returns:
- the portlet session
-
getPreferences
public PortletPreferences getPreferences()
Description copied from interface:PortletRequestReturns the preferences object associated with the portlet.- Specified by:
getPreferencesin interfacePortletRequest- Returns:
- the portlet preferences
-
getProperties
public Enumeration<String> getProperties(String name)
Description copied from interface:PortletRequestReturns all the values of the specified request property as aEnumerationofStringobjects.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.- Specified by:
getPropertiesin interfacePortletRequest- Parameters:
name- aStringspecifying the property name- Returns:
- a
Enumerationcontaining the values of the requested property. If the request does not have any properties of that name return an emptyEnumeration.
-
getProperty
public String getProperty(String name)
Description copied from interface:PortletRequestReturns the value of the specified request property as aString. If the request did not include a property of the specified name, this method returnsnull.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.- Specified by:
getPropertyin interfacePortletRequest- Parameters:
name- aStringspecifying the property name- Returns:
- a
Stringcontaining the value of the requested property, ornullif the request does not have a property of that name.
-
getPropertyNames
public Enumeration<String> getPropertyNames()
Description copied from interface:PortletRequestReturns aEnumerationof all the property names this request contains. If the request has no properties, this method returns an emptyEnumeration.- Specified by:
getPropertyNamesin interfacePortletRequest- Returns:
- an
Enumerationof all the property names sent with this request; if the request has no properties, an emptyEnumeration.
-
getRemoteUser
public String getRemoteUser()
Description copied from interface:PortletRequestReturns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.- Specified by:
getRemoteUserin interfacePortletRequest- Returns:
- a
Stringspecifying the login of the user making this request, ornullif the user login is not known.
-
getRequestedSessionId
public String getRequestedSessionId()
Description copied from interface:PortletRequestReturns the session ID indicated in the client request. This session ID may not be a valid one, it may be an old one that has expired or has been invalidated. If the client request did not specify a session ID, this method returnsnull.- Specified by:
getRequestedSessionIdin interfacePortletRequest- Returns:
- a
Stringspecifying the session ID, ornullif the request did not specify a session ID - See Also:
PortletRequest.isRequestedSessionIdValid()
-
getResponseContentType
public String getResponseContentType()
Description copied from interface:PortletRequestReturns the portal preferred content type for the response.The following restrictions apply:
- The content type only includes the MIME type, not the
character set. The character set of the response
can be retrieved via the
MimeResponse.getCharacterEncoding(). -
If the portlet has defined
'*'or'*/*'as supported content types in the portlet configuration, these may also be valid return values.
- Specified by:
getResponseContentTypein interfacePortletRequest- Returns:
- preferred MIME type of the response
- The content type only includes the MIME type, not the
character set. The character set of the response
can be retrieved via the
-
getResponseContentTypes
public Enumeration<String> getResponseContentTypes()
Description copied from interface:PortletRequestGets a list of content types which the portal accepts for the response. This list is ordered with the most preferable types listed first.The following restrictions apply:
- The content type only includes the MIME type, not the character set.
-
If the portlet has defined
'*'or'*/*'as supported content types in the portlet configuration, these may also be valid return values.
- Specified by:
getResponseContentTypesin interfacePortletRequest- Returns:
- ordered list of MIME types for the response
-
getScheme
public String getScheme()
Description copied from interface:PortletRequestReturns the name of the scheme used to make this request. For example,http,https, orftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.- Specified by:
getSchemein interfacePortletRequest- Returns:
- a
Stringcontaining the name of the scheme used to make this request
-
getServerName
public String getServerName()
Description copied from interface:PortletRequestReturns the host name of the server that received the request.- Specified by:
getServerNamein interfacePortletRequest- Returns:
- a
Stringcontaining the name of the server to which the request was sent
-
getServerPort
public int getServerPort()
Description copied from interface:PortletRequestReturns the port number on which this request was received.- Specified by:
getServerPortin interfacePortletRequest- Returns:
- an integer specifying the port number
-
getUserPrincipal
public Principal getUserPrincipal()
Description copied from interface:PortletRequestReturns a java.security.Principal object containing the name of the current authenticated user.- Specified by:
getUserPrincipalin interfacePortletRequest- Returns:
- a
java.security.Principalcontaining the name of the user making this request, ornullif the user has not been authenticated.
-
getWindowID
public String getWindowID()
Description copied from interface:PortletRequestReturns the portlet window ID. The portlet window ID is unique for this portlet window and is constant for the lifetime of the portlet window.This ID is the same that is used by the portlet container for scoping the portlet-scope session attributes.
- Specified by:
getWindowIDin interfacePortletRequest- Returns:
- the portlet window ID
-
getWindowState
public WindowState getWindowState()
Description copied from interface:RenderStateReturns the current window state of the portlet.- Specified by:
getWindowStatein interfaceRenderState- Overrides:
getWindowStatein classRenderStateWrapper- Returns:
- the window state. If the window state is not available,
WindowState.UNDEFINEDis returned. - See Also:
WindowState
-
isPortletModeAllowed
public boolean isPortletModeAllowed(PortletMode mode)
Description copied from interface:PortletRequestReturns true, if the given portlet mode is a valid one to set for this portlet in the context of the current request.- Specified by:
isPortletModeAllowedin interfacePortletRequest- Parameters:
mode- portlet mode to check- Returns:
- true, if it is valid for this portlet in this request to change to the given portlet mode
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
Description copied from interface:PortletRequestChecks whether the requested session ID is still valid.- Specified by:
isRequestedSessionIdValidin interfacePortletRequest- Returns:
trueif this request has an id for a valid session in the current session context;falseotherwise- See Also:
PortletRequest.getRequestedSessionId(),PortletRequest.getPortletSession()
-
isSecure
public boolean isSecure()
Description copied from interface:PortletRequestReturns a boolean indicating whether this request was made using a secure channel between client and the portal, such as HTTPS.- Specified by:
isSecurein interfacePortletRequest- Returns:
- true, if the request was made using a secure channel.
-
isUserInRole
public boolean isUserInRole(String role)
Description copied from interface:PortletRequestReturns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returnsfalse.- Specified by:
isUserInRolein interfacePortletRequest- Parameters:
role- aStringspecifying the name of the role- Returns:
- a
booleanindicating whether the user making this request belongs to a given role;falseif the user has not been authenticated.
-
isWindowStateAllowed
public boolean isWindowStateAllowed(WindowState state)
Description copied from interface:PortletRequestReturns true, if the given window state is valid to be set for this portlet in the context of the current request.- Specified by:
isWindowStateAllowedin interfacePortletRequest- Parameters:
state- window state to checked- Returns:
- true, if it is valid for this portlet in this request to change to the given window state
-
removeAttribute
public void removeAttribute(String name)
Description copied from interface:PortletRequestRemoves an attribute from this request. This method is not generally needed, as attributes only persist as long as the request is being handled.Attribute names should follow the same conventions as package names. Names beginning with
java.*,jakarta.*, andcom.sun.*are reserved.- Specified by:
removeAttributein interfacePortletRequest- Parameters:
name- aStringspecifying the name of the attribute to be removed
-
setAttribute
public void setAttribute(String name, Object o)
Description copied from interface:PortletRequestStores an attribute in this request.Attribute names should follow the same conventions as package names. Names beginning with
java.*,jakarta.*, andcom.sun.*are reserved.
If the value passed into this method isnull, the effect is the same as callingPortletRequest.removeAttribute(java.lang.String).- Specified by:
setAttributein interfacePortletRequest- Parameters:
name- aStringspecifying the name of the attributeo- theObjectto be stored
-
getCookies
public jakarta.servlet.http.Cookie[] getCookies()
Description copied from interface:PortletRequestReturns an array containing all of the Cookie properties.This method returns
nullif no cookies exist.- Specified by:
getCookiesin interfacePortletRequest- Returns:
- array of cookie properties, or
nullif no cookies exist. - See Also:
PortletResponse.addProperty(Cookie)
-
getPrivateParameterMap
@Deprecated public Map<String,String[]> getPrivateParameterMap()
Deprecated.Description copied from interface:PortletRequestReturns aMapof 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
Mapare from type String array (String[]).If no private parameters exist this method returns an empty
Map.- Specified by:
getPrivateParameterMapin interfacePortletRequest- Returns:
- an immutable
Mapcontaining private parameter names as keys and private parameter values as map values, or an emptyMapif 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[]).
-
getPublicParameterMap
@Deprecated public Map<String,String[]> getPublicParameterMap()
Deprecated.Description copied from interface:PortletRequestReturns aMapof the public parameters of this request. Public parameters may be shared with other portlets or components as defined in the portlet deployment descriptor with thesupported-public-render-parameterelement. The returned parameters are "x-www-form-urlencoded" decoded.The values in the returned
Mapare from type String array (String[]).If no public parameters exist this method returns an empty
Map.- Specified by:
getPublicParameterMapin interfacePortletRequest- Returns:
- an immutable
Mapcontaining public parameter names as keys and public parameter values as map values, or an emptyMapif 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[]).
-
getUserAgent
public String getUserAgent()
Description copied from interface:PortletRequestReturns the user agent for the request.- Specified by:
getUserAgentin interfacePortletRequest- Returns:
- The user agent string.
-
-