Class AudienceRights
- All Implemented Interfaces:
PluginComponent,StoreListener
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
- Author:
- Vincent Bouthors, Olivier Jaquemet
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected ConcurrentHashMap<Category, BitSet> protected Channelprotected booleanprotected ConcurrentHashMap<Member, BitSet> protected ConcurrentHashMap<Publication, BitSet> -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckRights(Publication pub, Member member) Check if the publication can be read by the given member using AudienceRights.protected voidClear the list of BitSet (one for each category axe).protected voidclearMemberBS(Member member) Clear the BitSet associated with the given Member.protected voidClear the map which associate member to their BitSet.protected voidClear the BitSet associated with the given Publication.protected BitSetcomputeMemberBS(Member member) Retrieve the List of BitSet (one for each category axe).Retrieve the list containing all the root categories of the audience rights axes.protected BitSetgetCategoryBS(Category category) Retrieve the BitSet associated with the given Category.protected BitSetgetCategorySetBS(Set<Category> catSet) Creates and returns a BitSet from a Set of Category, using their indivual BitSet.static AudienceRightsprotected BitSetgetMemberBS(Member member) Retrieve the BitSet associated with the given Member.protected BitSetRetrieve the BitSet associated with the given publication.voidhandleCommitUpdate(Storable storable, Storable oldStorable, boolean firstime) This method gets called when after a storable has been updated.voidhandleCreate(Storable storable, boolean firstime) This method gets called when a storable is created.voidhandleDelete(Storable storable, boolean firstime) This method gets called when a storable is deleted.booleanvoidprotected voidupdateStorableBS(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
-
Field Details
-
channel
-
isEnabled
protected boolean isEnabled -
categoriesAxesList
-
categoriesAxesBSList
-
categoryNumber
protected int categoryNumber -
categoryToBSMap
-
publicationToBSMap
-
memberToBSMap
-
-
Method Details
-
reloadProperties
public void reloadProperties() -
isEnabled
public boolean isEnabled()- Returns:
- true if audience rights is enabled, false otherwise.
-
getCategoriesAxesList
Retrieve the list containing all the root categories of the audience rights axes.- Returns:
- a List of Category
-
getInstance
-
checkRights
Check if the publication can be read by the given member using AudienceRights.- Parameters:
pub- the publicationmember- the member- Returns:
- true if publication can be read by member, false otherwise
-
getPublicationBS
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
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
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
-
clearMemberBS
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
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
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
-
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
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
Description copied from interface:StoreListenerThis method gets called when a storable is created.- Specified by:
handleCreatein interfaceStoreListener- Overrides:
handleCreatein classBasicStoreListener- Parameters:
storable- the storablefirstime- true if it is the first time this operation is processed- See Also:
-
handleCommitUpdate
Description copied from interface:StoreListenerThis method gets called when after a storable has been updated.- Specified by:
handleCommitUpdatein interfaceStoreListener- Overrides:
handleCommitUpdatein classBasicStoreListener- 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:
-
handleDelete
Description copied from interface:StoreListenerThis method gets called when a storable is deleted.- Specified by:
handleDeletein interfaceStoreListener- Overrides:
handleDeletein classBasicStoreListener- Parameters:
storable- the storablefirstime- true if it is the first time this operation is processed- See Also:
-
updateStorableBS
Reset the internal BitSet(s) depending on the modification of the given Storable.- Parameters:
storable- the Storable on which a modification occured
-