org.opencms.db
Interface I_CmsBackupDriver

All Known Implementing Classes:
CmsBackupDriver

public interface I_CmsBackupDriver

Definitions of all required backup driver methods.

A backup driver is a driver to write projects, resources and properties of resources optionally to a second set of backup database tables while resources get published. A unique backup tag ID is used to identify a set of resource that were saved during one backup process.

Since:
6.0.0
Version:
$Revision: 1.52 $
Author:
Michael Emmerich, Thomas Weckert

Field Summary
static int DRIVER_TYPE_ID
          The type ID to identify backup driver implementations.
 
Method Summary
 CmsPropertyDefinition createBackupPropertyDefinition(CmsDbContext dbc, java.lang.String name)
          Creates a new property defintion in the database.
 CmsBackupResource createBackupResource(java.sql.ResultSet res, boolean hasContent)
          Creates a valid CmsBackupResource instance from a JDBC ResultSet.
 void deleteBackup(CmsDbContext dbc, CmsBackupResource res, int tag, int versions)
          Deletes all backup versions of a backup resource that are older than a given project tag and where the version id is lower than a given value.
 void deleteBackupPropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef)
          Deletes a property defintion.
 void deleteBackups(CmsDbContext context, java.util.List existingBackups, int maxVersions)
          Deletes backup versions of a resource.
 void destroy()
          Destroys this driver.
 CmsSqlManager getSqlManager()
          Returns the SqlManager of this driver.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
 CmsBackupResource readBackupFile(CmsDbContext dbc, int tagId, java.lang.String resourcePath)
          Reads a backup file including the file content.
 java.util.List readBackupFileHeaders(CmsDbContext dbc)
          Reads all backup file headers excluding the file content.
 java.util.List readBackupFileHeaders(CmsDbContext dbc, java.lang.String resourcePath, CmsUUID id)
          Reads all file headers of a file.
 int readBackupMaxVersion(CmsDbContext dbc, CmsUUID resourceId)
          Returns the max. current backup version of a resource.
 CmsBackupProject readBackupProject(CmsDbContext dbc, int tagId)
          Reads a backup project.
 java.util.List readBackupProjectResources(CmsDbContext dbc, int tagId)
          Reads all resources that belong to a given backup version ID.
 java.util.List readBackupProjects(CmsDbContext dbc)
          Returns all projects from the history.
 int readBackupProjectTag(CmsDbContext dbc, long maxdate)
          Gets the TagId of the first backup project after a given date.
 java.util.List readBackupProperties(CmsDbContext dbc, CmsBackupResource resource)
          Returns a list of all properties of a backup file or folder.
 CmsPropertyDefinition readBackupPropertyDefinition(CmsDbContext dbc, java.lang.String name)
          Reads a property definition for the specified mapping type.
 int readMaxTagId(CmsDbContext dbc, CmsResource resource)
          Reads the max. backup tag ID for a specified resource.
 int readNextBackupTagId(CmsDbContext dbc)
          Returns the next available backup version ID for a resource.
 void writeBackupProject(CmsDbContext dbc, int tagId, long publishDate)
          Creates a backup of the current project.
 void writeBackupProperties(CmsDbContext dbc, CmsResource resource, java.util.List properties, CmsUUID backupId, int tagId, int versionId)
          Writes the properties of a resource to the backup.
 void writeBackupResource(CmsDbContext dbc, CmsResource resource, java.util.List properties, int tagId, long publishDate, int maxVersions)
          Writes a resource to the backup.
 

Field Detail

DRIVER_TYPE_ID

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

See Also:
Constant Field Values
Method Detail

createBackupPropertyDefinition

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

Parameters:
dbc - the current database context
name - the name of the propertydefinitions to overwrite
Returns:
the new propertydefinition
Throws:
CmsDataAccessException - if something goes wrong

createBackupResource

public CmsBackupResource createBackupResource(java.sql.ResultSet res,
                                              boolean hasContent)
                                       throws java.sql.SQLException
Creates a valid CmsBackupResource instance from a JDBC ResultSet.

Parameters:
res - the JDBC result set
hasContent - true if the file content is part of the result set
Returns:
CmsBackupResource the new resource/file instance
Throws:
java.sql.SQLException - if a requested attribute was not found in the result set

deleteBackup

public void deleteBackup(CmsDbContext dbc,
                         CmsBackupResource res,
                         int tag,
                         int versions)
                  throws CmsDataAccessException
Deletes all backup versions of a backup resource that are older than a given project tag and where the version id is lower than a given value.

Parameters:
dbc - the current database context
res - the backup resource
tag - the project tag date
versions - the deletion version
Throws:
CmsDataAccessException - if something goes wrong

deleteBackupPropertyDefinition

public void deleteBackupPropertyDefinition(CmsDbContext dbc,
                                           CmsPropertyDefinition metadef)
                                    throws CmsDataAccessException
Deletes a property defintion.

Parameters:
dbc - the current database context
metadef - the propertydefinitions to be deleted
Throws:
CmsDataAccessException - if something goes wrong

deleteBackups

public void deleteBackups(CmsDbContext context,
                          java.util.List existingBackups,
                          int maxVersions)
                   throws CmsDataAccessException
Deletes backup versions of a resource.

Deletes the m-n oldest backup versions, if m is the number of backup versions, and n the number of max. allowed backup versions.

Parameters:
context - the current database context
existingBackups - a list of backup resources ordered by their ascending creation date
maxVersions - maximum number of versions per resource
Throws:
CmsDataAccessException - if something goes wrong

destroy

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

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

getSqlManager

public CmsSqlManager getSqlManager()
Returns the SqlManager of this driver.

Returns:
the SqlManager of this driver

initSqlManager

public 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

readBackupFile

public CmsBackupResource readBackupFile(CmsDbContext dbc,
                                        int tagId,
                                        java.lang.String resourcePath)
                                 throws CmsDataAccessException
Reads a backup file including the file content.

Parameters:
dbc - the current database context
tagId - the desired tag ID of the file
resourcePath - the path of the file to read
Returns:
the backup file
Throws:
CmsDataAccessException - if something goes wrong

readBackupFileHeaders

public java.util.List readBackupFileHeaders(CmsDbContext dbc)
                                     throws CmsDataAccessException
Reads all backup file headers excluding the file content.

.

Parameters:
dbc - the current database context
Returns:
List with all backup file headers
Throws:
CmsDataAccessException - if something goes wrong

readBackupFileHeaders

public java.util.List readBackupFileHeaders(CmsDbContext dbc,
                                            java.lang.String resourcePath,
                                            CmsUUID id)
                                     throws CmsDataAccessException
Reads all file headers of a file.
This method returns a list with the history of all file headers, i.e. the file headers of a file, independent of the project they were attached to.
The reading excludes the file content.

The filter is (path OR id).

Parameters:
dbc - the current database context
resourcePath - the path of the file to read
id - the resource id (usefull for siblings)
Returns:
a list of file headers, as CmsBackupResource objects, read from the Cms
Throws:
CmsDataAccessException - if something goes wrong

readBackupMaxVersion

public int readBackupMaxVersion(CmsDbContext dbc,
                                CmsUUID resourceId)
                         throws CmsDataAccessException
Returns the max. current backup version of a resource.

Parameters:
dbc - the current database context
resourceId - the resource ID of the resource
Returns:
Returns the max. current backup version of a resource
Throws:
CmsDataAccessException - if something goes wrong

readBackupProject

public CmsBackupProject readBackupProject(CmsDbContext dbc,
                                          int tagId)
                                   throws CmsDataAccessException
Reads a backup project.

Parameters:
dbc - the current database context
tagId - the versionId of the project
Returns:
the requested backup project
Throws:
CmsDataAccessException - is something goes wrong

readBackupProjectResources

public java.util.List readBackupProjectResources(CmsDbContext dbc,
                                                 int tagId)
                                          throws CmsDataAccessException
Reads all resources that belong to a given backup version ID.

Parameters:
dbc - the current database context
tagId - the version ID of the backup
Returns:
all resources that belong to the given backup version ID
Throws:
CmsDataAccessException - if something goes wrong

readBackupProjects

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

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

readBackupProjectTag

public int readBackupProjectTag(CmsDbContext dbc,
                                long maxdate)
                         throws CmsDataAccessException
Gets the TagId of the first backup project after a given date.

This method is used during the deletion process of older backup data.

Parameters:
dbc - the current database context
maxdate - the date to compare the backup projects with
Returns:
tag id of the first backup project after maxdate
Throws:
CmsDataAccessException - if something goes wrong

readBackupProperties

public java.util.List readBackupProperties(CmsDbContext dbc,
                                           CmsBackupResource resource)
                                    throws CmsDataAccessException
Returns a list of all properties of a backup file or folder.

Parameters:
dbc - the current database context
resource - the resource to read the properties from
Returns:
a Map of Strings representing the properties of the resource
Throws:
CmsDataAccessException - if something goes wrong

readBackupPropertyDefinition

public CmsPropertyDefinition readBackupPropertyDefinition(CmsDbContext dbc,
                                                          java.lang.String name)
                                                   throws CmsDataAccessException
Reads a property definition for the specified mapping type.

Parameters:
dbc - the current database context
name - the name of the propertydefinition to read
Returns:
the propertydefinition that corresponds to the overgiven arguments - or null if there is no valid propertydefinition
Throws:
CmsDataAccessException - if something goes wrong

readMaxTagId

public int readMaxTagId(CmsDbContext dbc,
                        CmsResource resource)
                 throws CmsDataAccessException
Reads the max. backup tag ID for a specified resource.

Parameters:
dbc - the current database context
resource - the Cms resource
Returns:
the max. backup tag ID
Throws:
CmsDataAccessException - if something goes wrong

readNextBackupTagId

public int readNextBackupTagId(CmsDbContext dbc)
Returns the next available backup version ID for a resource.

Parameters:
dbc - the current database context
Returns:
the next available backup version ID

writeBackupProject

public void writeBackupProject(CmsDbContext dbc,
                               int tagId,
                               long publishDate)
                        throws CmsDataAccessException
Creates a backup of the current project.

Parameters:
dbc - the current database context
tagId - the version ID of the backup
publishDate - long timestamp when the current project was published.
Throws:
CmsDataAccessException - if something goes wrong

writeBackupProperties

public void writeBackupProperties(CmsDbContext dbc,
                                  CmsResource resource,
                                  java.util.List properties,
                                  CmsUUID backupId,
                                  int tagId,
                                  int versionId)
                           throws CmsDataAccessException
Writes the properties of a resource to the backup.

Parameters:
dbc - the current database context
resource - the resource of the properties
properties - the properties to write
backupId - the id backup
tagId - the tag ID of the backup
versionId - the version ID of the backup
Throws:
CmsDataAccessException - if something goes wrong

writeBackupResource

public void writeBackupResource(CmsDbContext dbc,
                                CmsResource resource,
                                java.util.List properties,
                                int tagId,
                                long publishDate,
                                int maxVersions)
                         throws CmsDataAccessException
Writes a resource to the backup.

Parameters:
dbc - the current database context
resource - the resource that is written to the backup
properties - the properties of the resource
tagId - the version ID of the backup
publishDate - long timestamp when the resource was published
maxVersions - maximum number of backup versions
Throws:
CmsDataAccessException - if something goes wrong