public interface PortletRequest extends RenderState
PortletRequest
defines the base interface to provide client
request information to a portlet. The portlet container uses specialized
versions of this interface when invoking a portlet.
The portlet container creates these objects and
passes them as arguments to the corresponding request processing methods.
The PortletRequest
also provides access to the render state.
RenderState
,
ActionRequest
,
EventRequest
,
RenderRequest
,
ResourceRequest
Modifier and Type | Interface and Description |
---|---|
static class |
PortletRequest.P3PUserInfos
P3P user information constants.
|
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_PHASE
String identifier for the portlet action lifecycle phase.
|
static String |
ACTION_SCOPE_ID
The action scope ID that the portlet container uses
for storing the current action scope as render parameter
if the
javax.portlet.actionScopedRequestAttributes
container runtime option is used by the portlet. |
static String |
BASIC_AUTH
String identifier for Basic authentication.
|
static String |
CCPP_PROFILE
Used to retrieve an instance of the
javax.ccpp.Profile
with the getAttribute call. |
static String |
CLIENT_CERT_AUTH
String identifier for Certification based authentication.
|
static String |
DIGEST_AUTH
String identifier for Digest based authentication.
|
static String |
EVENT_PHASE
String identifier for the portlet event lifecycle phase.
|
static String |
FORM_AUTH
String identifier for Form based authentication.
|
static String |
HEADER_PHASE
String identifier for the portlet render lifecycle phase.
|
static String |
LIFECYCLE_PHASE
Provides the portlet lifecycle phase of the current request
as request attribute.
|
static String |
RENDER_HEADERS
The RENDER_HEADERS is a possible value of the RENDER_PART
request attribute and denotes that the portlet should set
the intended headers and the portlet title of this render
request.
|
static String |
RENDER_MARKUP
The RENDER_MARKUP is a possible value of the RENDER_PART
request attribute and denotes that the portlet should
produce its markup for this render request.
|
static String |
RENDER_PART
The RENDER_PART portlet request attribute is set by portals
that are streaming based and therefore need to split the
render phase into two parts: first the RENDER_HEADERS part
where the portlet should only set the header related data
and the portlet title, and second the RENDER_MARKUP part
in which the portlet should produce its markup.
|
static String |
RENDER_PHASE
String identifier for the portlet render lifecycle phase.
|
static String |
RESOURCE_PHASE
String identifier for the portlet resource serving lifecycle phase.
|
static String |
USER_INFO
Used to retrieve user information attributes with the
getAttribute call. |
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.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
Map<String,String[]> |
getParameterMap()
Deprecated.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
Enumeration<String> |
getParameterNames()
Deprecated.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
String[] |
getParameterValues(String name)
Deprecated.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
PortalContext |
getPortalContext()
Returns the context of the calling portal.
|
PortletContext |
getPortletContext()
Returns the
PortletContext of the portlet application
the portlet is in. |
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.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
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.
As of version 3.0. Use
RenderState.getRenderParameters() instead. |
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.
|
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.
|
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.
|
getPortletMode, getRenderParameters, getWindowState
static final String USER_INFO
getAttribute
call. The user information is returned
as a Map
object. The portlet must define the
user information attribute it is interested in inside the
user-attribute
section of the deployment descriptor.
If an attribute is not supported
by the current runtime system it will not show up in the user
attribute map.null
value.
If the user-attribute is not defined for the current user it will not show up in the Map.
The value is javax.portlet.userinfo
.
static final String CCPP_PROFILE
javax.ccpp.Profile
with the getAttribute
call. The returned profile is based
on the current portlet request and may contain additional CC/PP
information set by the portal / portlet container.
The value is javax.portlet.ccpp
.
static final String BASIC_AUTH
static final String FORM_AUTH
static final String CLIENT_CERT_AUTH
static final String DIGEST_AUTH
static final String ACTION_PHASE
ActionRequest
and ActionResponse
.
The value of the constant is ACTION_PHASE
.
static final String EVENT_PHASE
EventRequest
and EventResponse
.
The value of the constant is EVENT_PHASE
.
static final String HEADER_PHASE
HeaderRequest
and HeaderResponse
.
The value of the constant is HEADER_PHASE
.
static final String RENDER_PHASE
RenderRequest
and RenderResponse
.
The value of the constant is RENDER_PHASE
.
static final String RESOURCE_PHASE
ResourceRequest
and ResourceResponse
.
The value of the constant is RESOURCE_PHASE
.
static final String LIFECYCLE_PHASE
Valid values are: ACTION_PHASE, EVENT_PHASE, RENDER_PHASE, RESOURCE_SERVING_PHASE.
The value of the constant is javax.portlet.lifecylce_phase
.
static final String RENDER_PART
Non-streaming portals will not set this attribute and thus the portlet should set headers, portlet title and produce its markup in a single render request.
The value of the constant is javax.portlet.render_part
.
static final String RENDER_HEADERS
The value of the constant is RENDER_HEADERS
.
static final String RENDER_MARKUP
The value of the constant is RENDER_MARKUP
.
static final String ACTION_SCOPE_ID
javax.portlet.actionScopedRequestAttributes
container runtime option is used by the portlet.
The value is javax.portlet.as
.
boolean isWindowStateAllowed(WindowState state)
state
- window state to checkedboolean isPortletModeAllowed(PortletMode mode)
mode
- portlet mode to checkPortletPreferences getPreferences()
PortletSession getPortletSession()
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.
PortletSession getPortletSession(boolean create)
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.
create
- true
to create a new session, false
to return null
if there
is no current sessionString getProperty(String name)
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 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
.
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.IllegalArgumentException
- if name is null
.Enumeration<String> getProperties(String name)
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.
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
.IllegalArgumentException
- if name is null
.Enumeration<String> getPropertyNames()
Enumeration
of all the property names
this request contains. If the request has no
properties, this method returns an empty Enumeration
.Enumeration
of all the
property names sent with this
request; if the request has
no properties, an empty Enumeration
.PortalContext getPortalContext()
PortletContext getPortletContext()
PortletContext
of the portlet application
the portlet is in.
PortletContext
object, used by the
caller to interact with its portlet containerPortletContext
String getAuthType()
BASIC_AUTH
, CLIENT_CERT_AUTH
,
a custom one or null
if there was no authentication.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.String getContextPath()
To encode a URL the PortletResponse.encodeURL(java.lang.String)
method must be used.
String
specifying the
portion of the request URL that indicates the context
of the requestPortletResponse.encodeURL(java.lang.String)
String getRemoteUser()
String
specifying the login
of the user making this request, or null
if the user login is not known.Principal getUserPrincipal()
java.security.Principal
containing
the name of the user making this request, or
null
if the user has not been
authenticated.boolean isUserInRole(String role)
false
.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.Object getAttribute(String name)
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.
name
- a String
specifying the name of
the attributeObject
containing the value
of the attribute, or null
if
the attribute does not exist.IllegalArgumentException
- if name is null
.Enumeration<String> getAttributeNames()
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.Enumeration
of strings
containing the names
of the request attributes, or an empty
Enumeration
if the request
has no attributes available to it.@Deprecated String getParameter(String name)
RenderState.getRenderParameters()
instead.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 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
.
name
- a String
specifying the
name of the parameterString
representing the
single value of the parameterIllegalArgumentException
- if name is null
.getParameterValues(java.lang.String)
@Deprecated Enumeration<String> getParameterNames()
RenderState.getRenderParameters()
instead.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.
Enumeration
of String
objects, each String
containing
the name of a request parameter; or an
empty Enumeration
if the
request has no parameters.@Deprecated String[] getParameterValues(String name)
RenderState.getRenderParameters()
instead.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.
name
- a String
containing the name of
the parameter the value of which is requestedString
objects
containing the parameter values.IllegalArgumentException
- if name is null
.getParameter(java.lang.String)
@Deprecated Map<String,String[]> getParameterMap()
RenderState.getRenderParameters()
instead.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
.
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[]
).boolean isSecure()
void setAttribute(String name, Object o)
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 removeAttribute(java.lang.String)
.
name
- a String
specifying
the name of the attributeo
- the Object
to be storedIllegalArgumentException
- if name is null
.void removeAttribute(String name)
Attribute names should follow the same conventions as
package names. Names beginning with java.*
,
javax.*
, and com.sun.*
are
reserved.
name
- a String
specifying
the name of the attribute to be removedIllegalArgumentException
- if name is null
.String getRequestedSessionId()
null
.String
specifying the session
ID, or null
if the request did
not specify a session IDisRequestedSessionIdValid()
boolean isRequestedSessionIdValid()
true
if this
request has an id for a valid session
in the current session context;
false
otherwisegetRequestedSessionId()
,
getPortletSession()
String getResponseContentType()
The following restrictions apply:
MimeResponse.getCharacterEncoding()
.'*'
or '*/*'
as supported content
types in the portlet configuration, these may also be valid return values.
Enumeration<String> getResponseContentTypes()
The following restrictions apply:
'*'
or '*/*'
as supported content
types in the portlet configuration, these may also be valid return values.
Locale getLocale()
Enumeration<Locale> getLocales()
String getScheme()
http
, https
, or ftp
.
Different schemes have different rules for constructing URLs,
as noted in RFC 1738.String
containing the name
of the scheme used to make this requestString getServerName()
String
containing the name
of the server to which the request was sentint getServerPort()
String getWindowID()
This ID is the same that is used by the portlet container for scoping the portlet-scope session attributes.
javax.servlet.http.Cookie[] getCookies()
This method returns null
if no cookies exist.
null
if no cookies exist.PortletResponse.addProperty(Cookie)
@Deprecated Map<String,String[]> getPrivateParameterMap()
RenderState.getRenderParameters()
instead.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
.
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 Map<String,String[]> getPublicParameterMap()
RenderState.getRenderParameters()
instead.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
.
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[]
).String getUserAgent()
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.