org.opencms.db
Interface I_CmsHistoryDriver

All Known Subinterfaces:
I_CmsBackupDriver
All Known Implementing Classes:
CmsBackupDriver, CmsBackupDriver, CmsBackupDriver, CmsBackupDriver, CmsBackupDriver, CmsBackupDriver, CmsHistoryDriver, 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
Version:
$Revision: 1.8 $
Author:
Michael Emmerich, Thomas Weckert, Michael Moossen

Field Summary
static int DRIVER_TYPE_ID
          The type ID to identify history driver implementations.
 
Method Summary
 CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc, java.lang.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 maximal versionsToKeep versions.
 void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition propertyDef)
          Deletes a property definition.
 void destroy()
          Destroys this driver.
 java.util.List getAllDeletedEntries(CmsDbContext dbc)
          Returns all historical resources (of deleted resources).
 java.util.List getAllNotDeletedEntries(CmsDbContext dbc)
          Returns all historical resources (of not deleted resources).
 CmsSqlManager getSqlManager()
          Returns the SqlManager of this driver.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
 java.util.List 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.
 java.util.List readDeletedResources(CmsDbContext dbc, CmsUUID structureId, CmsUUID userId)
          Reads all deleted (historical) resources below the given path, that the given user deleted by itself.
 I_CmsHistoryResource readFile(CmsDbContext dbc, CmsUUID structureId, int publishTag)
          Deprecated. use readResource(CmsDbContext, CmsUUID, int) instead but notice that the publishTag != version
 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 readNextPublishTag(CmsDbContext dbc)
          Returns the next available history publish tag.
 CmsHistoryPrincipal readPrincipal(CmsDbContext dbc, CmsUUID principalId)
          Reads an historical principal entry.
 CmsHistoryProject readProject(CmsDbContext dbc, CmsUUID projectId)
          Reads the latest historical project version with the given id.
 CmsHistoryProject readProject(CmsDbContext dbc, int publishTag)
          Reads an historical project version.
 java.util.List readProjectResources(CmsDbContext dbc, int publishTag)
          Reads all resources that belong to the historical project identified by the given publish tag.
 java.util.List readProjects(CmsDbContext dbc)
          Returns all projects from the history.
 java.util.List readProperties(CmsDbContext dbc, I_CmsHistoryResource historicalResource)
          Returns a list of all properties of a historical file or folder.
 CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, java.lang.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.
 I_CmsHistoryResource readResource(CmsDbContext dbc, CmsUUID structureId, int version)
          Reads a historical resource version without including the file content.
 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, java.util.List properties, int publishTag)
          Writes the properties of a resource to the history.
 void writeResource(CmsDbContext dbc, CmsResource resource, java.util.List properties, int publishTag)
          Writes a resource to the history.
 

Field Detail

DRIVER_TYPE_ID

static final int DRIVER_TYPE_ID
The type ID to identify history driver implementations.

See Also:
Constant Field Values
Method Detail

createPropertyDefinition

CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc,
                                               java.lang.String name,
                                               CmsPropertyDefinition.CmsPropertyType type)
                                               throws CmsDataAccessException
Creates a new property defintion in the database.

Parameters:
dbc - the current database context
name - the name of the property definition
type - 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 maximal versionsToKeep versions.

Parameters:
dbc - the current database context
histResource - the historical resource to delete versions for
versionsToKeep - the number of versions to keep
time - 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 context
propertyDef - the property definition to be deleted
Throws:
CmsDataAccessException - if something goes wrong

destroy

void destroy()
             throws java.lang.Throwable
Destroys this driver.

Throws:
java.lang.Throwable - if something goes wrong

getAllDeletedEntries

java.util.List getAllDeletedEntries(CmsDbContext dbc)
                                    throws CmsDataAccessException
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

java.util.List getAllNotDeletedEntries(CmsDbContext dbc)
                                       throws CmsDataAccessException
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

CmsSqlManager getSqlManager()
Returns the SqlManager of this driver.

Returns:
the SqlManager of this driver

initSqlManager

CmsSqlManager initSqlManager(java.lang.String classname)
Initializes the SQL manager for this driver.

Parameters:
classname - the classname of the SQL manager
Returns:
the SQL manager for this driver

readAllAvailableVersions

java.util.List 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 context
structureId - the structure id
Returns:
a list of historical resources, as I_CmsHistoryResource objects
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 context
resourceId - the resource id of the resource to read the content for
publishTag - the publish tag of the version
Returns:
the content if found
Throws:
CmsDataAccessException - if something goes wrong

readDeletedResources

java.util.List 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 context
structureId - the structure id of the parent resource to read the deleted resources from
userId - the id of the user that deleted the resources, or null to retrieve them all
Returns:
a list of I_CmsHistoryResource objects
Throws:
CmsDataAccessException - if something goes wrong

readFile

I_CmsHistoryResource readFile(CmsDbContext dbc,
                              CmsUUID structureId,
                              int publishTag)
                              throws CmsDataAccessException
Deprecated. use readResource(CmsDbContext, CmsUUID, int) instead but notice that the publishTag != version

Reads a historical file version including the file content.

Parameters:
dbc - the current database context
structureId - the structure id of the file to read
publishTag - the desired publish tag of the file
Returns:
the historical file version
Throws:
CmsDataAccessException - if something goes wrong

readLastVersion

int readLastVersion(CmsDbContext dbc,
                    CmsUUID structureId)
                    throws CmsDataAccessException
Returns the last historical version of a resource.

Parameters:
dbc - the current database context
structureId - the structure ID of the resource
Returns:
the last historical version of a resource
Throws:
CmsDataAccessException - if something goes wrong

readMaxPublishTag

int readMaxPublishTag(CmsDbContext dbc,
                      CmsUUID resourceId)
                      throws CmsDataAccessException
Reads the maximal publish tag for a specified resource id.

Parameters:
dbc - the current database context
resourceId - 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

int readNextPublishTag(CmsDbContext dbc)
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 context
principalId - the id of the principal to retrieve
Returns:
the historical principal entry
Throws:
CmsDataAccessException - if something goes wrong

readProject

CmsHistoryProject readProject(CmsDbContext dbc,
                              CmsUUID projectId)
                              throws CmsDataAccessException
Reads the latest historical project version with the given id.

Parameters:
dbc - the current database context
projectId - the project id
Returns:
the requested historical project
Throws:
CmsDataAccessException - is something goes wrong

readProject

CmsHistoryProject readProject(CmsDbContext dbc,
                              int publishTag)
                              throws CmsDataAccessException
Reads an historical project version.

Parameters:
dbc - the current database context
publishTag - the publish tag
Returns:
the requested historical project
Throws:
CmsDataAccessException - is something goes wrong

readProjectResources

java.util.List readProjectResources(CmsDbContext dbc,
                                    int publishTag)
                                    throws CmsDataAccessException
Reads all resources that belong to the historical project identified by the given publish tag.

Parameters:
dbc - the current database context
publishTag - 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

java.util.List readProjects(CmsDbContext dbc)
                            throws CmsDataAccessException
Returns all projects from the history.

Parameters:
dbc - the current database context
Returns:
list of CmsHistoryProject objects with all projects from history.
Throws:
CmsDataAccessException - if an error occurs

readProperties

java.util.List 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 context
historicalResource - the resource to read the properties from
Returns:
a list of CmsProperty objects
Throws:
CmsDataAccessException - if something goes wrong

readPropertyDefinition

CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc,
                                             java.lang.String name)
                                             throws CmsDataAccessException
Reads a property definition with the given name.

Parameters:
dbc - the current database context
name - 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

int readPublishTag(CmsDbContext dbc,
                   long maxdate)
                   throws CmsDataAccessException
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 context
maxdate - 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 context
structureId - the structure id of the resource to read
version - the desired version number
Returns:
the historical resource version
Throws:
CmsDataAccessException - if something goes wrong

writePrincipal

void writePrincipal(CmsDbContext dbc,
                    I_CmsPrincipal principal)
                    throws CmsDataAccessException
Writes an historical entry for the given principal.

Parameters:
dbc - the current database context
principal - the principal to write
Throws:
CmsDataAccessException - if something goes wrong

writeProject

void writeProject(CmsDbContext dbc,
                  int publishTag,
                  long publishDate)
                  throws CmsDataAccessException
Creates an historical entry for the current project.

Parameters:
dbc - the current database context
publishTag - the publish tag
publishDate - long timestamp when the current project was published
Throws:
CmsDataAccessException - if something goes wrong

writeProperties

void writeProperties(CmsDbContext dbc,
                     CmsResource resource,
                     java.util.List properties,
                     int publishTag)
                     throws CmsDataAccessException
Writes the properties of a resource to the history.

Parameters:
dbc - the current database context
resource - the resource of the properties
properties - the properties to write
publishTag - the publish tag
Throws:
CmsDataAccessException - if something goes wrong

writeResource

void writeResource(CmsDbContext dbc,
                   CmsResource resource,
                   java.util.List properties,
                   int publishTag)
                   throws CmsDataAccessException
Writes a resource to the history.

Parameters:
dbc - the current database context
resource - the resource that is written to the history
properties - the properties of the resource
publishTag - the publish tag
Throws:
CmsDataAccessException - if something goes wrong