com.wewebu.ow.server.util.paramcodec
Class OwAttributeBagCodec

java.lang.Object
  extended by com.wewebu.ow.server.util.paramcodec.OwCookieStoreCodec
      extended by com.wewebu.ow.server.util.paramcodec.OwAttributeBagCodec
All Implemented Interfaces:
OwParameterMapCodec
Direct Known Subclasses:
OwAppCounterBag, OwNetworkAttributeBagCodec

public abstract class OwAttributeBagCodec
extends OwCookieStoreCodec

An OwCookieStoreCodec implementation that stores cookies using the Alfresco Workdesk attribute bag mechanism.
The codec uses a bag for the unique index storage ( the master bag) and another bag for cookie expiration time storage (the cookie table bag).
Cookie mapped values are stored in individual bags with map parameter mapped to bag parameters. The codec does no support multiple value parameters.
The index name uniqueness is guaranteed per virtual machine.
Attribute bag access is also synchronized per virtual machine.
This codec is not suitable for cluster based usage.
OwAttributeBag instance access is delegated to subclasses.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com

Since:
3.0.0.0
See Also:
OwAttributeBag, OwAttributeBagWriteable

Nested Class Summary
 
Nested classes/interfaces inherited from class com.wewebu.ow.server.util.paramcodec.OwCookieStoreCodec
OwCookieStoreCodec.OwTimedCookie, OwCookieStoreCodec.OwTimedCookieValue
 
Field Summary
static String CONFIGURATION_ATTRIBUTEBAGS_ELEMENT
           
static String CONFIGURATION_CODEC_PREFIX_ATTRIBUTE
           
static String CONFIGURATION_COOKIE_PREFIX_ATTRIBUTE
           
static String CONFIGURATION_USER_ATTRIBUTE
           
static String DEFAULT_CODEC_BAGS_PREFIX
           
static String DEFAULT_CONFIG_BAG_USER_NAME
           
static String DEFAULT_COOKIE_BAGS_PREFIX
           
 
Fields inherited from class com.wewebu.ow.server.util.paramcodec.OwCookieStoreCodec
CONFIGURATION_BOOTSTRAP_ELEMENT_NAME, CONFIGURATION_DAYS_ATTRIBUTE, CONFIGURATION_HOURS_ATTRIBUTE, CONFIGURATION_MINUTES_ATTRIBUTE, CONFIGURATION_NAME_ATTRIBUTE, CONFIGURATION_SECONDS_ATTRIBUTE, CONFIGURATION_URL_LIFE_TIME_ELEMENT, CONFIGURATION_URL_PARAMETER_ELEMENT, DEFAULT_CONFIG_URL_LIFE_TIME, DEFAULT_URL_PARAMETER_NAME
 
Constructor Summary
OwAttributeBagCodec(String cookieParameterName_p, long namesExpirationTime_p, String codecBagsPrefix_p, String cookieBagsPrefix_p)
          Constructor
 
Method Summary
protected  void addCookieValue(OwCookieStoreCodec.OwTimedCookieValue timedCookieValue_p)
          Adds the given OwCookieStoreCodec.OwTimedCookieValue to the cookie store
protected  String cookieBagName(String cookieName_p)
           
protected  String cookieTableBagName()
           
protected  List createTimedCookieCollectList()
          Hook method that returns a list of OwCookieStoreCodec.OwTimedCookies to be collected.
protected abstract  OwAttributeBagWriteable getBag(String bagName_p, boolean create_p)
           
protected  OwAttributeBagWriteable getCookieBag(String cookieName_p, boolean create_p)
           
protected  OwAttributeBagWriteable getCookieTableBag()
           
protected  OwCookieStoreCodec.OwTimedCookieValue getCookieValue(String cookieName_p)
           
protected  long getInitialValueForIndex()
          Get the start value for index.
protected  OwAttributeBagWriteable getMasterBag()
           
 long getNextUnqiueNameIndex()
          Get the next available unique index.
static String[] loadAttributeBagsConfiguation(OwXMLUtil codecConfiguration_p)
          Loads the AttributeBags XML configuration element.
The expected XML structure is the following : AttributeBags - tag
Configures the attribute bag storage name for the parameters maps.
In order to prevent name conflicts in attribute bags usage unique bag names prefixes should
be specified here.

Attributes :
codecprefix = a string prefix to be used in codec internal bag names
cookieprefix = a string prefix to be used in codec internal bag names that will store
cookie based parameter maps
user = user to be used when storing codec attribute bags
protected  String masterBagName()
           
protected  void remove(OwCookieStoreCodec.OwTimedCookie timedCookie_p)
          Removes the given OwCookieStoreCodec.OwTimedCookie from cookie storage.
 
Methods inherited from class com.wewebu.ow.server.util.paramcodec.OwCookieStoreCodec
canDecode, collectExpiredNames, createCookie, decode, encode, loadUrlLifeTimeConfig, loadUrlParameterConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CODEC_BAGS_PREFIX

public static final String DEFAULT_CODEC_BAGS_PREFIX
See Also:
Constant Field Values

DEFAULT_COOKIE_BAGS_PREFIX

public static final String DEFAULT_COOKIE_BAGS_PREFIX
See Also:
Constant Field Values

DEFAULT_CONFIG_BAG_USER_NAME

public static final String DEFAULT_CONFIG_BAG_USER_NAME
See Also:
Constant Field Values

CONFIGURATION_ATTRIBUTEBAGS_ELEMENT

public static final String CONFIGURATION_ATTRIBUTEBAGS_ELEMENT
See Also:
Constant Field Values

CONFIGURATION_CODEC_PREFIX_ATTRIBUTE

public static final String CONFIGURATION_CODEC_PREFIX_ATTRIBUTE
See Also:
Constant Field Values

CONFIGURATION_COOKIE_PREFIX_ATTRIBUTE

public static final String CONFIGURATION_COOKIE_PREFIX_ATTRIBUTE
See Also:
Constant Field Values

CONFIGURATION_USER_ATTRIBUTE

public static final String CONFIGURATION_USER_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

OwAttributeBagCodec

public OwAttributeBagCodec(String cookieParameterName_p,
                           long namesExpirationTime_p,
                           String codecBagsPrefix_p,
                           String cookieBagsPrefix_p)
Constructor

Parameters:
cookieParameterName_p - name of the encoded URL parameter
namesExpirationTime_p - the time in which a cookie will expire (in milliseconds)
codecBagsPrefix_p - String prefix to be used with the index bag name and the cookie times table bag
cookieBagsPrefix_p - String prefix to be used in creation of the individual cookie bags
Method Detail

loadAttributeBagsConfiguation

public static String[] loadAttributeBagsConfiguation(OwXMLUtil codecConfiguration_p)
                                              throws Exception
Loads the AttributeBags XML configuration element.
The expected XML structure is the following : AttributeBags - tag
Configures the attribute bag storage name for the parameters maps.
In order to prevent name conflicts in attribute bags usage unique bag names prefixes should
be specified here.

Attributes :
codecprefix = a string prefix to be used in codec internal bag names
cookieprefix = a string prefix to be used in codec internal bag names that will store
cookie based parameter maps
user = user to be used when storing codec attribute bags

Parameters:
codecConfiguration_p -
Returns:
a String array of 3 Strings with the following meaning :
[0] - the configured codec bags prefix
[1] - the configured cookie bags prefix
[2] - the configured attribute bags user
Throws:
Exception

masterBagName

protected String masterBagName()
Returns:
the master bag name

cookieTableBagName

protected String cookieTableBagName()
Returns:
the cookie table bag name

cookieBagName

protected String cookieBagName(String cookieName_p)
Parameters:
cookieName_p -
Returns:
the name of the bag that stores the given cookie

getBag

protected abstract OwAttributeBagWriteable getBag(String bagName_p,
                                                  boolean create_p)
                                           throws Exception
Parameters:
bagName_p -
create_p - if true the given bag should be created if not found
Returns:
the bag with the given name
Throws:
Exception

getMasterBag

protected OwAttributeBagWriteable getMasterBag()
                                        throws Exception
Returns:
the master bag
Throws:
Exception

getCookieTableBag

protected OwAttributeBagWriteable getCookieTableBag()
                                             throws Exception
Returns:
the cookie table bag
Throws:
Exception

getCookieBag

protected OwAttributeBagWriteable getCookieBag(String cookieName_p,
                                               boolean create_p)
                                        throws Exception
Parameters:
cookieName_p -
create_p -
Returns:
the bag that stores the cookie with the given name
Throws:
Exception

addCookieValue

protected void addCookieValue(OwCookieStoreCodec.OwTimedCookieValue timedCookieValue_p)
                       throws OwException
Description copied from class: OwCookieStoreCodec
Adds the given OwCookieStoreCodec.OwTimedCookieValue to the cookie store

Specified by:
addCookieValue in class OwCookieStoreCodec
Throws:
OwException

createTimedCookieCollectList

protected List createTimedCookieCollectList()
                                     throws OwException
Description copied from class: OwCookieStoreCodec
Hook method that returns a list of OwCookieStoreCodec.OwTimedCookies to be collected.

Specified by:
createTimedCookieCollectList in class OwCookieStoreCodec
Returns:
a List of OwCookieStoreCodec.OwTimedCookie
Throws:
OwException - if the collect List creation fails
See Also:
OwCookieStoreCodec.collectExpiredNames()

getCookieValue

protected OwCookieStoreCodec.OwTimedCookieValue getCookieValue(String cookieName_p)
                                                        throws OwException
Specified by:
getCookieValue in class OwCookieStoreCodec
Returns:
the OwCookieStoreCodec.OwTimedCookieValue for the given cookie
Throws:
OwException

remove

protected void remove(OwCookieStoreCodec.OwTimedCookie timedCookie_p)
               throws OwException
Description copied from class: OwCookieStoreCodec
Removes the given OwCookieStoreCodec.OwTimedCookie from cookie storage.

Specified by:
remove in class OwCookieStoreCodec
Throws:
OwException

getNextUnqiueNameIndex

public long getNextUnqiueNameIndex()
                            throws OwException
Description copied from interface: OwParameterMapCodec
Get the next available unique index.

Returns:
a unique long index
Throws:
OwException

getInitialValueForIndex

protected long getInitialValueForIndex()
Get the start value for index.

Returns:
- the start value for index, used in case the attribute bag has no value set.


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.