DLESE Tools
v1.6.0

org.dlese.dpc.schemedit
Class SessionBean

java.lang.Object
  extended by org.dlese.dpc.schemedit.SessionBean
All Implemented Interfaces:
Serializable, EventListener, HttpSessionBindingListener

public class SessionBean
extends Object
implements HttpSessionBindingListener, Serializable

A Session-scoped Bean for information that needs to be available to different controllers and their jsp pages. Encapsulates access to servlet context attributes as well as session scope attributes, and provides other session-oriented services, such as

SessionBeans are bound to Session objects when they are created. This is done in SessionRegistry. Because they are bound to the session context, SessionBeans are available to jsp pages.

This class aims as much as possible to be a read-only structure that gets information from the application's form beans which are accessed via the session.

A tricky aspect of accessing Session attributes is that the session can be invalidated at any time (e.g., when a session times out). Thus, accesses to session attributes must be wrapped in a try statement that can catch a IllegalStateException exception. When such an exception is encountered, the SessionBean instance is destroyed. As a HttpSessionBindingListener, receives notification when attributes are bound to, or removed from, the session context.

Author:
ostwald
See Also:
Serialized Form

Nested Class Summary
static class SessionBean.IdComparator
          Implements Comparator to enable sorting by session id.
static class SessionBean.IdleTimeComparator
          Implements Comparator to enable sorting SessionBeans by their sessions idle time
 
Field Summary
 List creators
           
static String DEFAULT_REC_SORT
          Specifies the default sort order for display of records.
 List editors
           
 List indexedFormats
           
 
Constructor Summary
SessionBean()
          Argumentless Constructor for the SessionBean object.
SessionBean(HttpSession session, ServletContext servletContext)
          Constructor for the SessionBean object
 
Method Summary
 void clearSearchParams()
          Wipes out information about the last search.
 void destroy()
          Description of the Method
 List getAuthorizedCollections()
          Get the keys of the collections the sessionUser is authorized to access.
 boolean getBatchLocks(RecordList records)
           
 CollectionConfig getCollectionConfig(String collection)
          Gets the collectionConfig attribute of the SessionBean object
 long getCollectionConfigMod()
           
 org.apache.struts.util.LabelValueBean getCollectionFilter()
           
 List getCollectionLabelValues()
          Generate list of collections for use by jsp tags.
 CollectionRegistry getCollectionRegistry()
          Gets the collectionRegistry attribute of the SessionBean object
 String getCollectionsQueryClause()
          Return a query clause ORing together all the collections the current user is authorized to search over.
 List getCreators()
           
 DcsDataRecord getDcsDataRecord(String id)
          Get DcsDataRecord for the given id via the DcsDataManager
 List getEditors()
           
 RecordList getFailedBatchLocks()
          List of ids to records that could not be locked during getBatchLocks.
 String getFinalStatusLabel(String collection)
          Gets the finalStatusLabel attribute of the SessionBean object
 String getId()
          Gets the id of this session.
 String getInactiveIntervalRemaining()
          Gets the inactiveIntervalRemaining attribute of the SessionBean object
 List getIndexedFormats()
           
 long getIndexLastModified()
           
 String getIp()
          Gets the ip attribute of the SessionBean object
 Date getLastAccessedTime()
          Gets the lastAccessedTime attribute of the session as a Date.
 boolean getLock(String recId)
          Locks a record for this session through a call to SessionRegistry.getLock(String, String).
 List getLockedRecords()
          Gets the records locked by this session.
 int getNumSecsToTimeout()
          Returns the number of seconds left until this session times out.
 int getPaigingParam()
          Compute the start record index of the page on which the current record (recIndex) will be found.
 int getPaigingParam(String id)
          Compute the start record index of the page on which the specified record will be found.
 String getQueryUrl()
          Returns the url (decoded to preserve query string) that will reproduce the last query preformed on the search page.
 String getRecId()
          Gets the recId attribute of the SessionBean object, which keeps track of the record the user has last edited so that particular record can be highlighted in lists of records.
 RecordList getRecords()
          Provides access to current set of search results, which is updated by DCSQueryAction, but needed by other actions that need to operate over the results (e.g., BatchOperationsAction).
 HttpServletRequest getRequest()
          get the last request for this session - NOT currently used
 RoleManager getRoleManager()
          Gets the roleManager attribute of the SessionBean object
 SearchHelper getSearchHelper()
           
 String getSearchParams()
          A string representation (http request's query parameters) of the last search performed by the user.
 List getServletContextAttributeNames()
          Gets the AttributeNames defined in the servlet Context.
 HttpSession getSession()
          Gets the session attribute of the SessionBean object
 List getSessionAttributeNames()
          Gets the sessionAttributeNames of this session.
 SessionRegistry getSessionRegistry()
          Gets the Global SessionRegistry from the servlet context,
 List getSets()
          Gets a List of SetInfo objects that provide information about the collections known to RepositoryManager.
 Map getStatuses()
           
 SyncService getSyncService()
           
 String getTimeSinceCreation()
          Gets the timeSinceCreation attribute of the session as a formatted string.
 String getTimeSinceLastAccessed()
          Gets the timeSinceLastAccessed of the session as a formated String for use in jsp.
 User getUser()
           
 boolean isAuthorized(String operation)
          Gets the authorized attribute of the SessionBean object
 boolean isAuthorized(String operation, String collection)
          Gets the authorized attribute of the SessionBean object
 boolean isAuthorizedCollection(Roles.Role role, String collection)
           
 boolean isNew()
          Gets the new attribute of the SessionBean object
 boolean isQuerySelectorsInitialized()
           
 boolean ownsLock(String recId)
          Does this session own the lock for the record?
 boolean releaseAllLocks()
          Release all locks held by this session.
 boolean releaseLock(String recId)
          Release lock for given record.
 void setCollectionConfigMod(long mod)
           
 void setCreators(List creators)
           
 void setEditors(List editors)
           
 void setIndexedFormats(List formats)
           
 void setIndexLastModified(long mod)
           
 void setIp(String ip)
          Sets the ip attribute of the SessionBean object
 void setQuerySelectorsInitialized(boolean b)
           
 void setRecId(String id)
          Sets the recId attribute of the SessionBean object
 void setRequest(HttpServletRequest request)
          Sets the request attribute of the SessionBean object
 void setSets(List sets)
          Sets the sets attribute of the SessionBean object
 void setStatuses(Map statusMap)
           
 void setSyncService(SyncService svc)
           
 void updateCollectionFilter(String column, String value)
          The collectionFilter is used to filter UI displays using dcsTables
 void valueBound(HttpSessionBindingEvent event)
          Method called each time a attribute is bound to this SessionBean's session.
 void valueUnbound(HttpSessionBindingEvent event)
          Method called each time any attribute is removed from this SessionBean's session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REC_SORT

public static String DEFAULT_REC_SORT
Specifies the default sort order for display of records. Used in org.dlese.dpc.schemedit.action.form.DCSQueryForm#getSortRecsBy().


indexedFormats

public List indexedFormats

editors

public List editors

creators

public List creators
Constructor Detail

SessionBean

public SessionBean(HttpSession session,
                   ServletContext servletContext)
Constructor for the SessionBean object

Parameters:
session - Description of the Parameter
servletContext - Description of the Parameter

SessionBean

public SessionBean()
Argumentless Constructor for the SessionBean object.

Method Detail

updateCollectionFilter

public void updateCollectionFilter(String column,
                                   String value)
The collectionFilter is used to filter UI displays using dcsTables


getCollectionFilter

public org.apache.struts.util.LabelValueBean getCollectionFilter()

getSession

public HttpSession getSession()
Gets the session attribute of the SessionBean object

Returns:
The session value

getUser

public User getUser()

getRequest

public HttpServletRequest getRequest()
get the last request for this session - NOT currently used

Returns:
The request value

setRequest

public void setRequest(HttpServletRequest request)
Sets the request attribute of the SessionBean object

Parameters:
request - The new request value

setRecId

public void setRecId(String id)
Sets the recId attribute of the SessionBean object

Parameters:
id - The new recId value

getLastAccessedTime

public Date getLastAccessedTime()
Gets the lastAccessedTime attribute of the session as a Date.

Returns:
The lastAccessedTime value

getTimeSinceLastAccessed

public String getTimeSinceLastAccessed()
Gets the timeSinceLastAccessed of the session as a formated String for use in jsp.

Returns:
The timeSinceLastAccessed value

getNumSecsToTimeout

public int getNumSecsToTimeout()
Returns the number of seconds left until this session times out. Dependent on the session's MaxInactiveInterval

Returns:
The numSecsToTimeout value

isNew

public boolean isNew()
Gets the new attribute of the SessionBean object

Returns:
The new value

getInactiveIntervalRemaining

public String getInactiveIntervalRemaining()
Gets the inactiveIntervalRemaining attribute of the SessionBean object

Returns:
The inactiveIntervalRemaining value

getTimeSinceCreation

public String getTimeSinceCreation()
Gets the timeSinceCreation attribute of the session as a formatted string.

Returns:
The timeSinceCreation value

getRecId

public String getRecId()
Gets the recId attribute of the SessionBean object, which keeps track of the record the user has last edited so that particular record can be highlighted in lists of records.

Returns:
The recId value

getId

public String getId()
Gets the id of this session.

Returns:
The sessionId value

getIp

public String getIp()
Gets the ip attribute of the SessionBean object

Returns:
The ip value

setIp

public void setIp(String ip)
Sets the ip attribute of the SessionBean object

Parameters:
ip - The new ip value

getLockedRecords

public List getLockedRecords()
Gets the records locked by this session.

Returns:
A List of record Ids

valueBound

public void valueBound(HttpSessionBindingEvent event)
Method called each time a attribute is bound to this SessionBean's session.

This method is not currently used ...

Specified by:
valueBound in interface HttpSessionBindingListener
Parameters:
event - Description of the Parameter

valueUnbound

public void valueUnbound(HttpSessionBindingEvent event)
Method called each time any attribute is removed from this SessionBean's session.

This method is not currently used ...

Specified by:
valueUnbound in interface HttpSessionBindingListener
Parameters:
event - Description of the Parameter

getDcsDataRecord

public DcsDataRecord getDcsDataRecord(String id)
Get DcsDataRecord for the given id via the DcsDataManager

Parameters:
id - Description of the Parameter
Returns:
The dcsDataRecord value

getServletContextAttributeNames

public List getServletContextAttributeNames()
Gets the AttributeNames defined in the servlet Context.

Returns:
A list of attribute names

ownsLock

public boolean ownsLock(String recId)
Does this session own the lock for the record?

Parameters:
recId - Description of the Parameter
Returns:
Description of the Return Value

releaseLock

public boolean releaseLock(String recId)
Release lock for given record.

Parameters:
recId - Id of record to release
Returns:
Description of the Return Value

releaseAllLocks

public boolean releaseAllLocks()
Release all locks held by this session.

Returns:
Description of the Return Value

getLock

public boolean getLock(String recId)
Locks a record for this session through a call to SessionRegistry.getLock(String, String).

Parameters:
recId - Description of the Parameter
Returns:
The lock value

getFailedBatchLocks

public RecordList getFailedBatchLocks()
List of ids to records that could not be locked during getBatchLocks.

Returns:
a list of ResultDoc instances.
See Also:
#getBatchLocks(ResultDoc[])

getBatchLocks

public boolean getBatchLocks(RecordList records)

isAuthorized

public boolean isAuthorized(String operation)
Gets the authorized attribute of the SessionBean object

Parameters:
operation - Description of the Parameter
Returns:
The authorized value

isAuthorized

public boolean isAuthorized(String operation,
                            String collection)
Gets the authorized attribute of the SessionBean object

Parameters:
operation - Description of the Parameter
collection - Description of the Parameter
Returns:
The authorized value

isAuthorizedCollection

public boolean isAuthorizedCollection(Roles.Role role,
                                      String collection)

getSessionAttributeNames

public List getSessionAttributeNames()
Gets the sessionAttributeNames of this session.

Returns:
The sessionAttributeNames value

getSessionRegistry

public SessionRegistry getSessionRegistry()
Gets the Global SessionRegistry from the servlet context,

Returns:
The sessionRegistry value

getRoleManager

public RoleManager getRoleManager()
Gets the roleManager attribute of the SessionBean object

Returns:
The roleManager value

getCollectionRegistry

public CollectionRegistry getCollectionRegistry()
Gets the collectionRegistry attribute of the SessionBean object

Returns:
The collectionRegistry value

getCollectionConfig

public CollectionConfig getCollectionConfig(String collection)
Gets the collectionConfig attribute of the SessionBean object

Parameters:
collection - Description of the Parameter
Returns:
The collectionConfig value

getFinalStatusLabel

public String getFinalStatusLabel(String collection)
Gets the finalStatusLabel attribute of the SessionBean object

Parameters:
collection - Description of the Parameter
Returns:
The finalStatusLabel value

getSearchHelper

public SearchHelper getSearchHelper()

getRecords

public RecordList getRecords()
Provides access to current set of search results, which is updated by DCSQueryAction, but needed by other actions that need to operate over the results (e.g., BatchOperationsAction).


getSearchParams

public String getSearchParams()
A string representation (http request's query parameters) of the last search performed by the user.

Enables system to take user back to the last search they performed. For example,searchParams is used by the "Search" link in the page header, so when user returns to search it is as they left it. queryForm

Returns:
The part of a url that specifies a search

clearSearchParams

public void clearSearchParams()
Wipes out information about the last search.


getPaigingParam

public int getPaigingParam()
Compute the start record index of the page on which the current record (recIndex) will be found.

Returns:
The paigingParam value

getPaigingParam

public int getPaigingParam(String id)
Compute the start record index of the page on which the specified record will be found.

Parameters:
id - Description of the Parameter
Returns:
The paigingParam value

getQueryUrl

public String getQueryUrl()
Returns the url (decoded to preserve query string) that will reproduce the last query preformed on the search page.


getSets

public List getSets()
Gets a List of SetInfo objects that provide information about the collections known to RepositoryManager.

NOTE: why isn't the set list encapsulated by CollectionRegistry, and the SetInfos themselves by CollectionConfig. Then, the CollectionRegistry would be accessed through the servlet context.

Returns:
A List of SetInfo objects.

setSets

public void setSets(List sets)
Sets the sets attribute of the SessionBean object

Parameters:
sets - The new sets value

getAuthorizedCollections

public List getAuthorizedCollections()
Get the keys of the collections the sessionUser is authorized to access.

Parameters:
sessionBean - NOT YET DOCUMENTED
Returns:
The authorizedCollections value

getCollectionsQueryClause

public String getCollectionsQueryClause()
Return a query clause ORing together all the collections the current user is authorized to search over.

Parameters:
sessionBean - NOT YET DOCUMENTED
Returns:
The collectionsQueryClause value

isQuerySelectorsInitialized

public boolean isQuerySelectorsInitialized()

setQuerySelectorsInitialized

public void setQuerySelectorsInitialized(boolean b)

getIndexLastModified

public long getIndexLastModified()

setIndexLastModified

public void setIndexLastModified(long mod)

getCollectionConfigMod

public long getCollectionConfigMod()

setCollectionConfigMod

public void setCollectionConfigMod(long mod)

getStatuses

public Map getStatuses()

setStatuses

public void setStatuses(Map statusMap)

getIndexedFormats

public List getIndexedFormats()

setIndexedFormats

public void setIndexedFormats(List formats)

getEditors

public List getEditors()

setEditors

public void setEditors(List editors)

getCreators

public List getCreators()

setCreators

public void setCreators(List creators)

getCollectionLabelValues

public List getCollectionLabelValues()
Generate list of collections for use by jsp tags. Note: this could also be done by CollectionRegistry?

Returns:
The collectionLabelValues value

getSyncService

public SyncService getSyncService()

setSyncService

public void setSyncService(SyncService svc)

destroy

public void destroy()
Description of the Method


DLESE Tools
v1.6.0