Package org.opencms.db
Interface I_CmsHistoryDriver
- All Known Implementing Classes:
CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
,CmsHistoryDriver
public interface I_CmsHistoryDriver
Definitions of all required history driver methods.
A history driver is a driver to write projects, resources and properties of resources optionally to a second set of history database tables while resources get published. A unique publish tag ID is used to identify a set of resource that were saved during one publish process.
- Since:
- 6.9.1
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The type ID to identify history driver implementations. -
Method Summary
Modifier and TypeMethodDescriptioncreatePropertyDefinition
(CmsDbContext dbc, String name, CmsPropertyDefinition.CmsPropertyType type) Creates a new property defintion in the database.int
deleteEntries
(CmsDbContext dbc, I_CmsHistoryResource histResource, int versionsToKeep, long time) Deletes all historical versions of a resource keeping maximalversionsToKeep
versions.void
deletePropertyDefinition
(CmsDbContext dbc, CmsPropertyDefinition propertyDef) Deletes a property definition.void
destroy()
Destroys this driver.Returns all historical resources (of deleted resources).Returns all historical resources (of not deleted resources).Returns the SqlManager of this driver.initSqlManager
(String classname) Initializes the SQL manager for this driver.readAllAvailableVersions
(CmsDbContext dbc, CmsUUID structureId) Reads all file headers of the resource with the given structure id.byte[]
readContent
(CmsDbContext dbc, CmsUUID resourceId, int publishTag) Reads the content of the historical version of the resource identified by its structure id.readDeletedResources
(CmsDbContext dbc, CmsUUID structureId, CmsUUID userId) Reads all deleted (historical) resources below the given path, that the given user deleted by itself.int
readLastVersion
(CmsDbContext dbc, CmsUUID structureId) Returns the last historical version of a resource.int
readMaxPublishTag
(CmsDbContext dbc, CmsUUID resourceId) Reads the maximal publish tag for a specified resource id.int
Returns the next available history publish tag.readPrincipal
(CmsDbContext dbc, CmsUUID principalId) Reads an historical principal entry.readProject
(CmsDbContext dbc, int publishTag) Reads an historical project version.readProject
(CmsDbContext dbc, CmsUUID projectId) Reads the latest historical project version with the given id.readProjectResources
(CmsDbContext dbc, int publishTag) Reads all resources that belong to the historical project identified by the given publish tag.readProjects
(CmsDbContext dbc) Returns all projects from the history.readProperties
(CmsDbContext dbc, I_CmsHistoryResource historicalResource) Returns a list of all properties of a historical file or folder.readPropertyDefinition
(CmsDbContext dbc, String name) Reads a property definition with the given name.int
readPublishTag
(CmsDbContext dbc, long maxdate) Gets the publish tag of the first historical project after a given date.readResource
(CmsDbContext dbc, CmsUUID structureId, int version) Reads a historical resource version without including the file content.void
setDriverManager
(CmsDriverManager driverManager) Sets the driver manager for this driver if possible.void
setSqlManager
(CmsSqlManager sqlManager) Sets the SQL manager for this driver if possible.void
writePrincipal
(CmsDbContext dbc, I_CmsPrincipal principal) Writes an historical entry for the given principal.void
writeProject
(CmsDbContext dbc, int publishTag, long publishDate) Creates an historical entry for the current project.void
writeProperties
(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) Writes the properties of a resource to the history.void
writeResource
(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) Writes a resource to the history.
-
Field Details
-
DRIVER_TYPE_ID
The type ID to identify history driver implementations.- See Also:
-
-
Method Details
-
createPropertyDefinition
CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc, String name, CmsPropertyDefinition.CmsPropertyType type) throws CmsDataAccessException Creates a new property defintion in the database.- Parameters:
dbc
- the current database contextname
- the name of the property definitiontype
- the type of the property definition- Returns:
- the new property definition object
- Throws:
CmsDataAccessException
- if something goes wrong
-
deleteEntries
int deleteEntries(CmsDbContext dbc, I_CmsHistoryResource histResource, int versionsToKeep, long time) throws CmsDataAccessException Deletes all historical versions of a resource keeping maximalversionsToKeep
versions.- Parameters:
dbc
- the current database contexthistResource
- the historical resource to delete versions forversionsToKeep
- the number of versions to keeptime
- deleted resources older than this will also be deleted, is ignored if negative- Returns:
- the number of versions that were deleted
- Throws:
CmsDataAccessException
- if something goes wrong
-
deletePropertyDefinition
void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition propertyDef) throws CmsDataAccessException Deletes a property definition.- Parameters:
dbc
- the current database contextpropertyDef
- the property definition to be deleted- Throws:
CmsDataAccessException
- if something goes wrong
-
destroy
Destroys this driver.- Throws:
Throwable
- if something goes wrong
-
getAllDeletedEntries
Returns all historical resources (of deleted resources).- Parameters:
dbc
- the current database context- Returns:
- a list of
I_CmsHistoryResource
objects - Throws:
CmsDataAccessException
- if something goes wrong
-
getAllNotDeletedEntries
Returns all historical resources (of not deleted resources).- Parameters:
dbc
- the current database context- Returns:
- a list of
I_CmsHistoryResource
objects - Throws:
CmsDataAccessException
- if something goes wrong
-
getSqlManager
Returns the SqlManager of this driver.- Returns:
- the SqlManager of this driver
-
initSqlManager
Initializes the SQL manager for this driver.- Parameters:
classname
- the classname of the SQL manager- Returns:
- the SQL manager for this driver
-
readAllAvailableVersions
List<I_CmsHistoryResource> readAllAvailableVersions(CmsDbContext dbc, CmsUUID structureId) throws CmsDataAccessException Reads all file headers of the resource with the given structure id.This method returns a list with the history of the resource, i.e. the historical resources, independent of the project they were attached to.
The reading excludes the file content.- Parameters:
dbc
- the current database contextstructureId
- the structure id- Returns:
- a list of historical resources, as
objectsI_CmsHistoryResource
- Throws:
CmsDataAccessException
- if something goes wrong
-
readContent
byte[] readContent(CmsDbContext dbc, CmsUUID resourceId, int publishTag) throws CmsDataAccessException Reads the content of the historical version of the resource identified by its structure id.- Parameters:
dbc
- the current database contextresourceId
- the resource id of the resource to read the content forpublishTag
- the publish tag of the version- Returns:
- the content if found
- Throws:
CmsDataAccessException
- if something goes wrong
-
readDeletedResources
List<I_CmsHistoryResource> readDeletedResources(CmsDbContext dbc, CmsUUID structureId, CmsUUID userId) throws CmsDataAccessException Reads all deleted (historical) resources below the given path, that the given user deleted by itself.- Parameters:
dbc
- the current db contextstructureId
- the structure id of the parent resource to read the deleted resources fromuserId
- the id of the user that deleted the resources, ornull
to retrieve them all- Returns:
- a list of
objectsI_CmsHistoryResource
- Throws:
CmsDataAccessException
- if something goes wrong
-
readLastVersion
Returns the last historical version of a resource.- Parameters:
dbc
- the current database contextstructureId
- the structure ID of the resource- Returns:
- the last historical version of a resource
- Throws:
CmsDataAccessException
- if something goes wrong
-
readMaxPublishTag
Reads the maximal publish tag for a specified resource id.- Parameters:
dbc
- the current database contextresourceId
- the id of the resource the get the publish tag for- Returns:
- the maximal publish tag for the given resource
- Throws:
CmsDataAccessException
- if something goes wrong
-
readNextPublishTag
Returns the next available history publish tag.- Parameters:
dbc
- the current database context- Returns:
- the next available history publish tag
-
readPrincipal
CmsHistoryPrincipal readPrincipal(CmsDbContext dbc, CmsUUID principalId) throws CmsDataAccessException Reads an historical principal entry.- Parameters:
dbc
- the current database contextprincipalId
- the id of the principal to retrieve- Returns:
- the historical principal entry
- Throws:
CmsDataAccessException
- if something goes wrong
-
readProject
Reads the latest historical project version with the given id.- Parameters:
dbc
- the current database contextprojectId
- the project id- Returns:
- the requested historical project
- Throws:
CmsDataAccessException
- is something goes wrong
-
readProject
Reads an historical project version.- Parameters:
dbc
- the current database contextpublishTag
- the publish tag- Returns:
- the requested historical project
- Throws:
CmsDataAccessException
- is something goes wrong
-
readProjectResources
Reads all resources that belong to the historical project identified by the given publish tag.- Parameters:
dbc
- the current database contextpublishTag
- the publish tag- Returns:
- all resources that belong to the historical project identified by the given publish tag
- Throws:
CmsDataAccessException
- if something goes wrong
-
readProjects
Returns all projects from the history.- Parameters:
dbc
- the current database context- Returns:
- list of
objects with all projects from history.CmsHistoryProject
- Throws:
CmsDataAccessException
- if an error occurs
-
readProperties
List<CmsProperty> readProperties(CmsDbContext dbc, I_CmsHistoryResource historicalResource) throws CmsDataAccessException Returns a list of all properties of a historical file or folder.- Parameters:
dbc
- the current database contexthistoricalResource
- the resource to read the properties from- Returns:
- a list of
CmsProperty
objects - Throws:
CmsDataAccessException
- if something goes wrong
-
readPropertyDefinition
CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, String name) throws CmsDataAccessException Reads a property definition with the given name.- Parameters:
dbc
- the current database contextname
- the name of the property definition to read- Returns:
- the property definition that corresponds to the given arguments - or
null
if not found - Throws:
CmsDataAccessException
- if something goes wrong
-
readPublishTag
Gets the publish tag of the first historical project after a given date.This method is used during the deletion process of older historical data.
- Parameters:
dbc
- the current database contextmaxdate
- the date to compare the historical projects with- Returns:
- publish tag of the first historical project after maxdate
- Throws:
CmsDataAccessException
- if something goes wrong
-
readResource
I_CmsHistoryResource readResource(CmsDbContext dbc, CmsUUID structureId, int version) throws CmsDataAccessException Reads a historical resource version without including the file content.- Parameters:
dbc
- the current database contextstructureId
- the structure id of the resource to readversion
- the desired version number- Returns:
- the historical resource version
- Throws:
CmsDataAccessException
- if something goes wrong
-
setDriverManager
Sets the driver manager for this driver if possible.- Parameters:
driverManager
- the new driver manager
-
setSqlManager
Sets the SQL manager for this driver if possible.- Parameters:
sqlManager
- the new SQL manager
-
writePrincipal
Writes an historical entry for the given principal.- Parameters:
dbc
- the current database contextprincipal
- the principal to write- Throws:
CmsDataAccessException
- if something goes wrong
-
writeProject
Creates an historical entry for the current project.- Parameters:
dbc
- the current database contextpublishTag
- the publish tagpublishDate
- long timestamp when the current project was published- Throws:
CmsDataAccessException
- if something goes wrong
-
writeProperties
void writeProperties(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) throws CmsDataAccessException Writes the properties of a resource to the history.- Parameters:
dbc
- the current database contextresource
- the resource of the propertiesproperties
- the properties to writepublishTag
- the publish tag- Throws:
CmsDataAccessException
- if something goes wrong
-
writeResource
void writeResource(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) throws CmsDataAccessException Writes a resource to the history.- Parameters:
dbc
- the current database contextresource
- the resource that is written to the historyproperties
- the properties of the resourcepublishTag
- the publish tag- Throws:
CmsDataAccessException
- if something goes wrong
-