Package com.jalios.jcms.tracking
Class ReaderTrackerManager
- java.lang.Object
-
- com.jalios.jcms.db.BasicDBListener
-
- com.jalios.jcms.tracking.ReaderTrackerManager
-
- All Implemented Interfaces:
DBConstants,DBListener,PluginComponent,JaliosConstants,JPropertiesListener
public class ReaderTrackerManager extends BasicDBListener implements JaliosConstants, DBConstants, JPropertiesListener
- Author:
- bransard
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classReaderTrackerManager.CacheEntry
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREADER_TRACKER_ANONYMIZE_PROPstatic java.lang.StringREADER_TRACKER_CAN_ACCESS_TRACKING_ACLstatic java.lang.StringREADER_TRACKER_ENABLED_PROPstatic java.lang.StringREADER_TRACKER_READ_ACK_TYPESstatic java.lang.StringREADER_TRACKER_TYPES_PROPstatic java.lang.StringREADER_TRACKER_TYPESOFF_PROPstatic java.lang.StringREADER_TRACKER_WORKER_ACCESS_ENABLED_PROP-
Fields inherited from interface com.jalios.jcms.db.DBConstants
ALL_CATEGORIES_SET_FIELD, ATTACH_WS_SET_FIELD, AUTH_GRP_SET_FIELD, AUTH_MBR_SET_FIELD, AUTHOR_ID_FIELD, CATEGORIES_SET_FIELD, CDATE_FIELD, CHANNEL_JCMSDB_PROP, CLASSIFICATION_LEVEL_FIELD, DBDATA_URID, EXTENDED_READ_RIGHTS, HAS_ATTACH_WS_FIELD, HAS_NO_READ_RIGHTS, HIBERNATE_MAPPING_ADATE, HIBERNATE_MAPPING_AUTHOR, HIBERNATE_MAPPING_CDATE, HIBERNATE_MAPPING_EDATE, HIBERNATE_MAPPING_HAS_ATTACH_WS, HIBERNATE_MAPPING_HASNOREADRIGHTS, HIBERNATE_MAPPING_MAININSTANCE_ID, HIBERNATE_MAPPING_MAJORVERSION, HIBERNATE_MAPPING_MDATE, HIBERNATE_MAPPING_MERGE_DATE, HIBERNATE_MAPPING_MERGE_ID, HIBERNATE_MAPPING_MINORVERSION, HIBERNATE_MAPPING_OPAUTHOR, HIBERNATE_MAPPING_PDATE, HIBERNATE_MAPPING_PSTATUS, HIBERNATE_MAPPING_READ_ACK, HIBERNATE_MAPPING_READERCOUNT, HIBERNATE_MAPPING_RESTRICTIVE_UPDATE_RIGHTS, HIBERNATE_MAPPING_TITLE, HIBERNATE_MAPPING_TRACKED, HIBERNATE_MAPPING_UDATE, HIBERNATE_MAPPING_VOTECOUNT, HIBERNATE_MAPPING_VOTESCORE, HIBERNATE_MAPPING_WORKFLOW_ID, HIBERNATE_MAPPING_WORKSPACE_ID, MAX_HIBERNATE_MAPPING_PUBLICATION, MDATE_FIELD, OPAUTHOR_ID_FIELD, PSTATUS_FIELD, ROW_ID_FIELD, SCROLL_FETCH_SIZE, WORKFLOW_ID_FIELD, WORKSPACE_ID_FIELD
-
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidackRead(Publication pub, Member mbr)Confirm the read of the given publication by the given member.voidanonymizeAllReaderTracker(Member mbr)booleancanAccessReaderTracker(Publication pub, Member mbr)booleancanAccessReaderTracking(Member mbr)Returns true if the given member can access reader tracking.booleancanDeleteReaderTracker(Publication pub, Member mbr)intgetAccessCount(Publication pub)Returns the sum of access count for the given publication.intgetAccessCount(java.util.List<ReaderTracker> list)Returns the sum of access count for the list of ReaderTracker.intgetAnonymousReaderAccessCount(Publication pub)intgetAnonymousReaderDownloadCount(Publication pub)intgetAuthentifiedReaderAccessCount(Publication pub)intgetAuthentifiedReaderDownloadCount(Publication pub)intgetAuthentifiedReaderUniqueAccessCount(Publication pub)intgetAuthentifiedReaderUniqueDownloadCount(Publication pub)java.util.Set<Member>getAuthorSet(java.util.Set<ReaderTracker> readerTrackerSet)Get the authors set of given ReaderTracker set.intgetDownloadCount(Publication pub)Returns the download count for the given publication for authentified users.static ReaderTrackerManagergetInstance()java.util.Set<ReaderTrackerEntry>getMergedReaderTrackerSet(Publication pub, ReaderTrackerEntry.Sort Sort, boolean isReverse)java.util.Set<ReaderTrackerEntry>getMergedReaderTrackerSet(java.util.Collection<ReaderTracker> readerTrackers, ReaderTrackerEntry.Sort Sort, boolean isReverse)Returns a Set ofReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicatesjava.util.Set<ReaderTrackerEntry>getMergedReaderTrackerSet(java.util.List<ReaderTracker> readerTrackerList, ReaderTrackerEntry.Sort Sort, boolean isReverse)Returns a Set ofReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicatesintgetReadAckCount(Publication pub)Returns the count of member who confirm the reading of the given publication.intgetReaderAccessCount(Publication pub)intgetReaderCount(Publication pub)Returns the reader count for the given publication.ReaderTrackergetReaderTracker(Publication pub, Member mbr)Returns the ReaderTracker for the given Publication and the given Member.ReaderTrackergetReaderTracker(Publication pub, Member mbr, int accessType)Returns the ReaderTracker for the given Publication and the given Member.java.util.List<ReaderTracker>getReaderTrackerList(Publication pub)Returns the reader list for the given publication.java.util.List<ReaderTracker>getReaderTrackerList(Publication pub, int accessType)java.util.List<ReaderTracker>getReaderTrackerList(Publication pub, java.lang.String orderBy, boolean reverse, int accessType)booleanhasBeenAckBy(Publication pub, Member mbr)Returns true if the given member has confirmed the reading of the given publication.booleanhasBeenRead(Publication pub)voidinvalidateAllCacheEntries()Invalidate all the cache entries.voidinvalidateCacheEntry(Publication pub)Invalidate the cache entries for the given publicationbooleanisPerformTrack(Browser browser)Returns true if track must be performed for current visitor.booleanisReadAckAllowed(java.lang.Class clazz)Returns true if reading confirmation is allowed for the given class.booleanisReader(Publication pub, Member mbr)Returns true if the given publication has been read by the given member.booleanisReaderTrackerAnonymized()booleanisReaderTrackerEnabled()booleanisReaderTrackerWorkerAccessEnabled()Returns true if workers of a Workspace can access the reader tracking of all of the publications of their WorkspacebooleanisTracked(Publication pub)booleanisTypeReaderTracked(java.lang.Class<?> clazz)Returns true if the given class is reader trackedvoidonPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)This method is called after a DBData has been deleted.voidonPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)This method is called after a DBData has been created.voidonPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)This method is called after a DBData has been updated.voidpropertiesChange(JProperties properties)Invoked after properties have been modified in JCMS and save on disk.voidremoveAllReaderTracker(Member mbr, boolean anonymize)Removes all the ReaderTracekr bound to the given member ; and optionally report all the access of this member as anonymous access.voidremoveAllReaderTracker(Publication pub)Removes all the ReaderTracker bound to the given publication.voidtrack(Publication pub, Member mbr)Tracks the given member for the given publication.voidtrack(Publication pub, Member mbr, int accessType)Tracks the given member for the given publication and for given access Type.-
Methods inherited from class com.jalios.jcms.db.BasicDBListener
getAdateFromState, getAuthorIdFromState, getCdateFromState, getDateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate
-
-
-
-
Field Detail
-
READER_TRACKER_ANONYMIZE_PROP
public static final java.lang.String READER_TRACKER_ANONYMIZE_PROP
- See Also:
- Constant Field Values
-
READER_TRACKER_TYPES_PROP
public static final java.lang.String READER_TRACKER_TYPES_PROP
- See Also:
- Constant Field Values
-
READER_TRACKER_TYPESOFF_PROP
public static final java.lang.String READER_TRACKER_TYPESOFF_PROP
- See Also:
- Constant Field Values
-
READER_TRACKER_ENABLED_PROP
public static final java.lang.String READER_TRACKER_ENABLED_PROP
- See Also:
- Constant Field Values
-
READER_TRACKER_WORKER_ACCESS_ENABLED_PROP
public static final java.lang.String READER_TRACKER_WORKER_ACCESS_ENABLED_PROP
- See Also:
- Constant Field Values
-
READER_TRACKER_READ_ACK_TYPES
public static final java.lang.String READER_TRACKER_READ_ACK_TYPES
- See Also:
- Constant Field Values
-
READER_TRACKER_CAN_ACCESS_TRACKING_ACL
public static final java.lang.String READER_TRACKER_CAN_ACCESS_TRACKING_ACL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static ReaderTrackerManager getInstance()
-
propertiesChange
public void propertiesChange(JProperties properties)
Description copied from interface:JPropertiesListenerInvoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getPropertiesorchannel.getProperty.- Specified by:
propertiesChangein interfaceJPropertiesListener- Parameters:
properties- the properties which have been submitted to change- Since:
- jcms-8.0.0
-
isReaderTrackerEnabled
public boolean isReaderTrackerEnabled()
- Returns:
- true if the property "readertracker.enabled.boolean" is set to true
- Since:
- jcms-8.0.0
-
isReaderTrackerWorkerAccessEnabled
public boolean isReaderTrackerWorkerAccessEnabled()
Returns true if workers of a Workspace can access the reader tracking of all of the publications of their Workspace- Returns:
- true if the property "readertracker.worker.access.enabled.boolean" is set to true
- Since:
- jcms-9.0.1
-
isReaderTrackerAnonymized
public boolean isReaderTrackerAnonymized()
- Returns:
- true if the property "readertracker.anonymize.boolean" is set to true
- Since:
- jcms-8.0.0
-
isTypeReaderTracked
public boolean isTypeReaderTracked(java.lang.Class<?> clazz)
Returns true if the given class is reader tracked- Parameters:
clazz- the class to check- Returns:
- boolean true if the given class is compatible
-
isTracked
public boolean isTracked(Publication pub)
- Parameters:
pub- thePublication- Returns:
- true if given Publication is tracked and reader tracker is enabled
- Since:
- jcms-8.0.0
-
hasBeenRead
public boolean hasBeenRead(Publication pub)
- Parameters:
pub- thePublication- Returns:
- true if given publication has been read or downloaded
- Since:
- jcms-8.0.4 & jcms-9.0.2
-
getReaderCount
public int getReaderCount(Publication pub)
Returns the reader count for the given publication.- Parameters:
pub- the publication- Returns:
- the reader count for the given publication.
- Since:
- jcms-6.0.0
-
getReaderAccessCount
public int getReaderAccessCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- count of access for the given Publication
- Since:
- jcms-8.0.0
-
getAuthentifiedReaderUniqueAccessCount
public int getAuthentifiedReaderUniqueAccessCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the count of unique authentified users who have read the given Publication
- Since:
- jcms-8.0.0
-
getAuthentifiedReaderAccessCount
public int getAuthentifiedReaderAccessCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the count of authentified users who have read the given Publication
- Since:
- jcms-8.0.0
-
getAnonymousReaderAccessCount
public int getAnonymousReaderAccessCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the count of anonymous users who have accessed the given Publication
- Since:
- jcms-8.0.0
-
getReaderTrackerList
public java.util.List<ReaderTracker> getReaderTrackerList(Publication pub)
Returns the reader list for the given publication.- Parameters:
pub- the publication- Returns:
- the reader list for the given publication.
- Since:
- jcms-6.0.0
-
getReaderTrackerList
public java.util.List<ReaderTracker> getReaderTrackerList(Publication pub, int accessType)
- Parameters:
pub- thePublicationaccessType- the type of access (Read vs download)- Returns:
- the list of ReaderTracker for given access type
- Since:
- jcms-8.0.0
-
getReaderTrackerList
public java.util.List<ReaderTracker> getReaderTrackerList(Publication pub, java.lang.String orderBy, boolean reverse, int accessType)
- Parameters:
pub- thePublicationorderBy- the orderby of the queryreverse- to defines the order of the queryaccessType- the type of access- Returns:
- the list of ReaderTracker for given access type and for given parameters
- Since:
- jcms-8.0.0
-
getMergedReaderTrackerSet
public java.util.Set<ReaderTrackerEntry> getMergedReaderTrackerSet(Publication pub, ReaderTrackerEntry.Sort Sort, boolean isReverse)
- Parameters:
pub- the trackedPublicationSort- theReaderTrackerEntry.Sortof the queryisReverse- true to sort results reversed- Returns:
- a List of
ReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicates - Since:
- jcms-8.0.0
-
getMergedReaderTrackerSet
public java.util.Set<ReaderTrackerEntry> getMergedReaderTrackerSet(java.util.List<ReaderTracker> readerTrackerList, ReaderTrackerEntry.Sort Sort, boolean isReverse)
Returns a Set ofReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicates- Parameters:
readerTrackerList- collection ofReaderTrackerSort- theReaderTrackerEntry.Sortof the queryisReverse- true to sort results reversed- Returns:
- a List of
ReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicates - Since:
- jcms-8.0.0
-
getMergedReaderTrackerSet
public java.util.Set<ReaderTrackerEntry> getMergedReaderTrackerSet(java.util.Collection<ReaderTracker> readerTrackers, ReaderTrackerEntry.Sort Sort, boolean isReverse)
Returns a Set ofReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicates- Parameters:
readerTrackers- collection ofReaderTrackerSort- theReaderTrackerEntry.Sortof the queryisReverse- true to sort results reversed- Returns:
- a List of
ReaderTrackerEntrywhich merges aReaderTrackerList to avoid duplicates - Since:
- jcms-10.0.6
-
getReaderTracker
public ReaderTracker getReaderTracker(Publication pub, Member mbr)
Returns the ReaderTracker for the given Publication and the given Member.- Parameters:
pub- the publicationmbr- the member- Returns:
- the ReaderTracker for the given Publication and the given Member.
- Since:
- jcms-6.0.0
-
getReaderTracker
public ReaderTracker getReaderTracker(Publication pub, Member mbr, int accessType)
Returns the ReaderTracker for the given Publication and the given Member.- Parameters:
pub- the publicationmbr- the memberaccessType- the type of access (read vs download)- Returns:
- the ReaderTracker for the given Publication and the given Member.
- Since:
- jcms-6.0.0
-
getDownloadCount
public int getDownloadCount(Publication pub)
Returns the download count for the given publication for authentified users.- Parameters:
pub- the publication- Returns:
- the download count for the given publication for authentified users..
- Since:
- jcms-8.0.0
-
getAuthentifiedReaderUniqueDownloadCount
public int getAuthentifiedReaderUniqueDownloadCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the count of unique authentified reader who has downloaded the file document
- Since:
- jcms-8.0.0
-
getAuthentifiedReaderDownloadCount
public int getAuthentifiedReaderDownloadCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the total count of authenfied reader who has downloaded the file document
- Since:
- jcms-8.0.0
-
getAnonymousReaderDownloadCount
public int getAnonymousReaderDownloadCount(Publication pub)
- Parameters:
pub- thePublication- Returns:
- the count of anonymous reader who has downloaded the file document
- Since:
- jcms-8.0.0
-
getAccessCount
public int getAccessCount(Publication pub)
Returns the sum of access count for the given publication.- Parameters:
pub- the publication.- Returns:
- the sum of access count for the given publication.
- Since:
- jcms-6.0.0
-
getAccessCount
public int getAccessCount(java.util.List<ReaderTracker> list)
Returns the sum of access count for the list of ReaderTracker.- Parameters:
list- a list of ReaderTracker- Returns:
- the sum of access count for the list of ReaderTracker.
- Since:
- jcms-6.0.0
-
isReader
public boolean isReader(Publication pub, Member mbr)
Returns true if the given publication has been read by the given member.- Parameters:
pub- the publicationmbr- the member- Returns:
- true if the given publication has been read by the given member.
- Since:
- jcms-6.0.0
-
hasBeenAckBy
public boolean hasBeenAckBy(Publication pub, Member mbr)
Returns true if the given member has confirmed the reading of the given publication.- Parameters:
pub- the publicationmbr- the member- Returns:
- if the given member has confirmed the reading of the given publication.
- Since:
- jcms-10.0.5
-
getReadAckCount
public int getReadAckCount(Publication pub)
Returns the count of member who confirm the reading of the given publication.- Parameters:
pub- the publication- Returns:
- the count of member who confirm the reading of the given publication.
- Since:
- jcms-10.0.5
-
isReadAckAllowed
public boolean isReadAckAllowed(java.lang.Class clazz)
Returns true if reading confirmation is allowed for the given class.- Parameters:
clazz- the class- Returns:
- true if reading confirmation is allowed for the given class.
- Since:
- jcms-10.0.5
-
isPerformTrack
public boolean isPerformTrack(Browser browser)
Returns true if track must be performed for current visitor. If the visitor is a robot, the reader tracking is not saved.- Parameters:
browser- the browser of the user- Returns:
- true if track must be performed for current visitor
- Since:
- jcms-8.0.3 & jcms-9.0.2
- See Also:
Browser.isRobot()
-
track
public void track(Publication pub, Member mbr)
Tracks the given member for the given publication.- Parameters:
pub- the publicationmbr- the reader to be tracked (may be null)- Since:
- jcms-6.0.0
-
track
public void track(Publication pub, Member mbr, int accessType)
Tracks the given member for the given publication and for given access Type.- Parameters:
pub- the publicationmbr- the reader to be tracked (may be null)accessType- the type of access- Since:
- jcms-8.0.0
-
removeAllReaderTracker
public void removeAllReaderTracker(Publication pub)
Removes all the ReaderTracker bound to the given publication.- Parameters:
pub- the publication- Since:
- jcms-6.0.0
-
removeAllReaderTracker
public void removeAllReaderTracker(Member mbr, boolean anonymize)
Removes all the ReaderTracekr bound to the given member ; and optionally report all the access of this member as anonymous access.- Parameters:
mbr- the memberanonymize- if true report all the access of this member as anonymous access.- Since:
- jcms-6.0.0
-
anonymizeAllReaderTracker
public void anonymizeAllReaderTracker(Member mbr)
-
ackRead
public void ackRead(Publication pub, Member mbr)
Confirm the read of the given publication by the given member.- Parameters:
pub- the publicationmbr- the member- Since:
- jcms-10.0.5
-
canAccessReaderTracking
public boolean canAccessReaderTracking(Member mbr)
Returns true if the given member can access reader tracking.Access is granted if reader tracking is enable, and given member is global admin, or if check access and exists ACL test succeeds for
READER_TRACKER_CAN_ACCESS_TRACKING_ACL.- Parameters:
mbr- the member- Returns:
- true if the given member can access reader tracking.
- Since:
- jcms-10.0.6
- See Also:
AccessControlManager.checkAccessIfAclExists(Member, String, Map)
-
canAccessReaderTracker
public boolean canAccessReaderTracker(Publication pub, Member mbr)
- Parameters:
pub- thePublicationmbr- theMember- Returns:
- true if given Member can access reader tracker list on given Publication
- Since:
- jcms-8.0.0
-
canDeleteReaderTracker
public boolean canDeleteReaderTracker(Publication pub, Member mbr)
- Parameters:
pub- thePublicationmbr- theMember- Returns:
- true if given Member can delete reader tracker list on given Publication
- Since:
- jcms-8.0.0
-
invalidateCacheEntry
public void invalidateCacheEntry(Publication pub)
Invalidate the cache entries for the given publication- Parameters:
pub- the publication id- Since:
- jcms-6.1.2
-
invalidateAllCacheEntries
public void invalidateAllCacheEntries()
Invalidate all the cache entries.- Since:
- jcms-6.1.2
-
onPostInsert
public void onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)
Description copied from interface:DBListenerThis method is called after a DBData has been created.- Specified by:
onPostInsertin interfaceDBListener- Overrides:
onPostInsertin classBasicDBListener- Parameters:
data- the data.event- the event.firstTime- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostInsert(DBData, PostInsertEvent, boolean)
-
onPostUpdate
public void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
Description copied from interface:DBListenerThis method is called after a DBData has been updated.- Specified by:
onPostUpdatein interfaceDBListener- Overrides:
onPostUpdatein classBasicDBListener- Parameters:
data- the data.event- the event.firstTime- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostUpdate(DBData, PostUpdateEvent, boolean)
-
onPostDelete
public void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
Description copied from interface:DBListenerThis method is called after a DBData has been deleted.- Specified by:
onPostDeletein interfaceDBListener- Overrides:
onPostDeletein classBasicDBListener- Parameters:
data- the deleted DBData. WARNING! In a JSync Cluster, when firstTime is false, this data will be null. In this case, to get information about this deleted data, you must use the event and in particular event.getId(), which returns the JPlatform ID of the data, and event.getDeletedState() which returns the attributes of the data.event- the eventfirstTime- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostDelete(DBData, PostDeleteEvent, boolean)
-
getAuthorSet
public java.util.Set<Member> getAuthorSet(java.util.Set<ReaderTracker> readerTrackerSet)
Get the authors set of given ReaderTracker set.- Parameters:
readerTrackerSet- the tracker set to get corresponding unique readers- Returns:
- unique Members set
- Since:
- jcms-10.0.6
-
-