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
  • Field Details

  • Method Details

    • getInstance

      public static ReaderTrackerManager getInstance()
    • propertiesChange

      public void propertiesChange(JProperties properties)
      Description copied from interface: JPropertiesListener
      Invoked 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.getProperties or channel.getProperty.

      Specified by:
      propertiesChange in interface JPropertiesListener
      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(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 - the Publication
      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 - the Publication
      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 - the Publication
      Returns:
      count of access for the given Publication
      Since:
      jcms-8.0.0
    • getAuthentifiedReaderUniqueAccessCount

      public int getAuthentifiedReaderUniqueAccessCount(Publication pub)
      Parameters:
      pub - the Publication
      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 - the Publication
      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 - the Publication
      Returns:
      the count of anonymous users who have accessed the given Publication
      Since:
      jcms-8.0.0
    • getReaderTrackerList

      public 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 List<ReaderTracker> getReaderTrackerList(Publication pub, int accessType)
      Parameters:
      pub - the Publication
      accessType - the type of access (Read vs download)
      Returns:
      the list of ReaderTracker for given access type
      Since:
      jcms-8.0.0
    • getReaderTrackerList

      public List<ReaderTracker> getReaderTrackerList(Publication pub, String orderBy, boolean reverse, int accessType)
      Parameters:
      pub - the Publication
      orderBy - the orderby of the query
      reverse - to defines the order of the query
      accessType - the type of access
      Returns:
      the list of ReaderTracker for given access type and for given parameters
      Since:
      jcms-8.0.0
    • getMergedReaderTrackerSet

      public Set<ReaderTrackerEntry> getMergedReaderTrackerSet(Publication pub, ReaderTrackerEntry.Sort Sort, boolean isReverse)
      Parameters:
      pub - the tracked Publication
      Sort - the ReaderTrackerEntry.Sort of the query
      isReverse - true to sort results reversed
      Returns:
      a List of ReaderTrackerEntry which merges a ReaderTracker List to avoid duplicates
      Since:
      jcms-8.0.0
    • getMergedReaderTrackerSet

      public Set<ReaderTrackerEntry> getMergedReaderTrackerSet(List<ReaderTracker> readerTrackerList, ReaderTrackerEntry.Sort Sort, boolean isReverse)
      Returns a Set of ReaderTrackerEntry which merges a ReaderTracker List to avoid duplicates
      Parameters:
      readerTrackerList - collection of ReaderTracker
      Sort - the ReaderTrackerEntry.Sort of the query
      isReverse - true to sort results reversed
      Returns:
      a List of ReaderTrackerEntry which merges a ReaderTracker List to avoid duplicates
      Since:
      jcms-8.0.0
    • getMergedReaderTrackerSet

      public Set<ReaderTrackerEntry> getMergedReaderTrackerSet(Collection<ReaderTracker> readerTrackers, ReaderTrackerEntry.Sort Sort, boolean isReverse)
      Returns a Set of ReaderTrackerEntry which merges a ReaderTracker List to avoid duplicates
      Parameters:
      readerTrackers - collection of ReaderTracker
      Sort - the ReaderTrackerEntry.Sort of the query
      isReverse - true to sort results reversed
      Returns:
      a List of ReaderTrackerEntry which merges a ReaderTracker List 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 publication
      mbr - 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 publication
      mbr - the member
      accessType - 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 - the Publication
      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 - the Publication
      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 - the Publication
      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(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 publication
      mbr - 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 publication
      mbr - 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(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:
    • track

      public void track(Publication pub, Member mbr)
      Tracks the given member for the given publication.
      Parameters:
      pub - the publication
      mbr - 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 publication
      mbr - 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 member
      anonymize - if true report all the access of this member as anonymous access.
      Since:
      jcms-6.0.0
    • anonymizeAllReaderTracker

      public void anonymizeAllReaderTracker(Member mbr)
      Reports all the accesses of the given member as anonymous accesses.

      Access counts are first aggregated by publication and access type, then each anonymous ReaderTracker is created or incremented once, in the current transaction.

      The increment must not be performed in a dedicated transaction (as done by incrementAccess() for web accesses): an anonymous ReaderTracker created earlier in the current (not yet committed) transaction would be locked by this transaction, and the dedicated transaction would wait for this lock until the database lock wait timeout expires.

      Parameters:
      mbr - the member whose accesses must be anonymized
    • ackRead

      public void ackRead(Publication pub, Member mbr)
      Confirm the read of the given publication by the given member.
      Parameters:
      pub - the publication
      mbr - 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:
    • canAccessReaderTracker

      public boolean canAccessReaderTracker(Publication pub, Member mbr)
      Parameters:
      pub - the Publication
      mbr - the Member
      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 - the Publication
      mbr - the Member
      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: DBListener
      This method is called after a DBData has been created.
      Specified by:
      onPostInsert in interface DBListener
      Overrides:
      onPostInsert in class BasicDBListener
      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:
    • onPostUpdate

      public void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
      Description copied from interface: DBListener
      This method is called after a DBData has been updated.
      Specified by:
      onPostUpdate in interface DBListener
      Overrides:
      onPostUpdate in class BasicDBListener
      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:
    • onPostDelete

      public void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
      Description copied from interface: DBListener
      This method is called after a DBData has been deleted.
      Specified by:
      onPostDelete in interface DBListener
      Overrides:
      onPostDelete in class BasicDBListener
      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 event
      firstTime - true on the JSync replica on which the operation took place and false on the other replicas.
      See Also:
    • getAuthorSet

      public Set<Member> getAuthorSet(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