Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public interface PortletRequest
PortletRequest
defines the base interface to provide client
request information to a portlet. The portlet container uses two specialized
versions of this interface when invoking a portlet, ActionRequest
and RenderRequest
. The portlet container creates these objects and
passes them as arguments to the portlet's processAction
and
render
methods.
ActionRequest
, RenderRequest
Field Summary | |
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
Method Summary | |
Object |
|
java.util.Enumeration |
|
java.lang.String |
|
String |
|
java.util.Locale |
|
java.util.Enumeration |
|
String |
|
java.util.Map |
|
java.util.Enumeration |
|
String[] |
|
PortalContext |
|
PortletMode |
|
PortletSession |
|
PortletSession |
|
PortletPreferences |
|
java.util.Enumeration |
|
String |
|
java.util.Enumeration |
|
java.lang.String |
|
String |
|
String |
|
java.util.Enumeration |
|
String |
|
String |
|
int |
|
java.security.Principal |
|
WindowState |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
public static final String BASIC_AUTH
String identifier for Basic authentication. Value "BASIC".
public static final String CLIENT_CERT_AUTH
String identifier for Certification based authentication. Value "CLIENT_CERT".
public static final String DIGEST_AUTH
String identifier for Digest based authentication. Value "DIGEST".
public static final String FORM_AUTH
String identifier for Form based authentication. Value "FORM".
public static final String USER_INFO
Used to retrieve user information attributes with thegetAttribute
call. The user information is returned as aMap
object. The portlet must define the user information attribute it is interested in inside theuser-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.
If the user-attribute is supported by the runtime system, but not defined for a particular user, then for that user the attribute exists in the returned map and the attribute has anull
value. If the user-attribute is not defined for the current user it will not show up in the Map. The value isjavax.portlet.userinfo
.
public Object getAttribute(String name)
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists. Attribute names should follow the same conventions as package names. This specification reserves names matchingjava.*
, andjavax.*
. In a distributed portlet web application theObject
needs to be serializable.
- Parameters:
name
- aString
specifying the name of the attribute
- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist.
public java.util.Enumeration getAttributeNames()
Returns anEnumeration
containing the names of the attributes available to this request. This method returns an emptyEnumeration
if the request has no attributes available to it.
- Returns:
- an
Enumeration
of strings containing the names of the request attributes, or an emptyEnumeration
if the request has no attributes available to it.
public java.lang.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 ornull
if there was no authentication.
- 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, ornull
if the request was not authenticated.
public String getContextPath()
Returns 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 thePortletResponse.encodeURL(String)
method must be used.
- Returns:
- a
String
specifying the portion of the request URL that indicates the context of the request
- See Also:
PortletResponse.encodeURL(String)
public java.util.Locale getLocale()
Returns the preferred Locale in which the portal will accept content. The Locale may be based on the Accept-Language header of the client.
- Returns:
- the prefered Locale in which the portal will accept content.
public java.util.Enumeration 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. The Locales may be based on the Accept-Language header of the client.
- Returns:
- an Enumeration of Locales, in decreasing order, in which the portal will accept content for this request
public String getParameter(String name)
Returns the value of a request parameter as aString
, ornull
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, usegetParameterValues(String)
. If this method is used with a multivalued parameter, the value returned is equal to the first value in the array returned bygetParameterValues
.
- Parameters:
name
- aString
specifying the name of the parameter
- Returns:
- a
String
representing the single value of the parameter
- See Also:
getParameterValues(String)
public java.util.Map getParameterMap()
Returns aMap
of the 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 returnedMap
are from type String array (String[]
). If no parameters exist this method returns an emptyMap
.
- Returns:
- an immutable
Map
containing parameter names as keys and parameter values as map values, or an emptyMap
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[]
).
public java.util.Enumeration getParameterNames()
Returns anEnumeration
ofString
objects 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.
- Returns:
- an
Enumeration
ofString
objects, eachString
containing the name of a request parameter; or an emptyEnumeration
if the request has no parameters.
public String[] getParameterValues(String name)
Returns an array ofString
objects containing all of the values the given request parameter has, ornull
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.
- Parameters:
name
- aString
containing the name of the parameter the value of which is requested
- Returns:
- an array of
String
objects containing the parameter values.
- See Also:
getParameter(String)
public PortalContext getPortalContext()
Returns the context of the calling portal.
- Returns:
- the context of the calling portal
public PortletMode getPortletMode()
Returns the current portlet mode of the portlet.
- Returns:
- the portlet mode
public PortletSession getPortletSession()
Returns 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 newHttpSession
on which the portlet session is based on.
- Returns:
- the portlet session
public PortletSession getPortletSession(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. If the given flag isfalse
and there is no current portlet session, this method returnsnull
. Creating a new portlet session will result in creating a newHttpSession
on which the portlet session is based on.
- Parameters:
create
-true
to create a new session,
false
to returnnull
if there is no current session
- Returns:
- the portlet session
public PortletPreferences getPreferences()
Returns the preferences object associated with the portlet.
- Returns:
- the portlet preferences
public java.util.Enumeration getProperties(String name)
Returns all the values of the specified request property as aEnumeration
ofString
objects. If the request did not include any propertys of the specified name, this method returns an emptyEnumeration
. The property name is case insensitive. You can use this method with any request property.
- Parameters:
name
- aString
specifying the property name
- Returns:
- a
Enumeration
containing the values of the requested property. If the request does not have any properties of that name return an emptyEnumeration
.
public String getProperty(String name)
Returns 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, usegetProperties(String)
. If this method is used with a multivalued parameter, the value returned is equal to the first value in the Enumeration returned bygetProperties
.
- Parameters:
name
- aString
specifying the property name
- Returns:
- a
String
containing the value of the requested property, ornull
if the request does not have a property of that name.
public java.util.Enumeration getPropertyNames()
Returns aEnumeration
of all the property names this request contains. If the request has no properties, this method returns an emptyEnumeration
.
- Returns:
- an
Enumeration
of all the property names sent with this request; if the request has no properties, an emptyEnumeration
.
public java.lang.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.
- Returns:
- a
String
specifying the login of the user making this request, ornull
if the user login is not known.
public String getRequestedSessionId()
Returns 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
.
- Returns:
- a
String
specifying the session ID, ornull
if the request did not specify a session ID
- See Also:
isRequestedSessionIdValid()
public String getResponseContentType()
Returns the portal preferred content type for the response. The content type only includes the MIME type, not the character set. Only content types that the portlet has defined in its deployment descriptor are valid return values for this method call. If the portlet has defined'*'
or'* / *'
as supported content types, these may also be valid return values.
- Returns:
- preferred MIME type of the response
public java.util.Enumeration getResponseContentTypes()
Gets a list of content types which the portal accepts for the response. This list is ordered with the most preferable types listed first. The content type only includes the MIME type, not the character set. Only content types that the portlet has defined in its deployment descriptor are valid return values for this method call. If the portlet has defined'*'
or'* / *'
as supported content types, these may also be valid return values.
- Returns:
- ordered list of MIME types for the response
public String getScheme()
Returns 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.
- Returns:
- a
String
containing the name of the scheme used to make this request
public String getServerName()
Returns the host name of the server that received the request.
- Returns:
- a
String
containing the name of the server to which the request was sent
public int getServerPort()
Returns the port number on which this request was received.
- Returns:
- an integer specifying the port number
public java.security.Principal getUserPrincipal()
Returns a java.security.Principal object containing the name of the current authenticated user.
- Returns:
- a
java.security.Principal
containing the name of the user making this request, ornull
if the user has not been authenticated.
public WindowState getWindowState()
Returns the current window state of the portlet.
- Returns:
- the window state
public 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.
- 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
public boolean isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.
- Returns:
true
if this request has an id for a valid session in the current session context;false
otherwise
- See Also:
getRequestedSessionId()
,getPortletSession
public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel between client and the portal, such as HTTPS.
- Returns:
- true, if the request was made using a secure channel.
public boolean isUserInRole(java.lang.String role)
Returns 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
.
- Parameters:
role
- aString
specifying the name of the role
- Returns:
- a
boolean
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)
Returns true, if the given window state is valid to be set for this portlet in the context of the current request.
- 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
public void removeAttribute(String name)
Removes 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 withjava.*
,javax.*
, andcom.sun.*
are reserved for use by Sun Microsystems.
- Parameters:
name
- aString
specifying the name of the attribute to be removed
public void setAttribute(String name, Object o)
Stores an attribute in this request. Attribute names should follow the same conventions as package names. Names beginning withjava.*
,javax.*
, andcom.sun.*
are reserved for use by Sun Microsystems.
If the value passed into this method isnull
, the effect is the same as callingremoveAttribute(String)
.
- Parameters:
name
- aString
specifying the name of the attributeo
- theObject
to be stored