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
FieldsModifier and TypeFieldDescriptionprotected CmsDriverManagerA reference to the driver manager used by this driver.protected CmsSqlManagerThe 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_CONDITIONFields inherited from interface org.opencms.db.I_CmsSubscriptionDriver
DRIVER_TYPE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddVisit(CmsDbContext dbc, String poolName, CmsVisitEntry visit) Adds an entry to the table of visits.voiddeleteVisits(CmsDbContext dbc, String poolName, CmsVisitEntryFilter filter) Deletes visit entries matching the given filter.longgetDateLastVisitedBy(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.voidinit(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Initializes the driver.initSqlManager(String classname) Initializes the SQL manager for this driver.protected CmsVisitEntryCreates a newCmsVisitEntryobject from the given result set entry.voidmarkResourceAsVisitedBy(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) ReadsCmsVisitEntryobjects from the database.voidsetSubscribedResourceAsDeleted(CmsDbContext dbc, String poolName, CmsResource resource) Marks a subscribed resource as deleted.voidsubscribeResourceFor(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) Subscribes the user or group to the resource.voidunsubscribeAllDeletedResources(CmsDbContext dbc, String poolName, long deletedTo) Unsubscribes all deleted resources that were deleted before the specified time stamp.voidunsubscribeAllResourcesFor(CmsDbContext dbc, String poolName, CmsPrincipal principal) Unsubscribes the principal from all resources.voidunsubscribeResourceFor(CmsDbContext dbc, String poolName, CmsPrincipal principal, CmsResource resource) Unsubscribes the principal from the resource.voidunsubscribeResourceForAll(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, waitMethods 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_CmsSubscriptionDriverDeletes visit entries matching the given filter.- Specified by:
deleteVisitsin 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_CmsSubscriptionDriverReturns the date when the resource was last visited by the user.- Specified by:
getDateLastVisitedByin 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_CmsSubscriptionDriverReturns the SQL manager of this driver, if possible.- Specified by:
getSqlManagerin 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_CmsDriverInitializes the driver.- Specified by:
initin 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_CmsSubscriptionDriverInitializes 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:
initSqlManagerin 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_CmsSubscriptionDriverMark the given resource as visited by the user.- Specified by:
markResourceAsVisitedByin 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_CmsSubscriptionDriverReturns all resources subscribed by the given user or group.- Specified by:
readAllSubscribedResourcesin 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_CmsSubscriptionDriverReturns the resources that were visited by a user set in the filter.- Specified by:
readResourcesVisitedByin 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_CmsSubscriptionDriverReturns the subscribed history resources that were deleted.- Specified by:
readSubscribedDeletedResourcesin 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, ifnullall 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_CmsSubscriptionDriverReturns the resources that were subscribed by a user or group set in the filter.- Specified by:
readSubscribedResourcesin 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 ReadsCmsVisitEntryobjects 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_CmsSubscriptionDriverMarks a subscribed resource as deleted.- Specified by:
setSubscribedResourceAsDeletedin 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_CmsSubscriptionDriverSubscribes the user or group to the resource.- Specified by:
subscribeResourceForin 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_CmsSubscriptionDriverUnsubscribes all deleted resources that were deleted before the specified time stamp.- Specified by:
unsubscribeAllDeletedResourcesin 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_CmsSubscriptionDriverUnsubscribes the principal from all resources.- Specified by:
unsubscribeAllResourcesForin 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_CmsSubscriptionDriverUnsubscribes the principal from the resource.- Specified by:
unsubscribeResourceForin 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_CmsSubscriptionDriverUnsubscribes all groups and users from the resource.- Specified by:
unsubscribeResourceForAllin 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 newCmsVisitEntryobject from the given result set entry.- Parameters:
res- the result set- Returns:
- the new
CmsVisitEntryobject - 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
-