Package org.opencms.db.generic
Class CmsSubscriptionDriver
java.lang.Object
org.opencms.db.generic.CmsSubscriptionDriver
- All Implemented Interfaces:
I_CmsDriver
,I_CmsSubscriptionDriver
- Direct Known Subclasses:
CmsSubscriptionDriver
,CmsSubscriptionDriver
,CmsSubscriptionDriver
,CmsSubscriptionDriver
,CmsSubscriptionDriver
,CmsSubscriptionDriver
,CmsSubscriptionDriver
Generic implementation of the user tracking and subscription driver interface.
- Since:
- 8.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected CmsDriverManager
A reference to the driver manager used by this driver.protected CmsSqlManager
The SQL manager used by this driver.Fields inherited from interface org.opencms.db.I_CmsDriver
AND_CONDITION, BEGIN_CONDITION, BEGIN_EXCLUDE_CONDITION, BEGIN_INCLUDE_CONDITION, END_CONDITION, OR_CONDITION
Fields inherited from interface org.opencms.db.I_CmsSubscriptionDriver
DRIVER_TYPE_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addVisit
(CmsDbContext dbc, String poolName, CmsVisitEntry visit) Adds an entry to the table of visits.void
deleteVisits
(CmsDbContext dbc, String poolName, CmsVisitEntryFilter filter) Deletes visit entries matching the given filter.long
getDateLastVisitedBy
(CmsDbContext dbc, String poolName, CmsUser user, CmsResource resource) Returns the date when the resource was last visited by the user.Returns the SQL manager of this driver, if possible.void
init
(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Initializes the driver.initSqlManager
(String classname) Initializes the SQL manager for this driver.protected CmsVisitEntry
Creates a newCmsVisitEntry
object from the given result set entry.void
markResourceAsVisitedBy
(CmsDbContext dbc, String poolName, CmsResource resource, CmsUser user) Mark the given resource as visited by the user.protected CmsPair<String,
List<I_CmsPreparedStatementParameter>> Build the whole WHERE SQL statement part for the given visit entry filter.readAllSubscribedResources
(CmsDbContext dbc, String poolName, CmsPrincipal principal) Returns all resources subscribed by the given user or group.readResourcesVisitedBy
(CmsDbContext dbc, String poolName, CmsVisitedByFilter filter) Returns the resources that were visited by a user set in the filter.readSubscribedDeletedResources
(CmsDbContext dbc, String poolName, CmsUser user, List<CmsGroup> groups, CmsResource parent, boolean includeSubFolders, long deletedFrom) Returns the subscribed history resources that were deleted.readSubscribedResources
(CmsDbContext dbc, String poolName, CmsSubscriptionFilter filter) Returns the resources that were subscribed by a user or group set in the filter.readVisits
(CmsDbContext dbc, String poolName, CmsVisitEntryFilter filter) ReadsCmsVisitEntry
objects from the database.void
setSubscribedResourceAsDeleted
(CmsDbContext dbc, String poolName, CmsResource resource) Marks a subscribed resource as deleted.void
subscribeResourceFor
(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) Subscribes the user or group to the resource.void
unsubscribeAllDeletedResources
(CmsDbContext dbc, String poolName, long deletedTo) Unsubscribes all deleted resources that were deleted before the specified time stamp.void
unsubscribeAllResourcesFor
(CmsDbContext dbc, String poolName, CmsPrincipal principal) Unsubscribes the principal from all resources.void
unsubscribeResourceFor
(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) Unsubscribes the principal from the resource.void
unsubscribeResourceForAll
(CmsDbContext dbc, String poolName, CmsResource resource) Unsubscribes all groups and users from the resource.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opencms.db.I_CmsDriver
toString
-
Field Details
-
m_driverManager
A reference to the driver manager used by this driver. -
m_sqlManager
The SQL manager used by this driver.
-
-
Constructor Details
-
CmsSubscriptionDriver
public CmsSubscriptionDriver()
-
-
Method Details
-
deleteVisits
public void deleteVisits(CmsDbContext dbc, String poolName, CmsVisitEntryFilter filter) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Deletes visit entries matching the given filter.- Specified by:
deleteVisits
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to use, ifnull
, the default pool is usedfilter
- the log entry filter- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
getDateLastVisitedBy
public long getDateLastVisitedBy(CmsDbContext dbc, String poolName, CmsUser user, CmsResource resource) throws CmsException Description copied from interface:I_CmsSubscriptionDriver
Returns the date when the resource was last visited by the user.- Specified by:
getDateLastVisitedBy
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useuser
- 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- See Also:
-
getSqlManager
Description copied from interface:I_CmsSubscriptionDriver
Returns the SQL manager of this driver, if possible.- Specified by:
getSqlManager
in interfaceI_CmsSubscriptionDriver
- Returns:
- an SQL manager
- See Also:
-
init
public void init(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Description copied from interface:I_CmsDriver
Initializes the driver.- Specified by:
init
in interfaceI_CmsDriver
- Parameters:
dbc
- the current database contextconfigurationManager
- the configuration managersuccessiveDrivers
- a list of successive drivers to be initializeddriverManager
- the initialized OpenCms driver manager- See Also:
-
initSqlManager
Description copied from interface:I_CmsSubscriptionDriver
Initializes the SQL manager for this driver.To obtain JDBC connections from different pools, further {online|offline|history} pool Urls have to be specified.
- Specified by:
initSqlManager
in interfaceI_CmsSubscriptionDriver
- Parameters:
classname
- the classname of the SQL manager- Returns:
- the SQL manager for this driver
- See Also:
-
markResourceAsVisitedBy
public void markResourceAsVisitedBy(CmsDbContext dbc, String poolName, CmsResource resource, CmsUser user) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Mark the given resource as visited by the user.- Specified by:
markResourceAsVisitedBy
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useresource
- the resource to mark as visiteduser
- the user that visited the resource- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readAllSubscribedResources
public List<CmsResource> readAllSubscribedResources(CmsDbContext dbc, String poolName, CmsPrincipal principal) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Returns all resources subscribed by the given user or group.- Specified by:
readAllSubscribedResources
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useprincipal
- the principal to read the subscribed resources- Returns:
- all resources subscribed by the given user or group
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readResourcesVisitedBy
public List<CmsResource> readResourcesVisitedBy(CmsDbContext dbc, String poolName, CmsVisitedByFilter filter) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Returns the resources that were visited by a user set in the filter.- Specified by:
readResourcesVisitedBy
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to usefilter
- the filter that is used to get the visited resources- Returns:
- the resources that were visited by a user set in the filter
- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
readSubscribedDeletedResources
public List<I_CmsHistoryResource> readSubscribedDeletedResources(CmsDbContext dbc, String poolName, CmsUser user, List<CmsGroup> groups, CmsResource parent, boolean includeSubFolders, long deletedFrom) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Returns the subscribed history resources that were deleted.- Specified by:
readSubscribedDeletedResources
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useuser
- the user that subscribed to the resourcegroups
- the groups to check subscribed resources forparent
- the parent resource (folder) 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:
CmsDataAccessException
- if something goes wrong- See Also:
-
readSubscribedResources
public List<CmsResource> readSubscribedResources(CmsDbContext dbc, String poolName, CmsSubscriptionFilter filter) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Returns the resources that were subscribed by a user or group set in the filter.- Specified by:
readSubscribedResources
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to usefilter
- 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:
CmsDataAccessException
- if something goes wrong- See Also:
-
readVisits
public List<CmsVisitEntry> readVisits(CmsDbContext dbc, String poolName, CmsVisitEntryFilter filter) throws CmsDataAccessException ReadsCmsVisitEntry
objects from the database.- Parameters:
dbc
- the database context to usepoolName
- the name of the pool which should be used for the database operationfilter
- a filter for constraining the list of results- Returns:
- a list of visit entries
- Throws:
CmsDataAccessException
- if the database operation fails
-
setSubscribedResourceAsDeleted
public void setSubscribedResourceAsDeleted(CmsDbContext dbc, String poolName, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Marks a subscribed resource as deleted.- Specified by:
setSubscribedResourceAsDeleted
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useresource
- the subscribed resource to mark as deleted- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
subscribeResourceFor
public void subscribeResourceFor(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Subscribes the user or group to the resource.- Specified by:
subscribeResourceFor
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useprincipal
- the principal that subscribes to the resourceresource
- the resource to subscribe to- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
unsubscribeAllDeletedResources
public void unsubscribeAllDeletedResources(CmsDbContext dbc, String poolName, long deletedTo) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Unsubscribes all deleted resources that were deleted before the specified time stamp.- Specified by:
unsubscribeAllDeletedResources
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to usedeletedTo
- the time stamp to which the resources have been deleted- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
unsubscribeAllResourcesFor
public void unsubscribeAllResourcesFor(CmsDbContext dbc, String poolName, CmsPrincipal principal) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Unsubscribes the principal from all resources.- Specified by:
unsubscribeAllResourcesFor
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useprincipal
- the principal that unsubscribes from all resources- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
unsubscribeResourceFor
public void unsubscribeResourceFor(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Unsubscribes the principal from the resource.- Specified by:
unsubscribeResourceFor
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useprincipal
- the principal that unsubscribes from the resourceresource
- the resource to unsubscribe from- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
unsubscribeResourceForAll
public void unsubscribeResourceForAll(CmsDbContext dbc, String poolName, CmsResource resource) throws CmsDataAccessException Description copied from interface:I_CmsSubscriptionDriver
Unsubscribes all groups and users from the resource.- Specified by:
unsubscribeResourceForAll
in interfaceI_CmsSubscriptionDriver
- Parameters:
dbc
- the database contextpoolName
- the name of the database pool to useresource
- the resource to unsubscribe all groups and users from- Throws:
CmsDataAccessException
- if something goes wrong- See Also:
-
addVisit
protected void addVisit(CmsDbContext dbc, String poolName, CmsVisitEntry visit) throws CmsDbSqlException Adds an entry to the table of visits.- Parameters:
dbc
- the database context to usepoolName
- the name of the database pool to usevisit
- the visit bean- Throws:
CmsDbSqlException
- if the database operation fails
-
internalReadVisitEntry
Creates a newCmsVisitEntry
object from the given result set entry.- Parameters:
res
- the result set- Returns:
- the new
CmsVisitEntry
object - Throws:
SQLException
- if something goes wrong
-
prepareVisitConditions
protected CmsPair<String,List<I_CmsPreparedStatementParameter>> prepareVisitConditions(CmsVisitEntryFilter filter) Build the whole WHERE SQL statement part for the given visit entry filter.- Parameters:
filter
- the filter- Returns:
- a pair containing both the SQL and the parameters for it
-