org.apache.jetspeed.portalsite.impl
Class PortalSiteSessionContextImpl

java.lang.Object
  extended by org.apache.jetspeed.portalsite.impl.PortalSiteSessionContextImpl
All Implemented Interfaces:
Serializable, EventListener, javax.servlet.http.HttpSessionActivationListener, javax.servlet.http.HttpSessionBindingListener, org.apache.jetspeed.page.PageManagerEventListener, org.apache.jetspeed.portalsite.PortalSiteSessionContext

public class PortalSiteSessionContextImpl
extends Object
implements org.apache.jetspeed.portalsite.PortalSiteSessionContext, org.apache.jetspeed.page.PageManagerEventListener, javax.servlet.http.HttpSessionActivationListener, javax.servlet.http.HttpSessionBindingListener, Serializable

This class encapsulates managed session state for and interface to the portal-site component and subscribes to page manager and session events to flush stale state. Note that is object is Serializable since it is designed to be cached in the session. However, because this object is cached only for these two reasons: 1. a performance optimization to reuse SiteViews, and 2. to hold optional folder page history, this object need not be relocatable between J2 instances. Consequently, all data members are marked transient and the isValid() method is used to test whether this object is a valid context for the session or if it was transferred from another server or the persistent session store and needs to be discarded.

Version:
$Id: PortalSiteSessionContextImpl.java 553375 2007-07-05 05:37:00Z taylor $
Author:
Randy Watler
See Also:
Serialized Form

Field Summary
private  Map folderPageHistory
          folderPageHistory - map of last page visited by folder
private static org.apache.commons.logging.Log log
          log - logging instance
private  Map menuDefinitionLocatorCache
          menuDefinitionLocatorCache - cached menu definition locators for absolute menus valid for session
private  org.apache.jetspeed.page.PageManager pageManager
          pageManager - PageManager component
private  String pipeline
          store which pipeline we are serving
private  Map profileLocators
          profileLocators - map of session profile locators by locator names
private  SiteView siteView
          siteView - session site view
private  boolean stale
          stale - flag that indicates whether the state managed by this context is stale
private  boolean subscribed
          subscribed - flag that indicates whether this context is subscribed as event listeners
private  String userPrincipal
          userPrincipal - session user principal
 
Constructor Summary
PortalSiteSessionContextImpl(org.apache.jetspeed.page.PageManager pageManager)
          PortalSiteSessionContextImpl - constructor
 
Method Summary
private  void clearSessionProfileLocators()
          clearSessionProfileLocators - clear cache session profile locators
private  Map getFolderPageHistory()
           
 org.apache.jetspeed.om.page.Page getManagedPage(org.apache.jetspeed.om.page.Page page)
          getManagedPage - get concrete page instance from page proxy
 SiteViewMenuDefinitionLocator getMenuDefinitionLocator(org.apache.jetspeed.page.document.Node node, String name)
          getMenuDefinitionLocator - get named node proxy menu definition locator from site view
 Map getMenuDefinitionLocatorCache()
          getMenuDefinitionLocatorCache - get menu definition locators cache for absolute menus
 List getMenuDefinitionLocators(org.apache.jetspeed.page.document.Node node)
          getMenuDefinitionLocators - get list of node proxy menu definition locators from site view
 org.apache.jetspeed.page.PageManager getPageManager()
          getPageManager - return PageManager component instance
 String getPipeline()
           
 Map getProfileLocators()
          getProfileLocators - get session profile locators
private  String getRequestPathFromLocator(org.apache.jetspeed.profiler.ProfileLocator locator)
          getRequestPathFromLocator - execute profile locator to extract request path using locator rules; this is request specific and is not part of the site view
 org.apache.jetspeed.om.folder.Folder getRequestRootFolder(Map requestProfileLocators)
          getRequestRootFolder - select root folder proxy for given profile locators
 SiteView getSiteView()
          getSiteView - lookup and/or create site view for profile locators of this context
 Set getStandardMenuNames()
          getStandardMenuNames - get set of available standard menu names
 boolean isValid()
          isValid - return flag indicating whether this context instance is valid or if it is stale after being persisted and reloaded as session state
private static boolean locatorsEquals(Map locators0, Map locators1)
          locatorsEquals - test profile locator maps for equivalence ignoring request specifics
 void newNode(org.apache.jetspeed.page.document.Node node)
          newNode - invoked when the definition of a node is created by the page manager or when the node creation is otherwise detected
 org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
          newRequestContext - create a new request context instance with fallback and history
 org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback)
          newRequestContext - create a new request context instance with history
 org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback, boolean useHistory)
          newRequestContext - create a new request context instance
 void removedNode(org.apache.jetspeed.page.document.Node node)
          removedNode - invoked when the definition of a node is removed by the page manager or when the node removal is otherwise detected
 org.apache.jetspeed.om.page.Page selectRequestPage(Map requestProfileLocators, boolean requestFallback, boolean useHistory)
          selectRequestPage - select page proxy for request given profile locators
private  org.apache.jetspeed.om.page.Page selectRequestPage(String requestPath, boolean useHistory)
          selectRequestPage - select page proxy for request for specified path given profile locators and site view associated with this context
 void sessionDidActivate(javax.servlet.http.HttpSessionEvent event)
          sessionDidActivate - notification that the session has just been activated
 void sessionWillPassivate(javax.servlet.http.HttpSessionEvent event)
          sessionWillPassivate - notification that the session is about to be passivated
 void setMenuDefinitionLocatorCache(Map cache)
          setMenuDefinitionLocatorCache - set menu definition locators cache for absolute menus
 void setPipeline(String pipeline)
           
 void updatedNode(org.apache.jetspeed.page.document.Node node)
          updatedNode - invoked when the definition of a node is updated by the page manager or when the node modification is otherwise detected
private  boolean updateSessionProfileLocators(Map requestProfileLocators)
          updateSessionProfileLocators - detect modification of and update cached session profile locators
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
          valueBound - notifies this context that it is being bound to a session and identifies the session
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
          valueUnbound - notifies this context that it is being unbound from a session and identifies the session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log
log - logging instance


pageManager

private transient org.apache.jetspeed.page.PageManager pageManager
pageManager - PageManager component


profileLocators

private transient Map profileLocators
profileLocators - map of session profile locators by locator names


userPrincipal

private transient String userPrincipal
userPrincipal - session user principal


siteView

private transient SiteView siteView
siteView - session site view


folderPageHistory

private transient Map folderPageHistory
folderPageHistory - map of last page visited by folder


menuDefinitionLocatorCache

private transient Map menuDefinitionLocatorCache
menuDefinitionLocatorCache - cached menu definition locators for absolute menus valid for session


subscribed

private transient boolean subscribed
subscribed - flag that indicates whether this context is subscribed as event listeners


stale

private transient boolean stale
stale - flag that indicates whether the state managed by this context is stale


pipeline

private transient String pipeline
store which pipeline we are serving

Constructor Detail

PortalSiteSessionContextImpl

public PortalSiteSessionContextImpl(org.apache.jetspeed.page.PageManager pageManager)
PortalSiteSessionContextImpl - constructor

Parameters:
pageManager - PageManager component instance
Method Detail

newRequestContext

public org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
newRequestContext - create a new request context instance with fallback and history

Specified by:
newRequestContext in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext
Parameters:
requestProfileLocators - request profile locators
Returns:
new request context instance

newRequestContext

public org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators,
                                                                                 boolean requestFallback)
newRequestContext - create a new request context instance with history

Specified by:
newRequestContext in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext
Parameters:
requestProfileLocators - request profile locators
requestFallback - flag specifying whether to fallback to root folder if locators do not select a page or access is forbidden
Returns:
new request context instance

newRequestContext

public org.apache.jetspeed.portalsite.PortalSiteRequestContext newRequestContext(Map requestProfileLocators,
                                                                                 boolean requestFallback,
                                                                                 boolean useHistory)
newRequestContext - create a new request context instance

Specified by:
newRequestContext in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext
Parameters:
requestProfileLocators - request profile locators
requestFallback - flag specifying whether to fallback to root folder if locators do not select a page or access is forbidden
useHistory - flag indicating whether to use visited page history to select default page per site folder
Returns:
new request context instance

selectRequestPage

public org.apache.jetspeed.om.page.Page selectRequestPage(Map requestProfileLocators,
                                                          boolean requestFallback,
                                                          boolean useHistory)
                                                   throws org.apache.jetspeed.page.document.NodeNotFoundException
selectRequestPage - select page proxy for request given profile locators

Parameters:
requestProfileLocators - map of profile locators for request
requestFallback - flag specifying whether to fallback to root folder if locators do not select a page or access is forbidden
useHistory - flag indicating whether to use visited page history to select default page per site folder
Returns:
selected page proxy for request
Throws:
org.apache.jetspeed.page.document.NodeNotFoundException - if not found
SecurityException - if view access not granted

getRequestPathFromLocator

private String getRequestPathFromLocator(org.apache.jetspeed.profiler.ProfileLocator locator)
getRequestPathFromLocator - execute profile locator to extract request path using locator rules; this is request specific and is not part of the site view

Parameters:
locator - profile locator to execute
Returns:
request path from profile locator

selectRequestPage

private org.apache.jetspeed.om.page.Page selectRequestPage(String requestPath,
                                                           boolean useHistory)
                                                    throws org.apache.jetspeed.page.document.NodeNotFoundException
selectRequestPage - select page proxy for request for specified path given profile locators and site view associated with this context

Parameters:
requestPath - request path
useHistory - flag indicating whether to use visited page history to select default page per site folder
Returns:
selected page proxy for request
Throws:
org.apache.jetspeed.page.document.NodeNotFoundException - if not found
SecurityException - if view access not granted

getRequestRootFolder

public org.apache.jetspeed.om.folder.Folder getRequestRootFolder(Map requestProfileLocators)
                                                          throws org.apache.jetspeed.page.document.NodeNotFoundException
getRequestRootFolder - select root folder proxy for given profile locators

Parameters:
requestProfileLocators - map of profile locators for request
Returns:
root folder proxy for request
Throws:
org.apache.jetspeed.page.document.NodeNotFoundException - if not found
SecurityException - if view access not granted

updateSessionProfileLocators

private boolean updateSessionProfileLocators(Map requestProfileLocators)
updateSessionProfileLocators - detect modification of and update cached session profile locators

Parameters:
requestProfileLocators - map of profile locators for request
Returns:
profile locators validation flag

clearSessionProfileLocators

private void clearSessionProfileLocators()
clearSessionProfileLocators - clear cache session profile locators


getSiteView

public SiteView getSiteView()
getSiteView - lookup and/or create site view for profile locators of this context

Returns:
site view instance

getPageManager

public org.apache.jetspeed.page.PageManager getPageManager()
getPageManager - return PageManager component instance

Specified by:
getPageManager in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext
Returns:
PageManager instance

isValid

public boolean isValid()
isValid - return flag indicating whether this context instance is valid or if it is stale after being persisted and reloaded as session state

Specified by:
isValid in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext
Returns:
valid context status

getProfileLocators

public Map getProfileLocators()
getProfileLocators - get session profile locators


getStandardMenuNames

public Set getStandardMenuNames()
getStandardMenuNames - get set of available standard menu names

Returns:
menu names set

getMenuDefinitionLocators

public List getMenuDefinitionLocators(org.apache.jetspeed.page.document.Node node)
getMenuDefinitionLocators - get list of node proxy menu definition locators from site view

Parameters:
node - site view node proxy
Returns:
definition locator list

getMenuDefinitionLocator

public SiteViewMenuDefinitionLocator getMenuDefinitionLocator(org.apache.jetspeed.page.document.Node node,
                                                              String name)
getMenuDefinitionLocator - get named node proxy menu definition locator from site view

Parameters:
node - site view node proxy
name - menu definition name
Returns:
menu definition locator

getManagedPage

public org.apache.jetspeed.om.page.Page getManagedPage(org.apache.jetspeed.om.page.Page page)
getManagedPage - get concrete page instance from page proxy

Parameters:
page - page proxy
Returns:
managed page

getMenuDefinitionLocatorCache

public Map getMenuDefinitionLocatorCache()
getMenuDefinitionLocatorCache - get menu definition locators cache for absolute menus

Returns:
menu definition locators cache

setMenuDefinitionLocatorCache

public void setMenuDefinitionLocatorCache(Map cache)
setMenuDefinitionLocatorCache - set menu definition locators cache for absolute menus


locatorsEquals

private static boolean locatorsEquals(Map locators0,
                                      Map locators1)
locatorsEquals - test profile locator maps for equivalence ignoring request specifics

Parameters:
locators0 - request profile locator map
locators1 - request profile locator map
Returns:
boolean flag indicating equivalence

newNode

public void newNode(org.apache.jetspeed.page.document.Node node)
newNode - invoked when the definition of a node is created by the page manager or when the node creation is otherwise detected

Specified by:
newNode in interface org.apache.jetspeed.page.PageManagerEventListener
Parameters:
node - new managed node if known

updatedNode

public void updatedNode(org.apache.jetspeed.page.document.Node node)
updatedNode - invoked when the definition of a node is updated by the page manager or when the node modification is otherwise detected

Specified by:
updatedNode in interface org.apache.jetspeed.page.PageManagerEventListener
Parameters:
node - updated managed node if known

removedNode

public void removedNode(org.apache.jetspeed.page.document.Node node)
removedNode - invoked when the definition of a node is removed by the page manager or when the node removal is otherwise detected

Specified by:
removedNode in interface org.apache.jetspeed.page.PageManagerEventListener
Parameters:
node - removed managed node if known

sessionDidActivate

public void sessionDidActivate(javax.servlet.http.HttpSessionEvent event)
sessionDidActivate - notification that the session has just been activated

Specified by:
sessionDidActivate in interface javax.servlet.http.HttpSessionActivationListener
Parameters:
event - session activation event

sessionWillPassivate

public void sessionWillPassivate(javax.servlet.http.HttpSessionEvent event)
sessionWillPassivate - notification that the session is about to be passivated

Specified by:
sessionWillPassivate in interface javax.servlet.http.HttpSessionActivationListener
Parameters:
event - session activation event

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
valueBound - notifies this context that it is being bound to a session and identifies the session

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - session binding event

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
valueUnbound - notifies this context that it is being unbound from a session and identifies the session

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - session binding event

getFolderPageHistory

private Map getFolderPageHistory()

setPipeline

public void setPipeline(String pipeline)
Specified by:
setPipeline in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext

getPipeline

public String getPipeline()
Specified by:
getPipeline in interface org.apache.jetspeed.portalsite.PortalSiteSessionContext


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.