Class RegexHomeFolderProvider

  • All Implemented Interfaces:
    HomeFolderProvider2, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

    public class RegexHomeFolderProvider
    extends UsernameHomeFolderProvider
    Implementation that returns a tree structure for a home folder based on a property (typically userName) from the supplied person. The parent folder names are derived from regular expression groups matched against the property value. The final folder name is the full property value.

    For example, given the value "adavis" and the regular expression "^(..)" the resulting home folder path would be "/ad/adavis". However with the regular expression "^(.)(.?)" the home folder path would be "/a/d/adavis". If any group matches a zero length string, it is just ignored.

    Note: In order to choose an efficient distribution scheme, be aware that, when m users are distributed into n leaf folders, when m >> n log n the statistical maximum load is m/n + O( sqrt((m log n)/n)), w.h.p

    Author:
    Romain Guinot, Alan Davis
    • Constructor Detail

      • RegexHomeFolderProvider

        public RegexHomeFolderProvider()
    • Method Detail

      • setPropertyName

        public void setPropertyName​(java.lang.String propertyName)
        Parameters:
        propertyName - String the cm:person property used as the key, such as userName or organizationId.
      • setPattern

        public void setPattern​(java.lang.String patternString)
        Parameters:
        patternString - the regex pattern against the cm:person property value. Regex groups define the parent folder structure.
      • setGroupOrder

        public void setGroupOrder​(java.lang.String groupOrderString)
        Parameters:
        groupOrderString - String the order (as a comma separated list) in which the regex pattern groups should be assembled into folders (such as 2,1). The default ordering is as they appear.
      • getHomeFolderPath

        public java.util.List<java.lang.String> getHomeFolderPath​(org.alfresco.service.cmr.repository.NodeRef person)
        Description copied from interface: HomeFolderProvider2
        Returns a preferred path (a list of folder names) for the home folder relative to the root path. If all users share the root, the returned value should be an empty List or null. When all users have their own folder under the root there should be just one element in the List. Multiple elements should be returned when a nested folder structure is preferred.
        Specified by:
        getHomeFolderPath in interface HomeFolderProvider2
        Overrides:
        getHomeFolderPath in class UsernameHomeFolderProvider
        Parameters:
        person - NodeRef from which a property (normally the userName) is used as a hash key to create a nested directory structure.
        Returns:
        the path to be used.