Class AudienceRights

  • All Implemented Interfaces:
    PluginComponent, StoreListener

    public class AudienceRights
    extends BasicStoreListener
    This class manages a Member's read right on publication using their categories.

    How does it work? :
    You can use N audience axes to check rights, 1 axe is 1 category branch.
    A member is allowed to read a publication only if, for each audience axes, the read categories of the Member Member.getReadCategorySet() are under the categories of the Publication Publication.getCategorySet()

    Let's say we have those categories:

      root
       - Keywords
       - Location *
         - Europe
           - France
             - Ile de France
             - Gers
           - England
         - Asia
           - Japan
           - China
       - Line of work *
        - All jobs
          - Marketing
          - Engineering
     
    * categories used as audience axes.

    Two members with those read categories checked from the axes:

     M1:
       - Ile de France
       - Engineering
     M2:
       - Europe
       - Marketing
     

    Some publications with those categories: P1: - France - All jobs P2: - England - Engineering

    M1 is allowed to read P1 (category "Ile de France" is in "France" AND "Engineering" is in "All jobs"). But M1 is NOT allowed to read P2 (category "Ile de France" is NOT in "England", even though category "Engineering" matches).

    M2 is allowed to read P1 (category "Europe" is an ancestor of "France" AND "Marketing" is in "All jobs"). M2 is NOT allowed to read P2 (category "Europe" is an ancestor of "England", but category "Engineering" does not matches "Marketing").

    Since:
    jcms-5.5.0
    Version:
    $Revision: 107554 $
    Author:
    Vincent Bouthors, Olivier Jaquemet
    • Field Detail

      • channel

        protected Channel channel
      • isEnabled

        protected boolean isEnabled
      • categoriesAxesList

        protected java.util.List<Category> categoriesAxesList
      • categoriesAxesBSList

        protected java.util.List<java.util.BitSet> categoriesAxesBSList
      • categoryNumber

        protected int categoryNumber
      • categoryToBSMap

        protected java.util.concurrent.ConcurrentHashMap<Category,​java.util.BitSet> categoryToBSMap
      • publicationToBSMap

        protected java.util.concurrent.ConcurrentHashMap<Publication,​java.util.BitSet> publicationToBSMap
      • memberToBSMap

        protected java.util.concurrent.ConcurrentHashMap<Member,​java.util.BitSet> memberToBSMap
    • Method Detail

      • reloadProperties

        public void reloadProperties()
      • isEnabled

        public boolean isEnabled()
        Returns:
        true if audience rights is enabled, false otherwise.
      • getCategoriesAxesList

        public java.util.List<Category> getCategoriesAxesList()
        Retrieve the list containing all the root categories of the audience rights axes.
        Returns:
        a List of Category
      • checkRights

        public boolean checkRights​(Publication pub,
                                   Member member)
        Check if the publication can be read by the given member using AudienceRights.
        Parameters:
        pub - the publication
        member - the member
        Returns:
        true if publication can be read by member, false otherwise
      • getPublicationBS

        protected java.util.BitSet getPublicationBS​(Publication pub)
        Retrieve the BitSet associated with the given publication. Compute and cache it if not yet available.
        Parameters:
        pub - the publication of which to retrieve the BitSet.
        Returns:
        the BitSet associated with the given Publication.
      • clearPublicationBS

        protected void clearPublicationBS​(Publication pub)
        Clear the BitSet associated with the given Publication. Must be called each time the publication is modified or when deleted. The new bitSet will be computed again the next time it is used.
        Parameters:
        pub - the publication of which to remove the BitSet.
      • getMemberBS

        protected java.util.BitSet getMemberBS​(Member member)
        Retrieve the BitSet associated with the given Member. Compute and cache it if not yet available.
        Parameters:
        member - the Member of which to retrieve the BitSet.
        Returns:
        the BitSet associated with the given Member.
      • computeMemberBS

        protected java.util.BitSet computeMemberBS​(Member member)
      • clearMemberBS

        protected void clearMemberBS​(Member member)
        Clear the BitSet associated with the given Member. Must be called each time the member is modified or deleted.
        Parameters:
        member - the Member of which to clear the BitSet.
      • clearMemberBSListMap

        protected void clearMemberBSListMap()
        Clear the map which associate member to their BitSet. Must be called each time the category tree is modified.
      • getCategoryBS

        protected java.util.BitSet getCategoryBS​(Category category)
        Retrieve the BitSet associated with the given Category. Compute and cache it if not yet available.
        Parameters:
        category - the Category of which to retrieve the BitSet.
        Returns:
        the BitSet associated with the given list of.
      • getCategoriesAxesBSList

        protected java.util.List<java.util.BitSet> getCategoriesAxesBSList()
        Retrieve the List of BitSet (one for each category axe). Compute and cache it if not yet available.
        Returns:
        the list of BitSet (one for each category axe).
      • computeCategoriesAxesBSList

        protected java.util.List<java.util.BitSet> computeCategoriesAxesBSList()
      • clearCategoriesAxesBSList

        protected void clearCategoriesAxesBSList()
        Clear the list of BitSet (one for each category axe). Must be called each time a category is modified (more precisely reparented).
      • getCategorySetBS

        protected java.util.BitSet getCategorySetBS​(java.util.Set<Category> catSet)
        Creates and returns a BitSet from a Set of Category, using their indivual BitSet.
        Parameters:
        catSet - a Set of Category to use to create a new BitSet
        Returns:
        a new BitSet for the given Category Set.
      • handleCommitUpdate

        public void handleCommitUpdate​(Storable storable,
                                       Storable oldStorable,
                                       boolean firstime)
        Description copied from interface: StoreListener
        This method gets called when after a storable has been updated.
        Specified by:
        handleCommitUpdate in interface StoreListener
        Overrides:
        handleCommitUpdate in class BasicStoreListener
        Parameters:
        storable - the storable, this instance is the object that was created at first and that will be stored in jcms until deletion of the storable with this ID. You should always manipulate this object if you maintain any index.
        oldStorable - the previous version of the storable, it is a clone, do not use in any index, it should only be used to access old values.
        firstime - true if it is the first time this operation is processed
        See Also:
        StoreListener.handleCommitUpdate(Storable, Storable, boolean)
      • updateStorableBS

        protected void updateStorableBS​(Storable storable)
        Reset the internal BitSet(s) depending on the modification of the given Storable.
        Parameters:
        storable - the Storable on which a modification occured