Class CmsFlexBucketConfiguration


  • public class CmsFlexBucketConfiguration
    extends java.lang.Object
    Represents a Flex bucket configuration.

    This consists of a list of flex bucket definitions, and a 'clear all' list.

    Each flex bucket definition consists of a name and a list of paths. If any resources from the given list of paths or their descendants is published, the corresponding Flex bucket's contents should be removed from the Flex cache. If a resource with its path below one of the paths from the 'clear all' list is published, the complete Flex cache should be cleared.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BUCKET_OTHER
      Special bucket name for everything that doesn't belong in any other bucket.
      static java.lang.String KEY_CLEAR_ALL
      Configuration key for the list of folders for which the whole flex cache should be purged when a resource in them is published.
      static java.lang.String KEY_PREFIX_BUCKET
      The configuration key prefix used to define a bucket.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String key, java.util.List<java.lang.String> values)
      Adds a flex bucket definition, consisting of a flex bucket name and a list of paths.
      void freeze()
      Freeze the bucket configuration, i.e.
      java.lang.String getBucketName​(int bitIndex)
      Gets the bucket name for the given bit index.
      CmsFlexBucketConfiguration.BucketSet getBucketSet​(java.lang.Iterable<java.lang.String> paths)
      Computes the bucket set for a set of paths based on this configuration.
      static CmsFlexBucketConfiguration loadFromProperties​(java.util.Properties properties)
      Loads the flex bucket configuration from a java.util.Properties instance.
      static CmsFlexBucketConfiguration loadFromVfsFile​(CmsObject cms, java.lang.String path)
      Loads a flex bucket configuration from the OpenCms VFS.
      void setClearAll​(java.util.List<java.lang.String> clearAll)
      Sets the 'clear all' list, a list of paths for which the complete Flex cache should be cleared if any resource below them is published.
      boolean shouldClearAll​(java.util.List<CmsPublishedResource> publishedResources)
      Returns true if for the given publish list, the complete Flex cache should be cleared based on this configuration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BUCKET_OTHER

        public static final java.lang.String BUCKET_OTHER
        Special bucket name for everything that doesn't belong in any other bucket.
        See Also:
        Constant Field Values
      • KEY_CLEAR_ALL

        public static final java.lang.String KEY_CLEAR_ALL
        Configuration key for the list of folders for which the whole flex cache should be purged when a resource in them is published.
        See Also:
        Constant Field Values
    • Method Detail

      • loadFromProperties

        public static CmsFlexBucketConfiguration loadFromProperties​(java.util.Properties properties)
        Loads the flex bucket configuration from a java.util.Properties instance.

        Parameters:
        properties - the properties from which to load the configuration
        Returns:
        the configuration
      • loadFromVfsFile

        public static CmsFlexBucketConfiguration loadFromVfsFile​(CmsObject cms,
                                                                 java.lang.String path)
                                                          throws CmsException
        Loads a flex bucket configuration from the OpenCms VFS.

        Parameters:
        cms - the CMS context to use for VFS operations
        path - the path of the resource
        Returns:
        the flex bucket configuration
        Throws:
        CmsException - if something goes wrong
      • add

        public void add​(java.lang.String key,
                        java.util.List<java.lang.String> values)
        Adds a flex bucket definition, consisting of a flex bucket name and a list of paths.

        Parameters:
        key - the flex bucket name
        values - the flex bucket paths
      • freeze

        public void freeze()
        Freeze the bucket configuration, i.e. make it non-modifiable.

      • getBucketName

        public java.lang.String getBucketName​(int bitIndex)
        Gets the bucket name for the given bit index.

        Parameters:
        bitIndex - the bit index for the bucket in the bit set representation.

        Returns:
        the name of the bucket
      • getBucketSet

        public CmsFlexBucketConfiguration.BucketSet getBucketSet​(java.lang.Iterable<java.lang.String> paths)
        Computes the bucket set for a set of paths based on this configuration.

        The resulting bucket set contains all buckets for which one of the given paths is below the configured roots of that bucket.

        Parameters:
        paths - a list of root paths
        Returns:
        the bucket set for the input paths
      • setClearAll

        public void setClearAll​(java.util.List<java.lang.String> clearAll)
        Sets the 'clear all' list, a list of paths for which the complete Flex cache should be cleared if any resource below them is published.

        Parameters:
        clearAll - a list of paths
      • shouldClearAll

        public boolean shouldClearAll​(java.util.List<CmsPublishedResource> publishedResources)
        Returns true if for the given publish list, the complete Flex cache should be cleared based on this configuration.

        Parameters:
        publishedResources - a publish list
        Returns:
        true if the complete Flex cache should be cleared