org.opencms.ade.containerpage.inherited
Class CmsContainerConfigurationCache

java.lang.Object
  extended by org.opencms.ade.containerpage.inherited.CmsContainerConfigurationCache
All Implemented Interfaces:
I_CmsGlobalConfigurationCache

public class CmsContainerConfigurationCache
extends java.lang.Object
implements I_CmsGlobalConfigurationCache

A cache class for storing inherited container configurations.


Field Summary
static java.lang.String INHERITANCE_CONFIG_FILE_NAME
          The standard file name for inherited container configurations.
static org.apache.commons.logging.Log LOG
          The logger instance for this class.
protected  boolean m_initialized
          A flag which indicates whether this cache is initialized.
 
Constructor Summary
CmsContainerConfigurationCache(CmsObject cms, java.lang.String name)
          Creates a new cache instance for inherited containers.
 
Method Summary
 void clear()
          Clears the cache.
protected  java.lang.String getBasePath(java.lang.String rootPath)
          Returns the base path for a given configuration file.
protected  java.lang.String getCacheKey(java.lang.String basePath)
          Gets the cache key for a given base path.
 CmsContainerConfiguration getContainerConfiguration(java.lang.String rootPath, java.lang.String name, java.util.Locale locale)
          Gets the container configuration for a given root path, name and locale.
 void initialize()
          Initializes the cache.
protected  boolean isContainerConfiguration(java.lang.String rootPath, int type)
          Checks whethet a given combination of path and resource type belongs to an inherited container configuration file.
protected  void load(CmsResource configResource)
          Loads a single configuration file into the cache.
protected  void readRemainingConfigurations()
          Reads the configurations needed to make the cache up-to-date.
 void remove(CmsPublishedResource resource)
          Removes a published resource from the cache.
 void remove(CmsResource resource)
          Removes a resource from the cache.
protected  void remove(CmsUUID structureId, java.lang.String rootPath, int type)
          Removes a resource from the cache.
protected  int safeGetType()
          Either gets the configuration type id, or returns -1 if the type hasn't been loaded yet.
 void update(CmsPublishedResource resource)
          Updates the cache entry for the given published resource.
 void update(CmsResource resource)
          Updates the cache entry for the given resource.
protected  void update(CmsUUID structureId, java.lang.String rootPath, int type, CmsResourceState state)
          Updates a resource in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INHERITANCE_CONFIG_FILE_NAME

public static final java.lang.String INHERITANCE_CONFIG_FILE_NAME
The standard file name for inherited container configurations.

See Also:
Constant Field Values

LOG

public static final org.apache.commons.logging.Log LOG
The logger instance for this class.


m_initialized

protected boolean m_initialized
A flag which indicates whether this cache is initialized.

Constructor Detail

CmsContainerConfigurationCache

public CmsContainerConfigurationCache(CmsObject cms,
                                      java.lang.String name)
                               throws CmsException
Creates a new cache instance for inherited containers.

Parameters:
cms - the CMS context to use for VFS operations.
name - the name of the cache, for debugging/testing purposes
Throws:
CmsException - if something goes wrong
Method Detail

clear

public void clear()
Description copied from interface: I_CmsGlobalConfigurationCache
Clears the cache.

Specified by:
clear in interface I_CmsGlobalConfigurationCache
See Also:
I_CmsGlobalConfigurationCache.clear()

getContainerConfiguration

public CmsContainerConfiguration getContainerConfiguration(java.lang.String rootPath,
                                                           java.lang.String name,
                                                           java.util.Locale locale)
Gets the container configuration for a given root path, name and locale.

Parameters:
rootPath - the root path
name - the configuration name
locale - the locale to use
Returns:
the container configuration for the given combination of parameters

initialize

public void initialize()
Initializes the cache.


remove

public void remove(CmsPublishedResource resource)
Description copied from interface: I_CmsGlobalConfigurationCache
Removes a published resource from the cache.

Specified by:
remove in interface I_CmsGlobalConfigurationCache
Parameters:
resource - the published resource
See Also:
I_CmsGlobalConfigurationCache.remove(org.opencms.db.CmsPublishedResource)

remove

public void remove(CmsResource resource)
Description copied from interface: I_CmsGlobalConfigurationCache
Removes a resource from the cache.

Specified by:
remove in interface I_CmsGlobalConfigurationCache
Parameters:
resource - the resource to remove
See Also:
I_CmsGlobalConfigurationCache.remove(org.opencms.file.CmsResource)

update

public void update(CmsPublishedResource resource)
Description copied from interface: I_CmsGlobalConfigurationCache
Updates the cache entry for the given published resource.

NOTE: Cache implementations should not directly read the updated resource in this method because it might interfere with other caches. Instead, the resource should be marked as updated and read the next time the cache is queried.

Specified by:
update in interface I_CmsGlobalConfigurationCache
Parameters:
resource - a published resource
See Also:
I_CmsGlobalConfigurationCache.update(org.opencms.db.CmsPublishedResource)

update

public void update(CmsResource resource)
Description copied from interface: I_CmsGlobalConfigurationCache
Updates the cache entry for the given resource.

NOTE: Cache implementations should not directly read the updated resource in this method because it might interfere with other caches. Instead, the resource should be marked as updated and read the next time the cache is queried.

Specified by:
update in interface I_CmsGlobalConfigurationCache
Parameters:
resource - the resource for which the cache entry should be updated
See Also:
I_CmsGlobalConfigurationCache.update(org.opencms.file.CmsResource)

getBasePath

protected java.lang.String getBasePath(java.lang.String rootPath)
Returns the base path for a given configuration file. E.g. the result for the input '/sites/default/.container-config' will be '/sites/default'.

Parameters:
rootPath - the root path of the configuration file
Returns:
the base path for the configuration file

getCacheKey

protected java.lang.String getCacheKey(java.lang.String basePath)
Gets the cache key for a given base path.

Parameters:
basePath - the base path
Returns:
the cache key for the base path

isContainerConfiguration

protected boolean isContainerConfiguration(java.lang.String rootPath,
                                           int type)
Checks whethet a given combination of path and resource type belongs to an inherited container configuration file.

Parameters:
rootPath - the root path of the resource
type - the type id of the resource
Returns:
true if the given root path / type combination matches an inherited container configuration file

load

protected void load(CmsResource configResource)
Loads a single configuration file into the cache.

Parameters:
configResource - the configuration resource

readRemainingConfigurations

protected void readRemainingConfigurations()
Reads the configurations needed to make the cache up-to-date.


remove

protected void remove(CmsUUID structureId,
                      java.lang.String rootPath,
                      int type)
Removes a resource from the cache.

Parameters:
structureId - the structure id of the resource
rootPath - the root path of the resource
type - the resource type

safeGetType

protected int safeGetType()
Either gets the configuration type id, or returns -1 if the type hasn't been loaded yet.

Returns:
the configuration type id or -1

update

protected void update(CmsUUID structureId,
                      java.lang.String rootPath,
                      int type,
                      CmsResourceState state)
Updates a resource in the cache.

Parameters:
structureId - the structure id of the resource
rootPath - the root path of the resource
type - the resource type
state - the resource state