com.filenet.wcm.toolkit.server.util
Class WcmDataStore

java.lang.Object
  extended bycom.filenet.wcm.toolkit.server.util.WcmDataStore
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, java.io.Serializable
Direct Known Subclasses:
ControllerUtilities.PropertiesMap

public class WcmDataStore
extends java.lang.Object
implements javax.servlet.http.HttpSessionBindingListener, java.io.Serializable

WcmDataStore is a utility class that holds data across requests for a client session.

See Also:
Serialized Form

Nested Class Summary
protected static class WcmDataStore.DummyOutputStream
           
 
Field Summary
static java.lang.String BASE_LOCALPATH_KEY
          Deprecated. use
static java.lang.String BASE_URL_KEY
          The application's base URL as computed from the request.
static int BASIC_VALIDATION
           
protected  java.util.Map datastoreTable
           
protected  boolean initialized
           
static int NO_VALIDATION
           
static int THOROUGH_VALIDATION
           
static java.lang.String URL_HOST_KEY
          The URL_HOST_KEY contains the host name that appears on the URL.
static java.lang.String URL_PORT_KEY
          The URL_PORT_KEY contains the port number part, if any.
static java.lang.String URL_ROOT_KEY
          The URL_ROOT_KEY contains the web application name part.
static java.lang.String USER_CREDENTIALS_KEY
          A web session's user credentials that can be retrieved easily.
protected static int validateMode
           
 
Constructor Summary
WcmDataStore()
           
 
Method Summary
static void clear(javax.servlet.http.HttpServletRequest request)
           
 boolean containsKey(java.lang.String key)
          Check to see if the named key exists in the Data Store.
static WcmDataStore get(javax.servlet.http.HttpServletRequest request)
          Get the datastore instance for this user session, skip initialization & just return it.
static WcmDataStore get(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request)
          Static factory method for getting a Data Store for the current session.
static WcmDataStore get(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request, boolean forceInit)
          Static factory method for getting a Data Store for the current session.
 java.util.Locale getClientLocale()
           
 java.util.Set getKeys()
          Returns all keys in the Data Store.
 java.util.List getKeysStartingWith(java.lang.String sStartsWith, boolean bReturnUniqueParts)
          Returns keys in the Data Store that start with a specified string.
 WcmServerCredentials getServerCredentials()
          Shortcut to (WcmDataStoreCredentials) dataStore.getValue(WcmDataStore.USER_CREDENTIALS_KEY);
 java.lang.Object getValue(java.lang.String key)
          Method for retrieving the corresponding value associated with a key from the Data Store.
 java.lang.Object getValue(java.lang.String key, java.lang.Object defaultValue)
           
 void init(javax.servlet.ServletContext application, javax.servlet.http.HttpServletRequest request)
          Initialize globals
 java.lang.Object remove(java.lang.String key)
          Method for removing a key and corresponding value from the Data Store.
static void setValidateMode(int mode)
          For application testing, enables validation of incoming objects to verify that they are serializable.
 java.lang.Object setValue(java.lang.String key, java.lang.Object value)
          Method for adding a key with associated value into the Data Store.
 java.lang.Object setValue(java.lang.String key, java.lang.Object value, boolean bForCache)
          Method for adding a key with associated value into the Data Store.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
          This is a stubbed implementation in order to support the HttpSessionBindingListener interface.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
          This is an implementation of HttpSessionBindingListener.valueUnbound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_URL_KEY

public static final java.lang.String BASE_URL_KEY
The application's base URL as computed from the request. The BASE_URL_KEY contains the protocol, the domain host, and the web application.
e.g. http://<host>[:<port>]/<webapp>

See Also:
Constant Field Values

URL_PORT_KEY

public static final java.lang.String URL_PORT_KEY
The URL_PORT_KEY contains the port number part, if any.

See Also:
Constant Field Values

URL_ROOT_KEY

public static final java.lang.String URL_ROOT_KEY
The URL_ROOT_KEY contains the web application name part.

See Also:
Constant Field Values

URL_HOST_KEY

public static final java.lang.String URL_HOST_KEY
The URL_HOST_KEY contains the host name that appears on the URL.

See Also:
Constant Field Values

BASE_LOCALPATH_KEY

public static final java.lang.String BASE_LOCALPATH_KEY
Deprecated. use

See Also:
Constant Field Values

USER_CREDENTIALS_KEY

public static final java.lang.String USER_CREDENTIALS_KEY
A web session's user credentials that can be retrieved easily. It also contains the user's logon session to be used to pass to the JavaAPI.

See Also:
WcmServerCredentials, Constant Field Values

NO_VALIDATION

public static final int NO_VALIDATION
See Also:
Constant Field Values

BASIC_VALIDATION

public static final int BASIC_VALIDATION
See Also:
Constant Field Values

THOROUGH_VALIDATION

public static final int THOROUGH_VALIDATION
See Also:
Constant Field Values

validateMode

protected static int validateMode

datastoreTable

protected transient java.util.Map datastoreTable

initialized

protected boolean initialized
Constructor Detail

WcmDataStore

public WcmDataStore()
Method Detail

init

public void init(javax.servlet.ServletContext application,
                 javax.servlet.http.HttpServletRequest request)
Initialize globals


get

public static WcmDataStore get(javax.servlet.ServletContext application,
                               javax.servlet.http.HttpServletRequest request)
Static factory method for getting a Data Store for the current session.

Parameters:
application - ServletContext object
request - HttpServletRequest object
Returns:
Data Store.

get

public static WcmDataStore get(javax.servlet.ServletContext application,
                               javax.servlet.http.HttpServletRequest request,
                               boolean forceInit)
Static factory method for getting a Data Store for the current session.

Parameters:
application - ServletContext object
request - HttpServletRequest object
forceInit - Set to "true" to force initialization of global keys.
Returns:
Data Store.

get

public static WcmDataStore get(javax.servlet.http.HttpServletRequest request)
Get the datastore instance for this user session, skip initialization & just return it.

Parameters:
request -
Returns:

clear

public static void clear(javax.servlet.http.HttpServletRequest request)

getValue

public java.lang.Object getValue(java.lang.String key)
Method for retrieving the corresponding value associated with a key from the Data Store.

Parameters:
key - A string representing a key into the Data Store. The Data Store initially contains the following global keys:
  • WcmDataStore.BASE_URL_KEY
  • WcmDataStore.URL_PORT_KEY
  • WcmDataStore.URL_ROOT_KEY
  • WcmDataStore.BASE_LOCALPATH_KEY
Also, USER_CREDENTIALS_KEY is the key for holding the user credentials object of the user's logon session.
Returns:
The value, if a matching key is found, else null is returned.
See Also:
WcmServerCredentials

getValue

public java.lang.Object getValue(java.lang.String key,
                                 java.lang.Object defaultValue)
Parameters:
key - A string representing a key into the Data Store.
defaultValue - return value, if the value for the given key is not found in the Data Store
Returns:
The value, if matching key is found, else return back the defaultValue specified.
See Also:
getValue(String)

setValue

public java.lang.Object setValue(java.lang.String key,
                                 java.lang.Object value)
                          throws WcmException
Method for adding a key with associated value into the Data Store.

Parameters:
key - If key does not exist, a new key is added and value is associated. If key already exists, value will be overwritten without error.
value - Any non-null object can be provided as value. If key or value is null, then WcmException is thrown.
Returns:
The previous value associated with the specified key, or null if it does not have one.
Throws:
WcmException

setValue

public java.lang.Object setValue(java.lang.String key,
                                 java.lang.Object value,
                                 boolean bForCache)
                          throws WcmException
Method for adding a key with associated value into the Data Store.

Parameters:
key - If key does not exist, a new key is added and value is associated. If key already exists, value will be overwritten without error.
value - Any non-null object can be provided as value. If key or value is null, then WcmException is thrown.
bForCache - if this is true, the value will be added as a Soft Reference. That means, if the memory gets low, the value will be automatically removed.
Returns:
The previous value associated with the specified key, or null if it does not have one.
Throws:
WcmException

setValidateMode

public static void setValidateMode(int mode)
For application testing, enables validation of incoming objects to verify that they are serializable. By default this feature is disabled. Three possible mode values are defined static on WcmDataStore:

Parameters:
mode -

remove

public java.lang.Object remove(java.lang.String key)
Method for removing a key and corresponding value from the Data Store.

Parameters:
key - A string representing a key into the Data Store.
Returns:
The previous value associated with the specified key, or null if the key does not exist.

containsKey

public boolean containsKey(java.lang.String key)
Check to see if the named key exists in the Data Store.

Parameters:
key - A string representing a key into the Data Store.
Returns:
boolean true if the key exists, false if not.

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
This is a stubbed implementation in order to support the HttpSessionBindingListener interface.

HttpSessionBindingListener is supported by WcmDataStore in order to provide support for WcmDataStoreBindingListener.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - A reference to the associated HttpSessionBindingEvent.

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
This is an implementation of HttpSessionBindingListener.valueUnbound.

This method is called when the Java™Server Pages (JSP) session is ending, and indicates to WcmDataStore that it should propagate "valueUnbound" messages to all of the objects that it is storing that implement WcmDataStoreBindingListener.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
event - A reference to the associated HttpSessionBindingEvent.

getKeys

public java.util.Set getKeys()
Returns all keys in the Data Store.

Returns:
Set

getServerCredentials

public WcmServerCredentials getServerCredentials()
Shortcut to (WcmDataStoreCredentials) dataStore.getValue(WcmDataStore.USER_CREDENTIALS_KEY);

Returns:
WcmServerCredentials object

getKeysStartingWith

public java.util.List getKeysStartingWith(java.lang.String sStartsWith,
                                          boolean bReturnUniqueParts)
Returns keys in the Data Store that start with a specified string.

Parameters:
sStartsWith - keys must start with this string to be included.
bReturnUniqueParts - true if you want only unique keys returned. For example, if you have keys named a.b.c and a.b.x in the Data Store, with bReturnUniqueParts = true and sStartsWith = "a.b." the method will return a list with "c" and "x". Otherwise it would return a list with "a.b.c" and "a.b.x".
Returns:
List

getClientLocale

public java.util.Locale getClientLocale()


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.