net.sf.jportlet.impl
Class PortletRequestImpl

java.lang.Object
  |
  +--javax.servlet.ServletRequestWrapper
        |
        +--javax.servlet.http.HttpServletRequestWrapper
              |
              +--net.sf.jportlet.impl.PortletRequestImpl
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, PortletRequest, javax.servlet.ServletRequest

public class PortletRequestImpl
extends javax.servlet.http.HttpServletRequestWrapper
implements PortletRequest

Implementation of PortletRequest

Author:
Herve Tchepannou

Field Summary
static java.lang.String LOCALE_KEY
          Key for accessing the Locale from HttpSession
static java.lang.String PORTLET_REQUEST_KEY
          Key for accessing the previous PortletRequest
static java.lang.String PORTLET_URI_KEY
          Key for accessing the PortletURI from HttpServletRequest
static java.lang.String ROLES_KEY
          Key for accessing the User's roles from HttpServletRequest
static java.lang.String SESSION_KEY_PREFIX
          Prefix of the key of each PortletSession stored in the HttpSession
static java.lang.String USER_ID_KEY
          Key for accessing the current user's id from HttpSession
static java.lang.String USER_KEY
          Key for accessing the User from HttpServletRequest
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
PortletRequestImpl(net.sf.jportlet.portlet.application.PortletProxy proxy, javax.servlet.http.HttpServletRequest httpRequest, net.sf.jportlet.service.PortletServiceFactory serviceFactory)
           
 
Method Summary
 void addError(java.lang.Object error)
           
 void addErrors(java.util.Collection errors)
           
 boolean canAccess(Portlet.Mode mode)
          Return true if the current user can access the portlet in a given mode
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 java.util.Map getAttributes()
           
 net.sf.jportlet.portlet.Client getClient()
          Returns informations about the client device
 java.lang.String getContextPath()
           
 net.sf.jportlet.portlet.PortletData getData()
          Returns the data of the portlet
 java.util.Collection getErrors()
           
 javax.servlet.http.HttpServletRequest getHttpRequest()
           
 java.util.Locale getLocale()
           
 Portlet.Mode getMode()
          Returns the mode of the portlet
 net.sf.jportlet.impl.PortletPageContext getPageContext()
           
 net.sf.jportlet.portlet.PortletSession getPortletSession()
          Returns the current session or, if there is no current session, it creates one and returns it.
 net.sf.jportlet.portlet.PortletSession getPortletSession(boolean create)
          Returns the current session or, if there is no current session and the given flag is true, it creates one and returns it.
 net.sf.jportlet.portlet.PortletURI getPortletURI()
           
 net.sf.jportlet.portlet.application.PortletProxy getProxy()
           
 net.sf.jportlet.portlet.PortletSettings getSettings()
          Returns the settings of the portlet
 net.sf.jportlet.portlet.User getUser()
          Return the information of the current user.
 java.lang.String getUserId()
           
 java.util.Collection getUserRoles()
          Return a list of all the roles of the current user, or null if the current user has no role or no user is logged in
 net.sf.jportlet.portlet.PortletWindow getWindow()
          Return the window of the portlet
 boolean hasErrors()
           
 boolean isUserInRole(java.lang.String role)
           
 void removeAttribute(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setAttributes(java.util.Map attributes)
           
 void setPageContext(net.sf.jportlet.impl.PortletPageContext pageContext)
          Sets the pageContext.
 void startSession(net.sf.jportlet.portlet.User user)
          Start a new session for a user.
 void stopSession()
          Stop the current session.
 void userChanged(net.sf.jportlet.portlet.User user)
           
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid
 
Methods inherited from interface javax.servlet.ServletRequest
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, setCharacterEncoding
 

Field Detail

LOCALE_KEY

public static final java.lang.String LOCALE_KEY
Key for accessing the Locale from HttpSession

See Also:
Constant Field Values

PORTLET_REQUEST_KEY

public static final java.lang.String PORTLET_REQUEST_KEY
Key for accessing the previous PortletRequest

See Also:
Constant Field Values

PORTLET_URI_KEY

public static final java.lang.String PORTLET_URI_KEY
Key for accessing the PortletURI from HttpServletRequest

See Also:
Constant Field Values

SESSION_KEY_PREFIX

public static final java.lang.String SESSION_KEY_PREFIX
Prefix of the key of each PortletSession stored in the HttpSession

See Also:
Constant Field Values

USER_ID_KEY

public static final java.lang.String USER_ID_KEY
Key for accessing the current user's id from HttpSession

See Also:
Constant Field Values

USER_KEY

public static final java.lang.String USER_KEY
Key for accessing the User from HttpServletRequest

See Also:
Constant Field Values

ROLES_KEY

public static final java.lang.String ROLES_KEY
Key for accessing the User's roles from HttpServletRequest

See Also:
Constant Field Values
Constructor Detail

PortletRequestImpl

public PortletRequestImpl(net.sf.jportlet.portlet.application.PortletProxy proxy,
                          javax.servlet.http.HttpServletRequest httpRequest,
                          net.sf.jportlet.service.PortletServiceFactory serviceFactory)
Method Detail

addError

public void addError(java.lang.Object error)

addErrors

public void addErrors(java.util.Collection errors)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface javax.servlet.ServletRequest
Overrides:
getAttribute in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequest.getAttribute(java.lang.String)

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
Overrides:
getAttributeNames in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequest.getAttributeNames()

getAttributes

public java.util.Map getAttributes()

getClient

public net.sf.jportlet.portlet.Client getClient()
Description copied from interface: PortletRequest
Returns informations about the client device

Specified by:
getClient in interface PortletRequest
Returns:
Client
See Also:
PortletRequest.getClient()

getContextPath

public java.lang.String getContextPath()
Specified by:
getContextPath in interface javax.servlet.http.HttpServletRequest
Overrides:
getContextPath in class javax.servlet.http.HttpServletRequestWrapper
See Also:
HttpServletRequest.getContextPath()

getData

public net.sf.jportlet.portlet.PortletData getData()
Description copied from interface: PortletRequest
Returns the data of the portlet

Specified by:
getData in interface PortletRequest
Returns:
PortletData
See Also:
PortletRequest.getData()

getErrors

public java.util.Collection getErrors()

getHttpRequest

public javax.servlet.http.HttpServletRequest getHttpRequest()

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface javax.servlet.ServletRequest
Overrides:
getLocale in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequest.getLocale()

getMode

public Portlet.Mode getMode()
Description copied from interface: PortletRequest
Returns the mode of the portlet

Specified by:
getMode in interface PortletRequest
Returns:
Mode
See Also:
PortletRequest.getMode()

getPageContext

public net.sf.jportlet.impl.PortletPageContext getPageContext()
Returns:
PortletPageContext

getPortletSession

public net.sf.jportlet.portlet.PortletSession getPortletSession()
Description copied from interface: PortletRequest
Returns the current session or, if there is no current session, it creates one and returns it.

Specified by:
getPortletSession in interface PortletRequest
Returns:
PortletSession
See Also:
PortletRequest.getPortletSession()

getPortletSession

public net.sf.jportlet.portlet.PortletSession getPortletSession(boolean create)
Description copied from interface: PortletRequest
Returns the current session or, if there is no current session and the given flag is true, it creates one and returns it.

Specified by:
getPortletSession in interface PortletRequest
Parameters:
create - flag to create the session
Returns:
PortletSession
See Also:
PortletRequest.getPortletSession(boolean)

getPortletURI

public net.sf.jportlet.portlet.PortletURI getPortletURI()

getProxy

public net.sf.jportlet.portlet.application.PortletProxy getProxy()
Returns:
PortletProxy

getSettings

public net.sf.jportlet.portlet.PortletSettings getSettings()
Description copied from interface: PortletRequest
Returns the settings of the portlet

Specified by:
getSettings in interface PortletRequest
Returns:
PortletSettings
See Also:
PortletRequest.getSettings()

getUser

public net.sf.jportlet.portlet.User getUser()
Description copied from interface: PortletRequest
Return the information of the current user. If the user has not logged in, this method will return null

Specified by:
getUser in interface PortletRequest
Returns:
User
See Also:
PortletRequest.getUser()

getUserId

public java.lang.String getUserId()

getUserRoles

public java.util.Collection getUserRoles()
Return a list of all the roles of the current user, or null if the current user has no role or no user is logged in

Returns:
Collection

getWindow

public net.sf.jportlet.portlet.PortletWindow getWindow()
Description copied from interface: PortletRequest
Return the window of the portlet

Specified by:
getWindow in interface PortletRequest
Returns:
PortletWindow
See Also:
PortletRequest.getWindow()

hasErrors

public boolean hasErrors()

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.servlet.ServletRequest
Overrides:
removeAttribute in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequest.removeAttribute(java.lang.String)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in interface javax.servlet.ServletRequest
Overrides:
setAttribute in class javax.servlet.ServletRequestWrapper
See Also:
ServletRequest.setAttribute(java.lang.String, java.lang.Object)

setAttributes

public void setAttributes(java.util.Map attributes)

setPageContext

public void setPageContext(net.sf.jportlet.impl.PortletPageContext pageContext)
Sets the pageContext.

Parameters:
pageContext - The pageContext to set

startSession

public void startSession(net.sf.jportlet.portlet.User user)
                  throws PortletException
Start a new session for a user. This function is called by the container when a user logs in.

Parameters:
user - User who starts the current session
PortletException

stopSession

public void stopSession()
Stop the current session. This function is called by the container when the current user logs out


isUserInRole

public boolean isUserInRole(java.lang.String role)
Specified by:
isUserInRole in interface javax.servlet.http.HttpServletRequest
Overrides:
isUserInRole in class javax.servlet.http.HttpServletRequestWrapper
See Also:
HttpServletRequest.isUserInRole(java.lang.String)

canAccess

public boolean canAccess(Portlet.Mode mode)
Return true if the current user can access the portlet in a given mode

Parameters:
mode -
Returns:
boolean

userChanged

public void userChanged(net.sf.jportlet.portlet.User user)


Copyright © 2002 Herve Tchepannou. All Rights Reserved.