Package org.opencms.db
Class CmsSubscriptionManager
java.lang.Object
org.opencms.db.CmsSubscriptionManager
Manager that provides methods to subscribe resources to users, read subscribed or unvisited resources and more.
- Since:
- 8.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected CmsSecurityManager
The security manager to access the cms. -
Constructor Summary
ConstructorDescriptionInitializes a new CmsSubscriptionManager, called from the configuration. -
Method Summary
Modifier and TypeMethodDescriptionlong
getDateLastVisitedBy
(CmsObject cms, CmsUser user, String resourcePath) Returns the date when the resource was last visited by the user.long
getDateLastVisitedBy
(CmsObject cms, CmsUser user, CmsResource resource) Returns the date when the resource was last visited by the user.int
Returns the maximum number of visited resources to store per user.Returns the name of the database pool to use.void
initialize
(CmsObject cms) Initializes this subscription manager with the OpenCms system configuration.boolean
Returns if the subscription functionality is enabled.void
markResourceAsVisitedBy
(CmsObject cms, String resourcePath, CmsUser user) Mark the given resource as visited by the user.void
markResourceAsVisitedBy
(CmsObject cms, CmsResource resource, CmsUser user) Mark the given resource as visited by the user.readAllSubscribedResources
(CmsObject cms, CmsPrincipal principal) Returns all resources subscribed by the given user or group.readResourcesVisitedBy
(CmsObject cms, CmsVisitedByFilter filter) Returns the resources that were visited by a user set in the filter.readSubscribedDeletedResources
(CmsObject cms, CmsUser user, boolean includeGroups, String folderPath, boolean includeSubFolders, long deletedFrom) Returns the subscribed history resources that were deleted.readSubscribedResources
(CmsObject cms, CmsSubscriptionFilter filter) Returns the resources that were subscribed by a user or group set in the filter.void
setEnabled
(boolean enabled) Sets if the subscription functionality is enabled.void
setEnabled
(String enabled) Sets if the subscription functionality is enabled.void
setMaxVisitedCount
(String maxVisitedCount) Sets the maximum number of visited resources to store per user.void
setPoolName
(String poolName) Sets the name of the database pool to use.void
setSecurityManager
(CmsSecurityManager securityManager) Sets the security manager during initialization.void
setSubscribedResourceAsDeleted
(CmsObject cms, CmsResource resource) Marks a subscribed resource as deleted.void
subscribeResourceFor
(CmsObject cms, CmsPrincipal principal, String resourcePath) Subscribes the user or group to the resource.void
subscribeResourceFor
(CmsObject cms, CmsPrincipal principal, CmsResource resource) Subscribes the user or group to the resource.void
unsubscribeAllDeletedResources
(CmsObject cms, long deletedTo) Unsubscribes all deleted resources that were deleted before the specified time stamp.void
unsubscribeAllResourcesFor
(CmsObject cms, CmsPrincipal principal) Unsubscribes the user or group from all resources.void
unsubscribeResourceFor
(CmsObject cms, CmsPrincipal principal, String resourcePath) Unsubscribes the principal from the resource.void
unsubscribeResourceFor
(CmsObject cms, CmsPrincipal principal, CmsResource resource) Unsubscribes the principal from the resource.void
unsubscribeResourceForAll
(CmsObject cms, String resourcePath) Unsubscribes all groups and users from the resource.void
unsubscribeResourceForAll
(CmsObject cms, CmsResource resource) Unsubscribes all groups and users from the resource.
-
Field Details
-
m_securityManager
The security manager to access the cms.
-
-
Constructor Details
-
CmsSubscriptionManager
public CmsSubscriptionManager()Initializes a new CmsSubscriptionManager, called from the configuration.
-
-
Method Details
-
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 contextuser
- the user to check the dateresource
- 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, String resourcePath) throws CmsException Returns the date when the resource was last visited by the user.- Parameters:
cms
- the current users contextuser
- the user to check the dateresourcePath
- 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
Returns the maximum number of visited resources to store per user.- Returns:
- the maximum number of visited resources to store per user
-
getPoolName
Returns the name of the database pool to use.- Returns:
- the name of the database pool to use
-
initialize
Initializes this subscription manager with the OpenCms system configuration.- Parameters:
cms
- an OpenCms context object that must have been initialized with "Admin" permissions- Throws:
CmsRoleViolationException
- in case the given opencms object does not have
permissionsCmsRole.ROOT_ADMIN
-
isEnabled
Returns if the subscription functionality is enabled.- Returns:
true
if the subscription functionality is enabled, otherwisefalse
-
markResourceAsVisitedBy
public void markResourceAsVisitedBy(CmsObject cms, CmsResource resource, CmsUser user) throws CmsException Mark the given resource as visited by the user.- Parameters:
cms
- the current users contextresource
- the resource to mark as visiteduser
- the user that visited the resource- Throws:
CmsException
- if something goes wrong
-
markResourceAsVisitedBy
public void markResourceAsVisitedBy(CmsObject cms, String resourcePath, CmsUser user) throws CmsException Mark the given resource as visited by the user.- Parameters:
cms
- the current users contextresourcePath
- the name of the resource to mark as visiteduser
- the user that visited the resource- Throws:
CmsException
- if something goes wrong
-
readAllSubscribedResources
public List<CmsResource> readAllSubscribedResources(CmsObject cms, CmsPrincipal principal) throws CmsException Returns all resources subscribed by the given user or group.- Parameters:
cms
- the current users contextprincipal
- 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 List<CmsResource> readResourcesVisitedBy(CmsObject cms, CmsVisitedByFilter filter) throws CmsException Returns the resources that were visited by a user set in the filter.- Parameters:
cms
- the current users contextfilter
- 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 List<I_CmsHistoryResource> readSubscribedDeletedResources(CmsObject cms, CmsUser user, boolean includeGroups, String folderPath, boolean includeSubFolders, long deletedFrom) throws CmsException Returns the subscribed history resources that were deleted.- Parameters:
cms
- the current users contextuser
- the user that subscribed to the resourceincludeGroups
- indicates if the users groups should also be checked for subscribed deleted resourcesfolderPath
- the folder path of the deleted resources, ifnull
all deleted resources will be returnedincludeSubFolders
- indicates if the sub folders of the specified folder path should be considered, toodeletedFrom
- 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 List<CmsResource> readSubscribedResources(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 contextfilter
- 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
Sets if the subscription functionality is enabled.- Parameters:
enabled
- the flag indicating if the subscription functionality is enabled
-
setEnabled
Sets if the subscription functionality is enabled.- Parameters:
enabled
- the flag indicating if the subscription functionality is enabled
-
setMaxVisitedCount
Sets the maximum number of visited resources to store per user.- Parameters:
maxVisitedCount
- the maximum number of visited resources to store per user
-
setPoolName
Sets the name of the database pool to use.- Parameters:
poolName
- the name of the database pool to use
-
setSecurityManager
Sets the security manager during initialization.- Parameters:
securityManager
- the security manager
-
setSubscribedResourceAsDeleted
Marks a subscribed resource as deleted.- Parameters:
cms
- the current users contextresource
- the subscribed resource to mark as deleted- Throws:
CmsException
- if something goes wrong
-
subscribeResourceFor
public void subscribeResourceFor(CmsObject cms, CmsPrincipal principal, CmsResource resource) throws CmsException Subscribes the user or group to the resource.- Parameters:
cms
- the current users contextprincipal
- the principal that subscribes to the resourceresource
- the resource to subscribe to- Throws:
CmsException
- if something goes wrong
-
subscribeResourceFor
public void subscribeResourceFor(CmsObject cms, CmsPrincipal principal, String resourcePath) throws CmsException Subscribes the user or group to the resource.- Parameters:
cms
- the current users contextprincipal
- the principal that subscribes to the resourceresourcePath
- the name of the resource to subscribe to- Throws:
CmsException
- if something goes wrong
-
unsubscribeAllDeletedResources
Unsubscribes all deleted resources that were deleted before the specified time stamp.- Parameters:
cms
- the current users contextdeletedTo
- the time stamp to which the resources have been deleted- Throws:
CmsException
- if something goes wrong
-
unsubscribeAllResourcesFor
Unsubscribes the user or group from all resources.- Parameters:
cms
- the current users contextprincipal
- the principal that unsubscribes from all resources- 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 contextprincipal
- the principal that unsubscribes from the resourceresource
- the resource to unsubscribe from- Throws:
CmsException
- if something goes wrong
-
unsubscribeResourceFor
public void unsubscribeResourceFor(CmsObject cms, CmsPrincipal principal, String resourcePath) throws CmsException Unsubscribes the principal from the resource.- Parameters:
cms
- the current users contextprincipal
- the principal that unsubscribes from the resourceresourcePath
- the name of the resource to unsubscribe from- Throws:
CmsException
- if something goes wrong
-
unsubscribeResourceForAll
Unsubscribes all groups and users from the resource.- Parameters:
cms
- the current users contextresource
- the resource to unsubscribe all groups and users from- Throws:
CmsException
- if something goes wrong
-
unsubscribeResourceForAll
Unsubscribes all groups and users from the resource.- Parameters:
cms
- the current users contextresourcePath
- the name of the resource to unsubscribe all groups and users from- Throws:
CmsException
- if something goes wrong
-