com.jalios.jcms
Class AudienceRights

java.lang.Object
  extended by com.jalios.jcms.BasicStoreListener
      extended by com.jalios.jcms.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: 27753 $
Author:
Vincent Bouthors , Olivier Jaquemet

Field Summary
protected  List<BitSet> categoriesAxesBSList
           
protected  List<Category> categoriesAxesList
           
protected  int categoryNumber
           
protected  Object categoryNumberLock
           
protected  HashMap<Category,BitSet> categoryToBSMap
           
protected  Channel channel
           
protected  boolean isEnabled
           
protected  HashMap<Member,BitSet> memberToBSMap
           
protected  HashMap<Publication,BitSet> publicationToBSMap
           
static String REVISION
           
 
Method Summary
 boolean checkRights(Publication pub, Member member)
          Check if the publication can be read by the given member using AudienceRights.
protected  void clearCategoriesAxesBSList()
          Clear the list of BitSet (one for each category axe).
protected  void clearMemberBS(Member member)
          Clear the BitSet associated with the given Member.
protected  void clearMemberBSListMap()
          Clear the map which associate member to their BitSet.
protected  void clearPublicationBS(Publication pub)
          Clear the BitSet associated with the given Publication.
protected  List<BitSet> computeCategoriesAxesBSList()
           
protected  BitSet computeMemberBS(Member member)
           
protected  List<BitSet> getCategoriesAxesBSList()
          Retrieve the List of BitSet (one for each category axe).
 List<Category> getCategoriesAxesList()
          Retrieve the list containing all the root categories of the audience rights axes.
protected  BitSet getCategoryBS(Category category)
          Retrieve the BitSet associated with the given Category.
protected  BitSet getCategorySetBS(Set<Category> catSet)
          Creates and returns a BitSet from a Set of Category, using their indivual BitSet.
static AudienceRights getInstance()
           
protected  BitSet getMemberBS(Member member)
          Retrieve the BitSet associated with the given Member.
protected  BitSet getPublicationBS(Publication pub)
          Retrieve the BitSet associated with the given publication.
 void handleCommitUpdate(Storable storable, Storable oldStorable, boolean firstime)
          This method gets called when after a storable has been updated.
 void handleCreate(Storable storable, boolean firstime)
          This method gets called when a storable is created.
 void handleDelete(Storable storable, boolean firstime)
          This method gets called when a storable is deleted.
 boolean isEnabled()
           
 void reloadProperties()
           
protected  void updateStorableBS(Storable storable)
          Reset the internal BitSet(s) depending on the modification of the given Storable.
 
Methods inherited from class com.jalios.jcms.BasicStoreListener
handlePrepareUpdate, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

channel

protected Channel channel

isEnabled

protected boolean isEnabled

categoriesAxesList

protected List<Category> categoriesAxesList

categoriesAxesBSList

protected List<BitSet> categoriesAxesBSList

categoryNumber

protected int categoryNumber

categoryNumberLock

protected Object categoryNumberLock

categoryToBSMap

protected HashMap<Category,BitSet> categoryToBSMap

publicationToBSMap

protected HashMap<Publication,BitSet> publicationToBSMap

memberToBSMap

protected HashMap<Member,BitSet> memberToBSMap
Method Detail

reloadProperties

public void reloadProperties()

isEnabled

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

getCategoriesAxesList

public List<Category> getCategoriesAxesList()
Retrieve the list containing all the root categories of the audience rights axes.

Returns:
a List of Category

getInstance

public static AudienceRights getInstance()

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 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 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 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 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 List<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 List<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 BitSet getCategorySetBS(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.

handleCreate

public void handleCreate(Storable storable,
                         boolean firstime)
Description copied from interface: StoreListener
This method gets called when a storable is created.

Specified by:
handleCreate in interface StoreListener
Overrides:
handleCreate in class BasicStoreListener
Parameters:
storable - the storable
firstime - true if it is the first time this operation is processed
See Also:
StoreListener.handleCreate(Storable, boolean)

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)

handleDelete

public void handleDelete(Storable storable,
                         boolean firstime)
Description copied from interface: StoreListener
This method gets called when a storable is deleted.

Specified by:
handleDelete in interface StoreListener
Overrides:
handleDelete in class BasicStoreListener
Parameters:
storable - the storable
firstime - true if it is the first time this operation is processed
See Also:
StoreListener.handleDelete(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


Copyright © 2001-2010 Jalios SA. All Rights Reserved.