Overview  Package   Class  Tree  Serialized  Deprecated  Index  Help 

org.apache.jetspeed.portlet
Interface PortletRequest

All Superinterfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public interface PortletRequest
extends javax.servlet.http.HttpServletRequest

The PortletRequest encapsulates the request sent by the client to the portlet.

Since:
4.1
See Also:
PortletResponse

Field Summary
 

Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 

Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the attribute with the given name, or null if no attribute with the given name exists.
 java.util.Enumeration getAttributeNames()
          Returns an enumeration of names of all attributes available to this request.
 Client getClient()
          Returns an object representing the client device that the user connects to the portal with.
 javax.servlet.http.Cookie[] getCookies()
          Returns an array containing all of the Cookie objects the client sent with this request.
 PortletData getData()
          Returns the data of the concrete portlet instance
 long getDateHeader(java.lang.String name)
          Returns the value of the specified request header as a long value that represents a Date object.
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified request header as a String.
 java.util.Enumeration getHeaderNames()
          Returns an enumeration of all the header names this request contains.
 java.util.Enumeration getHeaders(java.lang.String name)
          Returns all the values of the specified request header as an Enumeration of String objects.
 javax.servlet.ServletInputStream getInputStream()
          Retrieves the body of the request as binary data using an InputStream.
 int getIntHeader(java.lang.String name)
          Returns the value of the specified request header as an int.
 java.util.Locale getLocale()
          Returns the locale of the preferred language.
 java.util.Enumeration getLocales()
          Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
 java.lang.String getMethod()
          Returns the HTTP method of this request.
 Portlet.Mode getMode()
          Returns the mode that the portlet is running in.
 java.lang.String getParameter(java.lang.String name)
          Returns the value of the parameter with the given name, or null if no such parameter exists.
 java.util.Map getParameterMap()
          Returns a map of the parameters of this request.
 java.util.Enumeration getParameterNames()
          Returns an enumeration of all parameter names.
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns the values of all parameters with the given name.
 PortletSession getPortletSession()
          Returns the current session for the portlet or, if there is no current portlet session, creates one and returns it.
 PortletSession getPortletSession(boolean create)
          Returns the current session for the portlet or, if there is no current portlet session and the given flag is true, creates one and returns it.
 PortletSettings getPortletSettings()
          Returns the PortletSettings object of the concrete portlet.
 Portlet.Mode getPreviousMode()
          Returns the last mode that is kept for this portlet on the mode stack, or null if no previous mode exists.
 org.apache.jetspeed.portlet.User getUser()
          Returns the user object.
 PortletWindow getWindow()
          Returns the window that the portlet is running in.
 void invalidateCache()
          Invalidates the cache for all window states, markups and locals
 boolean isSecure()
          Returns whether this request was made using a secure channel, such as HTTPS.
 void removeAttribute(java.lang.String name)
          Removes the attribute with the given name.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Associates an attribute with the given name and value with this request.
 void setModeModifier(Portlet.ModeModifier modeModifier)
          Defines which portlet mode is shown next.
 

Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getContextPath, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 

Methods inherited from interface javax.servlet.ServletRequest
getCharacterEncoding, getContentLength, getContentType, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, setCharacterEncoding
 

Method Detail

getMode

public Portlet.Mode getMode()
Returns the mode that the portlet is running in.

Returns:
the portlet mode

getPreviousMode

public Portlet.Mode getPreviousMode()
Returns the last mode that is kept for this portlet on the mode stack, or null if no previous mode exists.

Note that the result is not necessarily the last mode that this portlet was running in. For example, if the portlet starts in view mode, changes to edit mode and then goes back to view mode through a return URL or by using PortletMode.ModeModifier.PREVIOUS, then getPreviousMode will return null because the edit mode has already been removed from the stack.

Returns:
the previous portlet mode

setModeModifier

public void setModeModifier(Portlet.ModeModifier modeModifier)
                     throws AccessDeniedException
Defines which portlet mode is shown next. Once the mode is changed it cannot be changed back to Portlet.ModeModifier.REQUESTED.

This function may only be used during event processing, in any other case the call has no effect.

Parameters:
modeModifier - the mode modifier
Throws:
AccessDeniedException - if the portlet tries to access this function outside of the action event processing

getMethod

public java.lang.String getMethod()
Returns the HTTP method of this request. The most commonly used request methods are GET and POST.

Specified by:
getMethod in interface javax.servlet.http.HttpServletRequest
Returns:
the method

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Retrieves the body of the request as binary data using an InputStream.

Specified by:
getInputStream in interface javax.servlet.ServletRequest
Returns:
an input stream containing the body of the request
Throws:
java.lang.IllegalStateException - if the portlet tries to access this function outside of the action event processing
java.io.IOException - if an input or output exception occurred

getLocale

public java.util.Locale getLocale()
Returns the locale of the preferred language. The preference is based on the user's choice of language(s) and/or the client's Accept-Language header.

If more than one language is preferred, the locale returned by this method is the one with the highest preference.

Specified by:
getLocale in interface javax.servlet.ServletRequest
Returns:
the locale of the preferred language

getLocales

public java.util.Enumeration getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.

Specified by:
getLocales in interface javax.servlet.ServletRequest
Returns:
an Enumeration of preferred Locale objects for the client

getClient

public Client getClient()
Returns an object representing the client device that the user connects to the portal with.

Returns:
the client

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value of the parameter with the given name, or null if no such parameter exists.

You should only use this method when you are sure the parameter has only one value. If not, use getParameterValues(String)

All parameter retrieval methods check for parameters that are namespaced by the portlet and for paramters that are not namespaced. If both exist, the namespaced parameter values are returned

Specified by:
getParameter in interface javax.servlet.ServletRequest
Parameters:
name - the parameter name
Returns:
the parameter value
See Also:
getParameterMap(), getParameterValues(String)

getParameterMap

public java.util.Map getParameterMap()
Returns a map of the parameters of this request.

All parameter retrieval methods check for parameters that are namespaced by the portlet and for paramters that are not namespaced. If both exist, the namespaced parameter values are returned

Note that, for historical reasons, the values of the returned map are Strings and not String arrays, altough this is is inconsistent with the behavior defined by javax.servlet.ServletRequest

Specified by:
getParameterMap in interface javax.servlet.ServletRequest
Returns:
a map of parameters; maps from String to String
See Also:
getParameter(String), getParameterValues(String)

getParameterNames

public java.util.Enumeration getParameterNames()
Returns an enumeration of all parameter names. If this request

All parameter retrieval methods check for parameters that are namespaced by the portlet and for paramters that are not namespaced.

Specified by:
getParameterNames in interface javax.servlet.ServletRequest
Returns:
the enumeration

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of all parameters with the given name.

A request can carry more than one parameter with a certain name. This method returns these parameters in the order of appearance.

All parameter retrieval methods check for parameters that are namespaced by the portlet and for paramters that are not namespaced. If both exist, the namespaced parameter values are returned

Note that, for historical reasons, this method returns an empty String array and not null if the specified parameter is not set, altough this is is inconsistent with the behavior defined by javax.servlet.ServletRequest

Specified by:
getParameterValues in interface javax.servlet.ServletRequest
Parameters:
name - the parameter name
Returns:
the array of parameter values
See Also:
getParameterMap(), getParameter(String)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Associates an attribute with the given name and value with this request. If a portlet needs to communicate information to embedded servlets or JSP, this methods can used carry the information along.

The portlet provider should take care that the the namespace of attribute names is not unnecessarily polluted. It is recommended to prefix all attributes the package and class name of the portlet that makes use of this method.

Specified by:
setAttribute in interface javax.servlet.ServletRequest
Parameters:
name - the attribute name
value - the attribute value

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the attribute with the given name.

Specified by:
removeAttribute in interface javax.servlet.ServletRequest
Parameters:
name - the name of attribute to be removed

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the attribute with the given name, or null if no attribute with the given name exists.

Specified by:
getAttribute in interface javax.servlet.ServletRequest
Parameters:
name - the attribute name
Returns:
the attribute value

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an enumeration of names of all attributes available to this request. This method returns an empty enumeration if the request has no attributes available to it.

Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
Returns:
an enumeration of attribute names

isSecure

public boolean isSecure()
Returns whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface javax.servlet.ServletRequest
Returns:
true if channel is secure,
false otherwise

getWindow

public PortletWindow getWindow()
Returns the window that the portlet is running in.

Returns:
the portlet window

getData

public PortletData getData()
Returns the data of the concrete portlet instance

If the portlet is run in CONFIGURE mode, the portlet data is not accessible and this method will return null.

Returns:
the portlet data

getPortletSession

public PortletSession getPortletSession()
Returns the current session for the portlet or, if there is no current portlet session, creates one and returns it.

This method should not be called when no portal session exists, i.e. when no user is logged in and the portlet is viewed on an anonymous page. In this case, the result may be a temporary session and session contents will be lost after the request completes.

Returns:
the portlet session

getPortletSession

public PortletSession getPortletSession(boolean create)
Returns the current session for the portlet or, if there is no current portlet session and the given flag is true, creates one and returns it.

If the given flag is false and there is no current session for the portal, this method returns null. If a session exists for the portal, but the portlet has not yet requested a session, a new portlet session will be created.

This method should not be called with an argument value of true when no portal session exists, i.e. when no user is logged in and the portlet is viewed on an anonymous page. In this case, the result may be a temporary session and session contents will be lost after the request completes.

Parameters:
create - true always return a portlet session, even if none exists and only a temporary session can be created. false return null if there is no current session for the portal. Never return a temporary session.
Returns:
the portlet session

getCookies

public javax.servlet.http.Cookie[] getCookies()
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.

Specified by:
getCookies in interface javax.servlet.http.HttpServletRequest
Returns:
an array of all the Cookies included with this request, or null if the request has no cookies

getUser

public org.apache.jetspeed.portlet.User getUser()
Returns the user object. The user object contains useful information about the user and his or her preferences.

If the user has not logged in or does not grant access to the portlet, this method returns null.

Returns:
the user object

getPortletSettings

public PortletSettings getPortletSettings()
Returns the PortletSettings object of the concrete portlet.

Returns:
the PortletSettings object, or NULL if no PortletSettings object is available.

getDateHeader

public long getDateHeader(java.lang.String name)
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.

If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.

Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest
Parameters:
name - a String specifying the name of the header
Returns:
a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the reqest
Throws:
java.lang.IllegalArgumentException - If the header value can't be converted to a date

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
Parameters:
name - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the request does not have a header of that name

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)
Returns all the values of the specified request header as an Enumeration of String objects.

Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeaders in interface javax.servlet.http.HttpServletRequest
Parameters:
name - a String specifying the header name
Returns:
a Enumeration containing the values of the requested header, or null if the request does not have any headers of that name

getHeaderNames

public java.util.Enumeration getHeaderNames()
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.

Some portlet containers do not allow do not allow portlets to access headers using this method, in which case this method returns null

Specified by:
getHeaderNames in interface javax.servlet.http.HttpServletRequest
Returns:
an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the portlet container does not allow portlets to use this method, null

getIntHeader

public int getIntHeader(java.lang.String name)
Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException.

The header name is case insensitive.

Specified by:
getIntHeader in interface javax.servlet.http.HttpServletRequest
Parameters:
name - a String specifying the name of a request header
Returns:
an integer expressing the value of the request header or -1 if the request doesn't have a header of this name
Throws:
java.lang.NumberFormatException - If the header value can't be converted to an int

invalidateCache

public void invalidateCache()
Invalidates the cache for all window states, markups and locals


Overview  Package   Class  Tree  Serialized  Deprecated  Index  Help 

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.