Class CmsSubscriptionManager


  • public class CmsSubscriptionManager
    extends java.lang.Object
    Manager that provides methods to subscribe resources to users, read subscribed or unvisited resources and more.

    Since:
    8.0
    • Constructor Detail

      • CmsSubscriptionManager

        public CmsSubscriptionManager()
        Initializes a new CmsSubscriptionManager, called from the configuration.

    • Method Detail

      • getDateLastVisitedBy

        public long getDateLastVisitedBy​(CmsObject cms,
                                         CmsUser user,
                                         CmsResource resource)
                                  throws CmsException
        Returns the date when the resource was last visited by the user.

        Parameters:
        cms - the current users context
        user - the user to check the date
        resource - the resource to check the date
        Returns:
        the date when the resource was last visited by the user
        Throws:
        CmsException - if something goes wrong
      • getDateLastVisitedBy

        public long getDateLastVisitedBy​(CmsObject cms,
                                         CmsUser user,
                                         java.lang.String resourcePath)
                                  throws CmsException
        Returns the date when the resource was last visited by the user.

        Parameters:
        cms - the current users context
        user - the user to check the date
        resourcePath - the name of the resource to check the date
        Returns:
        the date when the resource was last visited by the user
        Throws:
        CmsException - if something goes wrong
      • getMaxVisitedCount

        public int getMaxVisitedCount()
        Returns the maximum number of visited resources to store per user.

        Returns:
        the maximum number of visited resources to store per user
      • getPoolName

        public java.lang.String getPoolName()
        Returns the name of the database pool to use.

        Returns:
        the name of the database pool to use
      • isEnabled

        public boolean isEnabled()
        Returns if the subscription functionality is enabled.

        Returns:
        true if the subscription functionality is enabled, otherwise false
      • markResourceAsVisitedBy

        public void markResourceAsVisitedBy​(CmsObject cms,
                                            java.lang.String resourcePath,
                                            CmsUser user)
                                     throws CmsException
        Mark the given resource as visited by the user.

        Parameters:
        cms - the current users context
        resourcePath - the name of the resource to mark as visited
        user - the user that visited the resource
        Throws:
        CmsException - if something goes wrong
      • readAllSubscribedResources

        public java.util.List<CmsResourcereadAllSubscribedResources​(CmsObject cms,
                                                                      CmsPrincipal principal)
                                                               throws CmsException
        Returns all resources subscribed by the given user or group.

        Parameters:
        cms - the current users context
        principal - the principal to read the subscribed resources
        Returns:
        all resources subscribed by the given user or group
        Throws:
        CmsException - if something goes wrong
      • readResourcesVisitedBy

        public java.util.List<CmsResourcereadResourcesVisitedBy​(CmsObject cms,
                                                                  CmsVisitedByFilter filter)
                                                           throws CmsException
        Returns the resources that were visited by a user set in the filter.

        Parameters:
        cms - the current users context
        filter - the filter that is used to get the visited resources
        Returns:
        the resources that were visited by a user set in the filter
        Throws:
        CmsException - if something goes wrong
      • readSubscribedDeletedResources

        public java.util.List<I_CmsHistoryResourcereadSubscribedDeletedResources​(CmsObject cms,
                                                                                   CmsUser user,
                                                                                   boolean includeGroups,
                                                                                   java.lang.String folderPath,
                                                                                   boolean includeSubFolders,
                                                                                   long deletedFrom)
                                                                            throws CmsException
        Returns the subscribed history resources that were deleted.

        Parameters:
        cms - the current users context
        user - the user that subscribed to the resource
        includeGroups - indicates if the users groups should also be checked for subscribed deleted resources
        folderPath - the folder path of the deleted resources, if null all deleted resources will be returned
        includeSubFolders - indicates if the sub folders of the specified folder path should be considered, too
        deletedFrom - the time stamp from which the resources should have been deleted
        Returns:
        the subscribed history resources that were deleted
        Throws:
        CmsException - if something goes wrong
      • readSubscribedResources

        public java.util.List<CmsResourcereadSubscribedResources​(CmsObject cms,
                                                                   CmsSubscriptionFilter filter)
                                                            throws CmsException
        Returns the resources that were subscribed by a user or group set in the filter.

        Parameters:
        cms - the current users context
        filter - the filter that is used to get the subscribed resources
        Returns:
        the resources that were subscribed by a user or group set in the filter
        Throws:
        CmsException - if something goes wrong
      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets if the subscription functionality is enabled.

        Parameters:
        enabled - the flag indicating if the subscription functionality is enabled
      • setEnabled

        public void setEnabled​(java.lang.String enabled)
        Sets if the subscription functionality is enabled.

        Parameters:
        enabled - the flag indicating if the subscription functionality is enabled
      • setMaxVisitedCount

        public void setMaxVisitedCount​(java.lang.String maxVisitedCount)
        Sets the maximum number of visited resources to store per user.

        Parameters:
        maxVisitedCount - the maximum number of visited resources to store per user
      • setPoolName

        public void setPoolName​(java.lang.String poolName)
        Sets the name of the database pool to use.

        Parameters:
        poolName - the name of the database pool to use
      • setSecurityManager

        public void setSecurityManager​(CmsSecurityManager securityManager)
        Sets the security manager during initialization.

        Parameters:
        securityManager - the security manager
      • subscribeResourceFor

        public void subscribeResourceFor​(CmsObject cms,
                                         CmsPrincipal principal,
                                         java.lang.String resourcePath)
                                  throws CmsException
        Subscribes the user or group to the resource.

        Parameters:
        cms - the current users context
        principal - the principal that subscribes to the resource
        resourcePath - the name of the resource to subscribe to
        Throws:
        CmsException - if something goes wrong
      • unsubscribeAllDeletedResources

        public void unsubscribeAllDeletedResources​(CmsObject cms,
                                                   long deletedTo)
                                            throws CmsException
        Unsubscribes all deleted resources that were deleted before the specified time stamp.

        Parameters:
        cms - the current users context
        deletedTo - the time stamp to which the resources have been deleted
        Throws:
        CmsException - if something goes wrong
      • unsubscribeResourceFor

        public void unsubscribeResourceFor​(CmsObject cms,
                                           CmsPrincipal principal,
                                           CmsResource resource)
                                    throws CmsException
        Unsubscribes the principal from the resource.

        Parameters:
        cms - the current users context
        principal - the principal that unsubscribes from the resource
        resource - the resource to unsubscribe from
        Throws:
        CmsException - if something goes wrong
      • unsubscribeResourceFor

        public void unsubscribeResourceFor​(CmsObject cms,
                                           CmsPrincipal principal,
                                           java.lang.String resourcePath)
                                    throws CmsException
        Unsubscribes the principal from the resource.

        Parameters:
        cms - the current users context
        principal - the principal that unsubscribes from the resource
        resourcePath - the name of the resource to unsubscribe from
        Throws:
        CmsException - if something goes wrong
      • unsubscribeResourceForAll

        public void unsubscribeResourceForAll​(CmsObject cms,
                                              java.lang.String resourcePath)
                                       throws CmsException
        Unsubscribes all groups and users from the resource.

        Parameters:
        cms - the current users context
        resourcePath - the name of the resource to unsubscribe all groups and users from
        Throws:
        CmsException - if something goes wrong