Package org.opencms.db.generic
Class CmsHistoryDriver
java.lang.Object
org.opencms.db.generic.CmsHistoryDriver
- All Implemented Interfaces:
I_CmsDriver,I_CmsHistoryDriver
- Direct Known Subclasses:
CmsHistoryDriver,CmsHistoryDriver,CmsHistoryDriver,CmsHistoryDriver,CmsHistoryDriver,CmsHistoryDriver,CmsHistoryDriver
Generic (ANSI-SQL) database server implementation of the history driver methods.
- Since:
- 6.9.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CmsDriverManagerThe driver manager instance.protected CmsSqlManagerThe SQL manager instance.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_CmsHistoryDriver
DRIVER_TYPE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreatePropertyDefinition(CmsDbContext dbc, String name, CmsPropertyDefinition.CmsPropertyType type) Creates a new property defintion in the database.intdeleteEntries(CmsDbContext dbc, I_CmsHistoryResource resource, int versionsToKeep, long time) Deletes all historical versions of a resource keeping maximalversionsToKeepversions.voiddeletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) Deletes a property definition.voiddestroy()Destroys this driver.Returns all historical resources (of deleted resources).Returns all historical resources (of not deleted resources).Returns the SqlManager of this driver.voidinit(CmsDbContext dbc, CmsConfigurationManager configurationManager, List<String> successiveDrivers, CmsDriverManager driverManager) Initializes the driver.initSqlManager(String classname) Initializes the SQL manager for this driver.protected voidinternalAddToPropMap(Map<String, CmsProperty> propertyMap, I_CmsHistoryResource resource, String propertyKey, String propertyValue, int mappingType) Updates the property map for the given resource with the given property data.protected voidinternalCleanup(CmsDbContext dbc, I_CmsHistoryResource resource) Deletes all historical entries of subresources of a folder without any historical netry left.protected intinternalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId) Returns the amount of properties for a propertydefinition.protected CmsHistoryProjectinternalCreateProject(ResultSet res, List<String> resources) Creates a historical project from the given result set and resources.protected I_CmsHistoryResourceCreates a validI_CmsHistoryResourceinstance from a JDBC ResultSet.protected I_CmsHistoryResourceinternalMergeResource(I_CmsHistoryResource histRes, ResultSet res, int versionOffset) Merges an historical entry for a sibling, based on the structure data from the given historical resource and result set for the resource entry.protected booleaninternalValidateResource(CmsDbContext dbc, CmsResource resource, int publishTag) Tests if a history resource does exist.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.intreadLastVersion(CmsDbContext dbc, CmsUUID structureId) Returns the last historical version of a resource.intreadMaxPublishTag(CmsDbContext dbc, CmsUUID resourceId) Reads the maximal publish tag for a specified resource id.intReturns 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 resource) 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.intreadPublishTag(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.voidsetDriverManager(CmsDriverManager driverManager) Sets the driver manager for this driver if possible.voidsetSqlManager(CmsSqlManager sqlManager) Sets the SQL manager for this driver if possible.voidwritePrincipal(CmsDbContext dbc, I_CmsPrincipal principal) Writes an historical entry for the given principal.voidwriteProject(CmsDbContext dbc, int publishTag, long publishDate) Creates an historical entry for the current project.voidwriteProperties(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) Writes the properties of a resource to the history.voidwriteResource(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) Writes a resource to the history.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
The driver manager instance. -
m_sqlManager
The SQL manager instance.
-
-
Constructor Details
-
CmsHistoryDriver
public CmsHistoryDriver()
-
-
Method Details
-
createPropertyDefinition
public CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc, String name, CmsPropertyDefinition.CmsPropertyType type) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverCreates a new property defintion in the database.- Specified by:
createPropertyDefinitionin interfaceI_CmsHistoryDriver- 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- See Also:
-
deleteEntries
public int deleteEntries(CmsDbContext dbc, I_CmsHistoryResource resource, int versionsToKeep, long time) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverDeletes all historical versions of a resource keeping maximalversionsToKeepversions.- Specified by:
deleteEntriesin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextresource- 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- See Also:
-
deletePropertyDefinition
public void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverDeletes a property definition.- Specified by:
deletePropertyDefinitionin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextmetadef- the property definition to be deleted- Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
destroy
Description copied from interface:I_CmsHistoryDriverDestroys this driver.- Specified by:
destroyin interfaceI_CmsHistoryDriver- Throws:
Throwable- if something goes wrong- See Also:
-
getAllDeletedEntries
public List<I_CmsHistoryResource> getAllDeletedEntries(CmsDbContext dbc) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReturns all historical resources (of deleted resources).- Specified by:
getAllDeletedEntriesin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database context- Returns:
- a list of
I_CmsHistoryResourceobjects - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
getAllNotDeletedEntries
public List<I_CmsHistoryResource> getAllNotDeletedEntries(CmsDbContext dbc) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReturns all historical resources (of not deleted resources).- Specified by:
getAllNotDeletedEntriesin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database context- Returns:
- a list of
I_CmsHistoryResourceobjects - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
getSqlManager
Description copied from interface:I_CmsHistoryDriverReturns the SqlManager of this driver.- Specified by:
getSqlManagerin interfaceI_CmsHistoryDriver- Returns:
- the SqlManager of this driver
- 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_CmsHistoryDriverInitializes the SQL manager for this driver.- Specified by:
initSqlManagerin interfaceI_CmsHistoryDriver- Parameters:
classname- the classname of the SQL manager- Returns:
- the SQL manager for this driver
- See Also:
-
readAllAvailableVersions
public List<I_CmsHistoryResource> readAllAvailableVersions(CmsDbContext dbc, CmsUUID structureId) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads 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.- Specified by:
readAllAvailableVersionsin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextstructureId- the structure id- Returns:
- a list of historical resources, as
objectsI_CmsHistoryResource - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
readContent
public byte[] readContent(CmsDbContext dbc, CmsUUID resourceId, int publishTag) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads the content of the historical version of the resource identified by its structure id.- Specified by:
readContentin interfaceI_CmsHistoryDriver- 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- See Also:
-
readDeletedResources
public List<I_CmsHistoryResource> readDeletedResources(CmsDbContext dbc, CmsUUID structureId, CmsUUID userId) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads all deleted (historical) resources below the given path, that the given user deleted by itself.- Specified by:
readDeletedResourcesin interfaceI_CmsHistoryDriver- 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, ornullto retrieve them all- Returns:
- a list of
objectsI_CmsHistoryResource - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
readLastVersion
Description copied from interface:I_CmsHistoryDriverReturns the last historical version of a resource.- Specified by:
readLastVersionin interfaceI_CmsHistoryDriver- 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- See Also:
-
readMaxPublishTag
Description copied from interface:I_CmsHistoryDriverReads the maximal publish tag for a specified resource id.- Specified by:
readMaxPublishTagin interfaceI_CmsHistoryDriver- 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- See Also:
-
readNextPublishTag
Description copied from interface:I_CmsHistoryDriverReturns the next available history publish tag.- Specified by:
readNextPublishTagin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database context- Returns:
- the next available history publish tag
- See Also:
-
readPrincipal
public CmsHistoryPrincipal readPrincipal(CmsDbContext dbc, CmsUUID principalId) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads an historical principal entry.- Specified by:
readPrincipalin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextprincipalId- the id of the principal to retrieve- Returns:
- the historical principal entry
- Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
readProject
public CmsHistoryProject readProject(CmsDbContext dbc, CmsUUID projectId) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads the latest historical project version with the given id.- Specified by:
readProjectin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextprojectId- the project id- Returns:
- the requested historical project
- Throws:
CmsDataAccessException- is something goes wrong- See Also:
-
readProject
public CmsHistoryProject readProject(CmsDbContext dbc, int publishTag) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads an historical project version.- Specified by:
readProjectin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextpublishTag- the publish tag- Returns:
- the requested historical project
- Throws:
CmsDataAccessException- is something goes wrong- See Also:
-
readProjectResources
public List<String> readProjectResources(CmsDbContext dbc, int publishTag) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads all resources that belong to the historical project identified by the given publish tag.- Specified by:
readProjectResourcesin interfaceI_CmsHistoryDriver- 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- See Also:
-
readProjects
Description copied from interface:I_CmsHistoryDriverReturns all projects from the history.- Specified by:
readProjectsin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database context- Returns:
- list of
objects with all projects from history.CmsHistoryProject - Throws:
CmsDataAccessException- if an error occurs- See Also:
-
readProperties
public List<CmsProperty> readProperties(CmsDbContext dbc, I_CmsHistoryResource resource) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReturns a list of all properties of a historical file or folder.- Specified by:
readPropertiesin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextresource- the resource to read the properties from- Returns:
- a list of
CmsPropertyobjects - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
readPropertyDefinition
public CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, String name) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads a property definition with the given name.- Specified by:
readPropertyDefinitionin interfaceI_CmsHistoryDriver- 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
nullif not found - Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
readPublishTag
Description copied from interface:I_CmsHistoryDriverGets the publish tag of the first historical project after a given date.This method is used during the deletion process of older historical data.
- Specified by:
readPublishTagin interfaceI_CmsHistoryDriver- 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- See Also:
-
readResource
public I_CmsHistoryResource readResource(CmsDbContext dbc, CmsUUID structureId, int version) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverReads a historical resource version without including the file content.- Specified by:
readResourcein interfaceI_CmsHistoryDriver- 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- See Also:
-
setDriverManager
Description copied from interface:I_CmsHistoryDriverSets the driver manager for this driver if possible.- Specified by:
setDriverManagerin interfaceI_CmsHistoryDriver- Parameters:
driverManager- the new driver manager- See Also:
-
setSqlManager
Description copied from interface:I_CmsHistoryDriverSets the SQL manager for this driver if possible.- Specified by:
setSqlManagerin interfaceI_CmsHistoryDriver- Parameters:
sqlManager- the new SQL manager- See Also:
-
writePrincipal
public void writePrincipal(CmsDbContext dbc, I_CmsPrincipal principal) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverWrites an historical entry for the given principal.- Specified by:
writePrincipalin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextprincipal- the principal to write- Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
writeProject
public void writeProject(CmsDbContext dbc, int publishTag, long publishDate) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverCreates an historical entry for the current project.- Specified by:
writeProjectin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextpublishTag- the publish tagpublishDate- long timestamp when the current project was published- Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
writeProperties
public void writeProperties(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverWrites the properties of a resource to the history.- Specified by:
writePropertiesin interfaceI_CmsHistoryDriver- Parameters:
dbc- the current database contextresource- the resource of the propertiesproperties- the properties to writepublishTag- the publish tag- Throws:
CmsDataAccessException- if something goes wrong- See Also:
-
writeResource
public void writeResource(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag) throws CmsDataAccessException Description copied from interface:I_CmsHistoryDriverWrites a resource to the history.- Specified by:
writeResourcein interfaceI_CmsHistoryDriver- 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- See Also:
-
internalAddToPropMap
protected void internalAddToPropMap(Map<String, CmsProperty> propertyMap, I_CmsHistoryResource resource, String propertyKey, String propertyValue, int mappingType) throws CmsDbConsistencyExceptionUpdates the property map for the given resource with the given property data.- Parameters:
propertyMap- the map to updateresource- the resource the properties belong topropertyKey- the property keypropertyValue- the property valuemappingType- the mapping type- Throws:
CmsDbConsistencyException- if the mapping type is wrong
-
internalCleanup
protected void internalCleanup(CmsDbContext dbc, I_CmsHistoryResource resource) throws CmsDataAccessException Deletes all historical entries of subresources of a folder without any historical netry left.- Parameters:
dbc- the current database contextresource- the resource to check- Throws:
CmsDataAccessException- if something goes wrong
-
internalCountProperties
protected int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition metadef, CmsUUID projectId) throws CmsDataAccessException Returns the amount of properties for a propertydefinition.- Parameters:
dbc- the current database contextmetadef- the propertydefinition to testprojectId- the ID of the current project- Returns:
- the amount of properties for a propertydefinition
- Throws:
CmsDataAccessException- if something goes wrong
-
internalCreateProject
protected CmsHistoryProject internalCreateProject(ResultSet res, List<String> resources) throws SQLException Creates a historical project from the given result set and resources.- Parameters:
res- the resource setresources- the historical resources- Returns:
- the historical project
- Throws:
SQLException- if something goes wrong
-
internalCreateResource
Creates a validI_CmsHistoryResourceinstance from a JDBC ResultSet.- Parameters:
res- the JDBC result set- Returns:
- the new historical resource instance
- Throws:
SQLException- if a requested attribute was not found in the result set
-
internalMergeResource
protected I_CmsHistoryResource internalMergeResource(I_CmsHistoryResource histRes, ResultSet res, int versionOffset) throws SQLException Merges an historical entry for a sibling, based on the structure data from the given historical resource and result set for the resource entry.- Parameters:
histRes- the original historical entryres- the result set of the resource entryversionOffset- the offset for the structure version- Returns:
- a merged historical entry for the sibling
- Throws:
SQLException- if something goes wrong
-
internalValidateResource
protected boolean internalValidateResource(CmsDbContext dbc, CmsResource resource, int publishTag) throws CmsDataAccessException Tests if a history resource does exist.- Parameters:
dbc- the current database contextresource- the resource to testpublishTag- the publish tag of the resource to test- Returns:
trueif the resource already exists,falseotherwise- Throws:
CmsDataAccessException- if something goes wrong
-