org.opencms.db.generic
Class CmsVfsDriver

java.lang.Object
  extended by org.opencms.db.generic.CmsVfsDriver
All Implemented Interfaces:
I_CmsDriver, I_CmsVfsDriver
Direct Known Subclasses:
CmsVfsDriver, CmsVfsDriver, CmsVfsDriver, CmsVfsDriver, CmsVfsDriver, CmsVfsDriver, CmsVfsDriver

public class CmsVfsDriver
extends java.lang.Object
implements I_CmsDriver, I_CmsVfsDriver

Generic (ANSI-SQL) database server implementation of the VFS driver methods.

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

Field Summary
protected  CmsDriverManager m_driverManager
          The driver manager.
protected  java.util.List m_resOp
          This field is temporarily used to compute the versions during publishing.
protected  CmsSqlManager m_sqlManager
          The sql manager.
 
Fields inherited from interface org.opencms.db.I_CmsDriver
AND_CONDITION, BEGIN_CONDITION, BEGIN_EXCLUDE_CONDITION, BEGIN_INCLUDE_CONDITION, END_CONDITION, OR_CONDITION
 
Fields inherited from interface org.opencms.db.I_CmsVfsDriver
DRIVER_TYPE_ID, REQ_ATTR_CHECK_PERMISSIONS, REQ_ATTR_RESOURCE_OUS, todo
 
Constructor Summary
CmsVfsDriver()
           
 
Method Summary
protected  void checkWritePermissionsInFolder(CmsDbContext dbc, CmsResource folder)
          Checks that the current user has write permissions for all subresources of the given folder.
 int countSiblings(CmsDbContext dbc, CmsUUID projectId, CmsUUID resourceId)
          Counts the number of siblings of a resource.
 void createContent(CmsDbContext dbc, CmsUUID projectId, CmsUUID resourceId, byte[] content)
          Creates a content entry for the resource identified by the specified resource id.
 CmsFile createFile(java.sql.ResultSet res, CmsUUID projectId)
          Creates a CmsFile instance from a JDBC ResultSet.
 CmsFile createFile(java.sql.ResultSet res, CmsUUID projectId, boolean hasFileContentInResultSet)
          Creates a CmsFile instance from a JDBC ResultSet.
 CmsFolder createFolder(java.sql.ResultSet res, CmsUUID projectId, boolean hasProjectIdInResultSet)
          Creates a CmsFolder instance from a JDBC ResultSet.
 void createOnlineContent(CmsDbContext dbc, CmsUUID resourceId, byte[] contents, int publishTag, boolean keepOnline, boolean needToUpdateContent)
          Creates a new content in the offline project.
 CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc, CmsUUID projectId, java.lang.String name, CmsPropertyDefinition.CmsPropertyType type)
          Creates a new property definition in the database.
 void createRelation(CmsDbContext dbc, CmsUUID projectId, CmsRelation relation)
          Creates a new CmsRelation object in the database.
 CmsResource createResource(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, byte[] content)
          Creates a new resource from a given CmsResource object.
 CmsResource createResource(java.sql.ResultSet res, CmsUUID projectId)
          Creates a CmsResource instance from a JDBC ResultSet.
 void createSibling(CmsDbContext dbc, CmsProject project, CmsResource resource)
          Creates a new sibling for a specified resource.
 void deletePropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef)
          Deletes a property definition.
 void deletePropertyObjects(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, int deleteOption)
          Deletes all property values of a file or folder.
 void deleteRelations(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, CmsRelationFilter filter)
          Deletes all relations with the given filter for the given resource.
 void destroy()
          Destroys this driver.
protected  java.lang.String escapeDbWildcard(java.lang.String path)
          Escapes the database wildcards within the resource path.
protected  java.util.List getResourceOus(CmsDbContext dbc, CmsUUID projectId, CmsResource resource)
          Returns all organizational units for the given resource.
 CmsSqlManager getSqlManager()
          Returns the SqlManager of this driver.
 void init(CmsDbContext dbc, CmsConfigurationManager configurationManager, java.util.List successiveDrivers, CmsDriverManager driverManager)
          Initializes the driver.
 CmsSqlManager initSqlManager(java.lang.String classname)
          Initializes the SQL manager for this driver.
protected  int internalCountProperties(CmsDbContext dbc, CmsPropertyDefinition propertyDefinition, CmsUUID projectId)
          Returns the count of properties for a property definition.
protected  java.lang.String internalReadParentId(CmsDbContext dbc, CmsUUID projectId, java.lang.String resourcename)
          Returns the parent id of the given resource.
protected  CmsRelation internalReadRelation(java.sql.ResultSet res)
          Creates a new CmsRelation object from the given result set entry.
protected  CmsResourceState internalReadResourceState(CmsDbContext dbc, CmsUUID projectId, CmsResource resource)
          Returns the resource state of the given resource.
protected  CmsResourceState internalReadStructureState(CmsDbContext dbc, CmsUUID projectId, CmsResource resource)
          Returns the structure state of the given resource.
protected  void internalRemoveFolder(CmsDbContext dbc, CmsProject currentProject, CmsResource resource)
          Removes a resource physically in the database.
protected  void internalUpdateVersions(CmsDbContext dbc, CmsResource resource)
          Updates the offline version numbers.
protected  void internalValidateResourceLength(CmsResource resource)
          Validates that the length setting of a resource is always correct.
protected  void moveRelations(CmsDbContext dbc, CmsUUID projectId, CmsUUID structureId, java.lang.String rootPath)
          Moves all relations of a resource to the new path.
 void moveResource(CmsDbContext dbc, CmsUUID projectId, CmsResource source, java.lang.String destinationPath)
          Moves the given resource to the specified destination path.
protected  void prepareExpiredTimeRangeCondition(CmsUUID projectId, long startTime, long endTime, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the expiration date.
protected  void preparePathCondition(CmsUUID projectId, java.lang.String parent, int mode, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the parentPath.
protected  void prepareProjectCondition(CmsUUID projectId, int mode, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the projectId.
protected  java.lang.String prepareRelationConditions(CmsUUID projectId, CmsRelationFilter filter, CmsResource resource, java.util.List params, boolean checkSource)
          Build the whole WHERE sql statement part for the given relation filter.
protected  void prepareReleasedTimeRangeCondition(CmsUUID projectId, long startTime, long endTime, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the released date.
protected  void prepareResourceCondition(CmsUUID projectId, int mode, java.lang.StringBuffer conditions)
          Appends the appropriate selection criteria related with the read mode.
protected  void prepareStateCondition(CmsUUID projectId, CmsResourceState state, int mode, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the resource state.
protected  void prepareTimeRangeCondition(CmsUUID projectId, long startTime, long endTime, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the date of the last modification.
protected  void prepareTypeCondition(CmsUUID projectId, int type, int mode, java.lang.StringBuffer conditions, java.util.List params)
          Appends the appropriate selection criteria related with the resource type.
 void publishResource(CmsDbContext dbc, CmsProject onlineProject, CmsResource onlineResource, CmsResource offlineResource)
          Publishes the structure and resource records of an offline resource into it's online counterpart.
 void publishVersions(CmsDbContext dbc, CmsResource resource, boolean firstSibling)
          Copies the version number from the offline resource to the online resource, this has to be done during publishing, direct after copying the resource itself.
 java.util.List readChildResources(CmsDbContext dbc, CmsProject currentProject, CmsResource resource, boolean getFolders, boolean getFiles)
          Reads all child-files and/or child-folders of a specified parent resource.
 byte[] readContent(CmsDbContext dbc, CmsUUID projectId, CmsUUID resourceId)
          Reads the content of a file specified by it's resource ID.
 CmsFolder readFolder(CmsDbContext dbc, CmsUUID projectId, CmsUUID folderId)
          Reads a folder specified by it's structure ID.
 CmsFolder readFolder(CmsDbContext dbc, CmsUUID projectId, java.lang.String folderPath)
          Reads a folder specified by it's resource name.
 CmsFolder readParentFolder(CmsDbContext dbc, CmsUUID projectId, CmsUUID structureId)
          Reads the parent folder of a resource specified by it's structure ID.
 CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc, java.lang.String name, CmsUUID projectId)
          Reads a property definition for the specified resource type.
 java.util.List readPropertyDefinitions(CmsDbContext dbc, CmsUUID projectId)
          Reads all property definitions for the specified mapping type.
 CmsProperty readPropertyObject(CmsDbContext dbc, java.lang.String key, CmsProject project, CmsResource resource)
          Reads a property object from the database specified by it's key name mapped to a resource.
 java.util.List readPropertyObjects(CmsDbContext dbc, CmsProject project, CmsResource resource)
          Reads all property objects mapped to a specified resource from the database.
 java.util.List readRelations(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, CmsRelationFilter filter)
          Reads all relations with the given filter for the given resource.
 CmsResource readResource(CmsDbContext dbc, CmsUUID projectId, CmsUUID structureId, boolean includeDeleted)
          Reads a resource specified by it's structure ID.
 CmsResource readResource(CmsDbContext dbc, CmsUUID projectId, java.lang.String path, boolean includeDeleted)
          Reads a resource specified by it's resource name.
 java.util.List readResources(CmsDbContext dbc, CmsUUID projectId, CmsResourceState state, int mode)
          Reads all resources inside a given project and with a given state.
 java.util.List readResourcesForPrincipalACE(CmsDbContext dbc, CmsProject project, CmsUUID principalId)
          Returns all resources associated to a given principal via an ACE.
 java.util.List readResourcesForPrincipalAttr(CmsDbContext dbc, CmsProject project, CmsUUID principalId)
          Returns all resources associated to a given principal through some of following attributes.
 java.util.List readResourcesWithProperty(CmsDbContext dbc, CmsUUID projectId, CmsUUID propertyDef, java.lang.String path, java.lang.String value)
          Reads all resources that have a value (containing the specified value) set for the specified property (definition), in the given path.
 java.util.List readResourceTree(CmsDbContext dbc, CmsUUID projectId, java.lang.String parentPath, int type, CmsResourceState state, long lastModifiedAfter, long lastModifiedBefore, long releasedAfter, long releasedBefore, long expiredAfter, long expiredBefore, int mode)
          Reads all resources inside a given project matching the criteria specified by parameter values.
 java.util.List readSiblings(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, boolean includeDeleted)
          Reads all siblings that point to the resource record of a specified resource.
 java.util.Map readVersions(CmsDbContext dbc, CmsUUID projectId, CmsUUID resourceId, CmsUUID structureId)
          Reads a resource version numbers.
 void removeFile(CmsDbContext dbc, CmsUUID projectId, CmsResource resource)
          Removes a file physically in the database.
 void removeFolder(CmsDbContext dbc, CmsProject currentProject, CmsResource resource)
          Removes a folder physically in the database.
protected  void repairBrokenRelations(CmsDbContext dbc, CmsUUID projectId, CmsUUID structureId, java.lang.String rootPath)
          Repairs broken links.
 void replaceResource(CmsDbContext dbc, CmsResource newResource, byte[] resContent, int newResourceType)
          Replaces the content and properties of an existing resource.
 void setDriverManager(CmsDriverManager driverManager)
          Sets the driver manager for this driver.
 void setSqlManager(CmsSqlManager sqlManager)
          Sets the SQL manager of this driver.
 void transferResource(CmsDbContext dbc, CmsProject project, CmsResource resource, CmsUUID createdUser, CmsUUID lastModifiedUser)
          Transfers the attributes of a resource from to the given users.
protected  void updateBrokenRelations(CmsDbContext dbc, CmsUUID projectId, java.lang.String rootPath)
          Updates broken links.
 void updateRelations(CmsDbContext dbc, CmsProject onlineProject, CmsResource offlineResource)
          Updates the relations on the online project copying the relations from the offline project.
 boolean validateResourceIdExists(CmsDbContext dbc, CmsUUID projectId, CmsUUID resourceId)
          Validates if the specified resource ID in the tables of the specified project {offline|online} exists.
 boolean validateStructureIdExists(CmsDbContext dbc, CmsUUID projectId, CmsUUID structureId)
          Validates if the specified structure ID in the tables of the specified project {offline|online} exists.
 void writeContent(CmsDbContext dbc, CmsUUID resourceId, byte[] content)
          Writes the resource content with the specified resource id.
 void writeLastModifiedProjectId(CmsDbContext dbc, CmsProject project, CmsUUID projectId, CmsResource resource)
          Writes the "last-modified-in-project" ID of a resource.
 void writePropertyObject(CmsDbContext dbc, CmsProject project, CmsResource resource, CmsProperty property)
          Writes a property object to the database mapped to a specified resource.
 void writePropertyObjects(CmsDbContext dbc, CmsProject project, CmsResource resource, java.util.List properties)
          Writes a list of property objects to the database mapped to a specified resource.
 void writeResource(CmsDbContext dbc, CmsUUID projectId, CmsResource resource, int changed)
          Writes the structure and/or resource record(s) of an existing file.
 void writeResourceState(CmsDbContext dbc, CmsProject project, CmsResource resource, int changed, boolean isPublishing)
          Writes file state in either the structure or resource record, or both of them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.db.I_CmsDriver
toString
 

Field Detail

m_driverManager

protected CmsDriverManager m_driverManager
The driver manager.


m_resOp

protected java.util.List m_resOp
This field is temporarily used to compute the versions during publishing.

See Also:
publishVersions(CmsDbContext, CmsResource, boolean)

m_sqlManager

protected CmsSqlManager m_sqlManager
The sql manager.

Constructor Detail

CmsVfsDriver

public CmsVfsDriver()
Method Detail

countSiblings

public int countSiblings(CmsDbContext dbc,
                         CmsUUID projectId,
                         CmsUUID resourceId)
                  throws CmsDataAccessException
Counts the number of siblings of a resource.

Specified by:
countSiblings in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the current project id
resourceId - the resource id to count the number of siblings from
Returns:
number of siblings
Throws:
CmsDataAccessException - if something goes wrong

createContent

public void createContent(CmsDbContext dbc,
                          CmsUUID projectId,
                          CmsUUID resourceId,
                          byte[] content)
                   throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a content entry for the resource identified by the specified resource id.

Specified by:
createContent in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the current project
resourceId - the resource id of the resource to create the content for
content - the content to write
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createContent(CmsDbContext, CmsUUID, CmsUUID, byte[])

createFile

public CmsFile createFile(java.sql.ResultSet res,
                          CmsUUID projectId)
                   throws java.sql.SQLException
Description copied from interface: I_CmsVfsDriver
Creates a CmsFile instance from a JDBC ResultSet.

Specified by:
createFile in interface I_CmsVfsDriver
Parameters:
res - the JDBC ResultSet
projectId - the project id
Returns:
the created file
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute
See Also:
I_CmsVfsDriver.createFile(java.sql.ResultSet, CmsUUID)

createFile

public CmsFile createFile(java.sql.ResultSet res,
                          CmsUUID projectId,
                          boolean hasFileContentInResultSet)
                   throws java.sql.SQLException
Description copied from interface: I_CmsVfsDriver
Creates a CmsFile instance from a JDBC ResultSet.

Specified by:
createFile in interface I_CmsVfsDriver
Parameters:
res - the JDBC ResultSet
projectId - the project id
hasFileContentInResultSet - flag to include the file content
Returns:
the created file
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute
See Also:
I_CmsVfsDriver.createFile(java.sql.ResultSet, CmsUUID, boolean)

createFolder

public CmsFolder createFolder(java.sql.ResultSet res,
                              CmsUUID projectId,
                              boolean hasProjectIdInResultSet)
                       throws java.sql.SQLException
Description copied from interface: I_CmsVfsDriver
Creates a CmsFolder instance from a JDBC ResultSet.

Specified by:
createFolder in interface I_CmsVfsDriver
Parameters:
res - the JDBC ResultSet
projectId - the ID of the current project
hasProjectIdInResultSet - true if the SQL select query includes the PROJECT_ID table attribute
Returns:
the created folder
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute
See Also:
I_CmsVfsDriver.createFolder(java.sql.ResultSet, CmsUUID, boolean)

createOnlineContent

public void createOnlineContent(CmsDbContext dbc,
                                CmsUUID resourceId,
                                byte[] contents,
                                int publishTag,
                                boolean keepOnline,
                                boolean needToUpdateContent)
                         throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a new content in the offline project.

Specified by:
createOnlineContent in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
resourceId - the resource id of the content to write
contents - the content to publish
publishTag - the publish tag
keepOnline - if the content is online or has to be put in the history
needToUpdateContent - if the content blob has to be updated
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createOnlineContent(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, byte[], int, boolean, boolean)

createPropertyDefinition

public CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc,
                                                      CmsUUID projectId,
                                                      java.lang.String name,
                                                      CmsPropertyDefinition.CmsPropertyType type)
                                               throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a new property definition in the database.

Specified by:
createPropertyDefinition in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project in which the property definition is created
name - the name of the property definition
type - the type of the property definition
Returns:
the new property definition
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createPropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, java.lang.String, org.opencms.file.CmsPropertyDefinition.CmsPropertyType)

createRelation

public void createRelation(CmsDbContext dbc,
                           CmsUUID projectId,
                           CmsRelation relation)
                    throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a new CmsRelation object in the database.

Specified by:
createRelation in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project to execute the query in
relation - the relation to create
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createRelation(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.relations.CmsRelation)

createResource

public CmsResource createResource(CmsDbContext dbc,
                                  CmsUUID projectId,
                                  CmsResource resource,
                                  byte[] content)
                           throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a new resource from a given CmsResource object.

This method works for both files and folders. Existing resources get overwritten.

Specified by:
createResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the current project
resource - the resource to be created
content - the file content, or null in case of a folder
Returns:
the created Cms resource
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createResource(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsResource, byte[])

createResource

public CmsResource createResource(java.sql.ResultSet res,
                                  CmsUUID projectId)
                           throws java.sql.SQLException
Description copied from interface: I_CmsVfsDriver
Creates a CmsResource instance from a JDBC ResultSet.

Specified by:
createResource in interface I_CmsVfsDriver
Parameters:
res - the JDBC ResultSet
projectId - the ID of the current project to adjust the modification date in case the resource is a VFS link
Returns:
the created resource
Throws:
java.sql.SQLException - in case the result set does not include a requested table attribute
See Also:
I_CmsVfsDriver.createResource(java.sql.ResultSet, CmsUUID)

createSibling

public void createSibling(CmsDbContext dbc,
                          CmsProject project,
                          CmsResource resource)
                   throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Creates a new sibling for a specified resource.

Specified by:
createSibling in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the project where to create the link
resource - the link prototype
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.createSibling(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource)

deletePropertyDefinition

public void deletePropertyDefinition(CmsDbContext dbc,
                                     CmsPropertyDefinition metadef)
                              throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Deletes a property definition.

Specified by:
deletePropertyDefinition in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
metadef - the property definitions to be deleted
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.deletePropertyDefinition(org.opencms.db.CmsDbContext, org.opencms.file.CmsPropertyDefinition)

deletePropertyObjects

public void deletePropertyObjects(CmsDbContext dbc,
                                  CmsUUID projectId,
                                  CmsResource resource,
                                  int deleteOption)
                           throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Deletes all property values of a file or folder.

You may specify which whether just structure or resource property values should be deleted, or both of them.

Specified by:
deletePropertyObjects in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project
resource - the resource
deleteOption - determines which property values should be deleted
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.deletePropertyObjects(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsResource, int)

deleteRelations

public void deleteRelations(CmsDbContext dbc,
                            CmsUUID projectId,
                            CmsResource resource,
                            CmsRelationFilter filter)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Deletes all relations with the given filter for the given resource.

Specified by:
deleteRelations in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project to execute the query in
resource - the base resource. May be null for all
filter - the filter to restrict the relations to remove
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.deleteRelations(org.opencms.db.CmsDbContext, CmsUUID, CmsResource, org.opencms.relations.CmsRelationFilter)

destroy

public void destroy()
             throws java.lang.Throwable
Description copied from interface: I_CmsVfsDriver
Destroys this driver.

Specified by:
destroy in interface I_CmsVfsDriver
Throws:
java.lang.Throwable - if something goes wrong
See Also:
I_CmsVfsDriver.destroy()

getSqlManager

public CmsSqlManager getSqlManager()
Description copied from interface: I_CmsVfsDriver
Returns the SqlManager of this driver.

Specified by:
getSqlManager in interface I_CmsVfsDriver
Returns:
the SqlManager of this driver
See Also:
I_CmsVfsDriver.getSqlManager()

init

public void init(CmsDbContext dbc,
                 CmsConfigurationManager configurationManager,
                 java.util.List successiveDrivers,
                 CmsDriverManager driverManager)
Description copied from interface: I_CmsDriver
Initializes the driver.

Specified by:
init in interface I_CmsDriver
Parameters:
dbc - the current database context
configurationManager - the configuration manager
successiveDrivers - a list of successive drivers to be initialized
driverManager - the initialized OpenCms driver manager
See Also:
I_CmsDriver.init(org.opencms.db.CmsDbContext, org.opencms.configuration.CmsConfigurationManager, java.util.List, org.opencms.db.CmsDriverManager)

initSqlManager

public CmsSqlManager initSqlManager(java.lang.String classname)
Description copied from interface: I_CmsVfsDriver
Initializes 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:
initSqlManager in interface I_CmsVfsDriver
Parameters:
classname - the class name of the SQL manager
Returns:
the SQL manager for this driver
See Also:
I_CmsVfsDriver.initSqlManager(String)

moveResource

public void moveResource(CmsDbContext dbc,
                         CmsUUID projectId,
                         CmsResource source,
                         java.lang.String destinationPath)
                  throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Moves the given resource to the specified destination path.

Specified by:
moveResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the Id of the project
source - the resource to move
destinationPath - the root path of the destination resource
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.moveResource(CmsDbContext, CmsUUID, CmsResource, String)

publishResource

public void publishResource(CmsDbContext dbc,
                            CmsProject onlineProject,
                            CmsResource onlineResource,
                            CmsResource offlineResource)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Publishes the structure and resource records of an offline resource into it's online counterpart.

Specified by:
publishResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
onlineProject - the online project
onlineResource - the online resource
offlineResource - the offline resource
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.publishResource(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, org.opencms.file.CmsResource)

publishVersions

public void publishVersions(CmsDbContext dbc,
                            CmsResource resource,
                            boolean firstSibling)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Copies the version number from the offline resource to the online resource, this has to be done during publishing, direct after copying the resource itself.

Specified by:
publishVersions in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
resource - the resource that has been publish
firstSibling - if this is the first sibling to be publish
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.publishVersions(org.opencms.db.CmsDbContext, org.opencms.file.CmsResource, boolean)

readChildResources

public java.util.List readChildResources(CmsDbContext dbc,
                                         CmsProject currentProject,
                                         CmsResource resource,
                                         boolean getFolders,
                                         boolean getFiles)
                                  throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all child-files and/or child-folders of a specified parent resource.

Specified by:
readChildResources in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
currentProject - the current project
resource - the parent folder
getFolders - if true the child folders of the parent folder are returned in the result set
getFiles - if true the child files of the parent folder are returned in the result set
Returns:
a list of all sub folders or sub files
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readChildResources(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, boolean, boolean)

readContent

public byte[] readContent(CmsDbContext dbc,
                          CmsUUID projectId,
                          CmsUUID resourceId)
                   throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads the content of a file specified by it's resource ID.

Specified by:
readContent in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the ID of the current project
resourceId - the id of the resource
Returns:
the file content
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readContent(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID)

readFolder

public CmsFolder readFolder(CmsDbContext dbc,
                            CmsUUID projectId,
                            CmsUUID folderId)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a folder specified by it's structure ID.

Specified by:
readFolder in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project in which the resource will be used
folderId - the structure id of the folder to be read
Returns:
the read folder
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readFolder(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID)

readFolder

public CmsFolder readFolder(CmsDbContext dbc,
                            CmsUUID projectId,
                            java.lang.String folderPath)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a folder specified by it's resource name.

Specified by:
readFolder in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project in which the resource will be used
folderPath - the name of the folder to be read
Returns:
the read folder
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readFolder(org.opencms.db.CmsDbContext, CmsUUID, java.lang.String)

readParentFolder

public CmsFolder readParentFolder(CmsDbContext dbc,
                                  CmsUUID projectId,
                                  CmsUUID structureId)
                           throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads the parent folder of a resource specified by it's structure ID.

The parent folder for the root '/' is defined as null.

Specified by:
readParentFolder in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project in which the resource will be used
structureId - the id of the resource to read the parent folder for
Returns:
the read folder, or null
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readParentFolder(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID)

readPropertyDefinition

public CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc,
                                                    java.lang.String name,
                                                    CmsUUID projectId)
                                             throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a property definition for the specified resource type.

If no property definition with the given name is found, null is returned.

Specified by:
readPropertyDefinition in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
name - the name of the property definition to read
projectId - the id of the project
Returns:
the property definition that was read
Throws:
CmsDataAccessException - a CmsDbEntryNotFoundException is thrown if the property definition does not exist
See Also:
I_CmsVfsDriver.readPropertyDefinition(org.opencms.db.CmsDbContext, java.lang.String, CmsUUID)

readPropertyDefinitions

public java.util.List readPropertyDefinitions(CmsDbContext dbc,
                                              CmsUUID projectId)
                                       throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all property definitions for the specified mapping type.

Specified by:
readPropertyDefinitions in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project
Returns:
a list with the CmsPropertyDefinition objects (may be empty)
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readPropertyDefinitions(org.opencms.db.CmsDbContext, CmsUUID)

readPropertyObject

public CmsProperty readPropertyObject(CmsDbContext dbc,
                                      java.lang.String key,
                                      CmsProject project,
                                      CmsResource resource)
                               throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a property object from the database specified by it's key name mapped to a resource.

The implementation must return CmsProperty.getNullProperty() if the property is not found.

TODO: change project parameter to project id

Specified by:
readPropertyObject in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
key - the key of the property
project - the current project
resource - the resource where the property is attached to
Returns:
a CmsProperty object containing both the structure and resource value of the property
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readPropertyObject(org.opencms.db.CmsDbContext, java.lang.String, org.opencms.file.CmsProject, org.opencms.file.CmsResource)

readPropertyObjects

public java.util.List readPropertyObjects(CmsDbContext dbc,
                                          CmsProject project,
                                          CmsResource resource)
                                   throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all property objects mapped to a specified resource from the database.

The implementation must return an empty list if no properties are found at all.

TODO: change project parameter to project id

Specified by:
readPropertyObjects in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the current project
resource - the resource where the property is attached to
Returns:
a list with CmsProperty objects containing both the structure and resource value of the property
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readPropertyObjects(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource)

readRelations

public java.util.List readRelations(CmsDbContext dbc,
                                    CmsUUID projectId,
                                    CmsResource resource,
                                    CmsRelationFilter filter)
                             throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all relations with the given filter for the given resource.

Specified by:
readRelations in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project to execute the query in
resource - the resource to read the relations for, may be null for all
filter - the filter to restrict the relations to retrieve
Returns:
the read relations
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readRelations(org.opencms.db.CmsDbContext, CmsUUID, CmsResource, org.opencms.relations.CmsRelationFilter)

readResource

public CmsResource readResource(CmsDbContext dbc,
                                CmsUUID projectId,
                                CmsUUID structureId,
                                boolean includeDeleted)
                         throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a resource specified by it's structure ID.

Specified by:
readResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the Id of the project
structureId - the Id of the resource
includeDeleted - true if already deleted files are included
Returns:
the resource that was read
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResource(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID, boolean)

readResource

public CmsResource readResource(CmsDbContext dbc,
                                CmsUUID projectId,
                                java.lang.String path,
                                boolean includeDeleted)
                         throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a resource specified by it's resource name.

Specified by:
readResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the Id of the project in which the resource will be used
path - the name of the file
includeDeleted - true if already deleted files are included
Returns:
the resource that was read
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResource(org.opencms.db.CmsDbContext, CmsUUID, java.lang.String, boolean)

readResources

public java.util.List readResources(CmsDbContext dbc,
                                    CmsUUID projectId,
                                    CmsResourceState state,
                                    int mode)
                             throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all resources inside a given project and with a given state.

Specified by:
readResources in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the current project
state - the state to match
mode - flag signaling the read mode
Returns:
a list with all resources that where read
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResources(org.opencms.db.CmsDbContext, CmsUUID, CmsResourceState, int)

readResourcesForPrincipalACE

public java.util.List readResourcesForPrincipalACE(CmsDbContext dbc,
                                                   CmsProject project,
                                                   CmsUUID principalId)
                                            throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Returns all resources associated to a given principal via an ACE.

Specified by:
readResourcesForPrincipalACE in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the to read the entries from
principalId - the id of the principal
Returns:
a list of CmsResource objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResourcesForPrincipalACE(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID)

readResourcesForPrincipalAttr

public java.util.List readResourcesForPrincipalAttr(CmsDbContext dbc,
                                                    CmsProject project,
                                                    CmsUUID principalId)
                                             throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Returns all resources associated to a given principal through some of following attributes.

Specified by:
readResourcesForPrincipalAttr in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the to read the entries from
principalId - the id of the principal
Returns:
a list of CmsResource objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResourcesForPrincipalAttr(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.util.CmsUUID)

readResourcesWithProperty

public java.util.List readResourcesWithProperty(CmsDbContext dbc,
                                                CmsUUID projectId,
                                                CmsUUID propertyDef,
                                                java.lang.String path,
                                                java.lang.String value)
                                         throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all resources that have a value (containing the specified value) set for the specified property (definition), in the given path.

Both individual and shared properties of a resource are checked.

If the value parameter is null, all resources having the given property set are returned.

Specified by:
readResourcesWithProperty in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the project
propertyDef - the id of the property definition
path - the folder to get the resources with the property from
value - the string to search in the value of the property
Returns:
a list of all CmsResource objects that have a value set for the specified property.
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResourcesWithProperty(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID, String, String)

readResourceTree

public java.util.List readResourceTree(CmsDbContext dbc,
                                       CmsUUID projectId,
                                       java.lang.String parentPath,
                                       int type,
                                       CmsResourceState state,
                                       long lastModifiedAfter,
                                       long lastModifiedBefore,
                                       long releasedAfter,
                                       long releasedBefore,
                                       long expiredAfter,
                                       long expiredBefore,
                                       int mode)
                                throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all resources inside a given project matching the criteria specified by parameter values.

Important: If CmsDriverManager.READMODE_EXCLUDE_TREE is true (or CmsDriverManager.READMODE_INCLUDE_TREE is false), the provided parent String must be the UUID of the parent folder, NOT the parent folder path.

Specified by:
readResourceTree in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project id for matching resources
parentPath - the path to the resource used as root of the searched subtree or CmsDriverManager.READ_IGNORE_PARENT, CmsDriverManager.READMODE_EXCLUDE_TREE means to read immediate children only
type - the resource type of matching resources or CmsDriverManager.READ_IGNORE_TYPE (meaning inverted by CmsDriverManager.READMODE_EXCLUDE_TYPE
state - the state of matching resources (meaning inverted by CmsDriverManager.READMODE_EXCLUDE_STATE or null to ignore
lastModifiedAfter - the start of the time range for the last modification date of matching resources or READ_IGNORE_TIME
lastModifiedBefore - the end of the time range for the last modification date of matching resources or READ_IGNORE_TIME
releasedAfter - the start of the time range for the release date of matching resources
releasedBefore - the end of the time range for the release date of matching resources
expiredAfter - the start of the time range for the expire date of matching resources
expiredBefore - the end of the time range for the expire date of matching resources
mode - additional mode flags:
Returns:
a list of CmsResource objects matching the given criteria
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readResourceTree(org.opencms.db.CmsDbContext, CmsUUID, java.lang.String, int, CmsResourceState, long, long, long, long, long, long, int)

readSiblings

public java.util.List readSiblings(CmsDbContext dbc,
                                   CmsUUID projectId,
                                   CmsResource resource,
                                   boolean includeDeleted)
                            throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads all siblings that point to the resource record of a specified resource.

Specified by:
readSiblings in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the current project
resource - the specified resource
includeDeleted - true if deleted siblings should be included in the result list
Returns:
a list of CmsResources that are siblings to the specified resource, including the specified resource itself.
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readSiblings(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsResource, boolean)

readVersions

public java.util.Map readVersions(CmsDbContext dbc,
                                  CmsUUID projectId,
                                  CmsUUID resourceId,
                                  CmsUUID structureId)
                           throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Reads a resource version numbers.

Specified by:
readVersions in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project to read the versions from
resourceId - the resource id of the resource to read the versions from
structureId - the structure id of the resource to read the versions from
Returns:
a map with two entries with keys "structure" and "resource" for the structure and resource version number respectively, the values are Integer objects and may be -1 if an entry could be found
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.readVersions(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

removeFile

public void removeFile(CmsDbContext dbc,
                       CmsUUID projectId,
                       CmsResource resource)
                throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Removes a file physically in the database.

Specified by:
removeFile in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the current project
resource - the resource
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.removeFile(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsResource)

removeFolder

public void removeFolder(CmsDbContext dbc,
                         CmsProject currentProject,
                         CmsResource resource)
                  throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Removes a folder physically in the database.

Specified by:
removeFolder in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
currentProject - the current project
resource - the folder
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.removeFolder(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource)

replaceResource

public void replaceResource(CmsDbContext dbc,
                            CmsResource newResource,
                            byte[] resContent,
                            int newResourceType)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Replaces the content and properties of an existing resource.

Specified by:
replaceResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
newResource - the new resource
resContent - the new content
newResourceType - the resource type
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.replaceResource(org.opencms.db.CmsDbContext, org.opencms.file.CmsResource, byte[], int)

setDriverManager

public void setDriverManager(CmsDriverManager driverManager)
Sets the driver manager for this driver.

Parameters:
driverManager - the new driver manager

setSqlManager

public void setSqlManager(CmsSqlManager sqlManager)
Sets the SQL manager of this driver.

Parameters:
sqlManager - the new SQL manager

transferResource

public void transferResource(CmsDbContext dbc,
                             CmsProject project,
                             CmsResource resource,
                             CmsUUID createdUser,
                             CmsUUID lastModifiedUser)
                      throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Transfers the attributes of a resource from to the given users.

Specified by:
transferResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the current project
resource - the resource to modify
createdUser - the id of the user to be set as the creator of the resource
lastModifiedUser - the id of the user to be set as the last modificator of the resource
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.transferResource(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, org.opencms.util.CmsUUID, org.opencms.util.CmsUUID)

updateRelations

public void updateRelations(CmsDbContext dbc,
                            CmsProject onlineProject,
                            CmsResource offlineResource)
                     throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Updates the relations on the online project copying the relations from the offline project.

TODO: add offlineProject parameter

Specified by:
updateRelations in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
onlineProject - the online project
offlineResource - the resource to update the relations for
Throws:
CmsDataAccessException - is something goes wrong
See Also:
I_CmsVfsDriver.updateRelations(CmsDbContext, CmsProject, CmsResource)

validateResourceIdExists

public boolean validateResourceIdExists(CmsDbContext dbc,
                                        CmsUUID projectId,
                                        CmsUUID resourceId)
                                 throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Validates if the specified resource ID in the tables of the specified project {offline|online} exists.

Specified by:
validateResourceIdExists in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the project id
resourceId - the resource id to test for
Returns:
true if a resource with the given id was found, false otherwise
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.validateResourceIdExists(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID)

validateStructureIdExists

public boolean validateStructureIdExists(CmsDbContext dbc,
                                         CmsUUID projectId,
                                         CmsUUID structureId)
                                  throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Validates if the specified structure ID in the tables of the specified project {offline|online} exists.

Specified by:
validateStructureIdExists in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the ID of current project
structureId - the structure id
Returns:
true, if the specified structure ID in the tables of the specified project {offline|online} exists
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.validateStructureIdExists(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.util.CmsUUID)

writeContent

public void writeContent(CmsDbContext dbc,
                         CmsUUID resourceId,
                         byte[] content)
                  throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes the resource content with the specified resource id.

Specified by:
writeContent in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
resourceId - the id of the resource used to identify the content to update
content - the new content of the file
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writeContent(org.opencms.db.CmsDbContext, org.opencms.util.CmsUUID, byte[])

writeLastModifiedProjectId

public void writeLastModifiedProjectId(CmsDbContext dbc,
                                       CmsProject project,
                                       CmsUUID projectId,
                                       CmsResource resource)
                                throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes the "last-modified-in-project" ID of a resource.

Specified by:
writeLastModifiedProjectId in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the resource record is updated with the ID of this project
projectId - the project id to write into the resource
resource - the resource that gets updated
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writeLastModifiedProjectId(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, CmsUUID, org.opencms.file.CmsResource)

writePropertyObject

public void writePropertyObject(CmsDbContext dbc,
                                CmsProject project,
                                CmsResource resource,
                                CmsProperty property)
                         throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes a property object to the database mapped to a specified resource.

Specified by:
writePropertyObject in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the current project
resource - the resource where the property should be attached to
property - a CmsProperty object containing both the structure and resource value of the property
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writePropertyObject(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, org.opencms.file.CmsProperty)

writePropertyObjects

public void writePropertyObjects(CmsDbContext dbc,
                                 CmsProject project,
                                 CmsResource resource,
                                 java.util.List properties)
                          throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes a list of property objects to the database mapped to a specified resource.

Specified by:
writePropertyObjects in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the current project
resource - the resource where the property should be attached to
properties - a list of CmsProperty objects
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writePropertyObjects(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, java.util.List)

writeResource

public void writeResource(CmsDbContext dbc,
                          CmsUUID projectId,
                          CmsResource resource,
                          int changed)
                   throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes the structure and/or resource record(s) of an existing file.

Common usages of this method are saving the resource information after creating, importing or restoring complete files where all file header attributes are changed. Both the structure and resource records get written. Thus, using this method affects all siblings of a resource! Use I_CmsVfsDriver.writeResourceState(CmsDbContext, CmsProject, CmsResource, int, boolean) instead if you just want to update the file state, e.g. of a single sibling.

The file state is set to "changed", unless the current state is "new" or "deleted". The "changed" argument allows to choose whether the structure or resource state, or none of them, is set to "changed".

The rating of the file state values is as follows:
unchanged < changed < new < deleted

Second, the "state" of the resource is the structure state, if the structure state has a higher file state value than the resource state. Otherwise the file state is the resource state.

Specified by:
writeResource in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
projectId - the id of the current project
resource - the resource to be updated
changed - determines whether the structure or resource state, or none of them, is set to "changed"
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writeResource(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.file.CmsResource, int)

writeResourceState

public void writeResourceState(CmsDbContext dbc,
                               CmsProject project,
                               CmsResource resource,
                               int changed,
                               boolean isPublishing)
                        throws CmsDataAccessException
Description copied from interface: I_CmsVfsDriver
Writes file state in either the structure or resource record, or both of them.

This method allows to change the resource state to any state by setting the desired state value in the specified CmsResource instance.

This method is frequently used while resources are published to set the file state back to "unchanged".

Only file state attributes. get updated here. Use I_CmsVfsDriver.writeResource(CmsDbContext, CmsUUID, CmsResource, int) instead to write the complete file header.

Please refer to the javadoc of I_CmsVfsDriver.writeResource(CmsDbContext, CmsUUID, CmsResource, int) to read how setting resource state values affects the file state.

Specified by:
writeResourceState in interface I_CmsVfsDriver
Parameters:
dbc - the current database context
project - the current project
resource - the resource to be updated
changed - determines whether the structure or resource state, or none of them, is set to "changed"
isPublishing - if this method is called during publishing to version numbers are updated
Throws:
CmsDataAccessException - if something goes wrong
See Also:
I_CmsVfsDriver.writeResourceState(org.opencms.db.CmsDbContext, org.opencms.file.CmsProject, org.opencms.file.CmsResource, int, boolean)

checkWritePermissionsInFolder

protected void checkWritePermissionsInFolder(CmsDbContext dbc,
                                             CmsResource folder)
                                      throws CmsDataAccessException
Checks that the current user has write permissions for all subresources of the given folder.

Parameters:
dbc - the current database context
folder - the folder to check
Throws:
CmsDataAccessException - if something goes wrong

escapeDbWildcard

protected java.lang.String escapeDbWildcard(java.lang.String path)
Escapes the database wildcards within the resource path.

This method is required to ensure chars in the resource path that have a special meaning in SQL (for example "_", which is the "any char" operator) are escaped.

It will escape the following chars:

Parameters:
path - the resource path
Returns:
the escaped resource path

getResourceOus

protected java.util.List getResourceOus(CmsDbContext dbc,
                                        CmsUUID projectId,
                                        CmsResource resource)
                                 throws CmsDbSqlException
Returns all organizational units for the given resource.

Parameters:
dbc - the database context
projectId - the id of the project
resource - the resource
Returns:
a list of CmsOrganizationalUnit objects
Throws:
CmsDbSqlException - if something goes wrong

internalCountProperties

protected int internalCountProperties(CmsDbContext dbc,
                                      CmsPropertyDefinition propertyDefinition,
                                      CmsUUID projectId)
                               throws CmsDataAccessException
Returns the count of properties for a property definition.

Parameters:
dbc - the current database context
propertyDefinition - the property definition to test
projectId - the ID of the current project
Returns:
the amount of properties for a property definition
Throws:
CmsDataAccessException - if something goes wrong

internalReadParentId

protected java.lang.String internalReadParentId(CmsDbContext dbc,
                                                CmsUUID projectId,
                                                java.lang.String resourcename)
                                         throws CmsDataAccessException
Returns the parent id of the given resource.

Parameters:
dbc - the current database context
projectId - the current project id
resourcename - the resource name to read the parent id for
Returns:
the parent id of the given resource
Throws:
CmsDataAccessException - if something goes wrong

internalReadRelation

protected CmsRelation internalReadRelation(java.sql.ResultSet res)
                                    throws java.sql.SQLException
Creates a new CmsRelation object from the given result set entry.

Parameters:
res - the result set
Returns:
the new CmsRelation object
Throws:
java.sql.SQLException - if something goes wrong

internalReadResourceState

protected CmsResourceState internalReadResourceState(CmsDbContext dbc,
                                                     CmsUUID projectId,
                                                     CmsResource resource)
                                              throws CmsDbSqlException
Returns the resource state of the given resource.

Parameters:
dbc - the database context
projectId - the id of the project
resource - the resource to read the resource state for
Returns:
the resource state of the given resource
Throws:
CmsDbSqlException - if something goes wrong

internalReadStructureState

protected CmsResourceState internalReadStructureState(CmsDbContext dbc,
                                                      CmsUUID projectId,
                                                      CmsResource resource)
                                               throws CmsDbSqlException
Returns the structure state of the given resource.

Parameters:
dbc - the database context
projectId - the id of the project
resource - the resource to read the structure state for
Returns:
the structure state of the given resource
Throws:
CmsDbSqlException - if something goes wrong

internalRemoveFolder

protected void internalRemoveFolder(CmsDbContext dbc,
                                    CmsProject currentProject,
                                    CmsResource resource)
                             throws CmsDataAccessException
Removes a resource physically in the database.

Parameters:
dbc - the current database context
currentProject - the current project
resource - the folder to remove
Throws:
CmsDataAccessException - if something goes wrong

internalUpdateVersions

protected void internalUpdateVersions(CmsDbContext dbc,
                                      CmsResource resource)
                               throws CmsDataAccessException
Updates the offline version numbers.

Parameters:
dbc - the current database context
resource - the resource to update the version number for
Throws:
CmsDataAccessException - if something goes wrong

internalValidateResourceLength

protected void internalValidateResourceLength(CmsResource resource)
                                       throws CmsDataAccessException
Validates that the length setting of a resource is always correct.

Files need to have a resource length of >= 0, while folders require a resource length of -1.

Parameters:
resource - the resource to check the length for
Throws:
CmsDataAccessException - if the resource length is not correct

moveRelations

protected void moveRelations(CmsDbContext dbc,
                             CmsUUID projectId,
                             CmsUUID structureId,
                             java.lang.String rootPath)
                      throws CmsDataAccessException
Moves all relations of a resource to the new path.

Parameters:
dbc - the current database context
projectId - the id of the project to apply the changes
structureId - the structure id of the resource to apply the changes to
rootPath - the new root path
Throws:
CmsDataAccessException - if something goes wrong

prepareExpiredTimeRangeCondition

protected void prepareExpiredTimeRangeCondition(CmsUUID projectId,
                                                long startTime,
                                                long endTime,
                                                java.lang.StringBuffer conditions,
                                                java.util.List params)
Appends the appropriate selection criteria related with the expiration date.

Parameters:
projectId - the id of the project of the resources
startTime - the start time
endTime - the end time
conditions - buffer to append the selection criteria
params - list to append the selection parameters

preparePathCondition

protected void preparePathCondition(CmsUUID projectId,
                                    java.lang.String parent,
                                    int mode,
                                    java.lang.StringBuffer conditions,
                                    java.util.List params)
Appends the appropriate selection criteria related with the parentPath.

Parameters:
projectId - the id of the project of the resources
parent - the parent path or UUID (if mode is C_READMODE_EXCLUDE_TREE)
mode - the selection mode
conditions - buffer to append the selection criteria
params - list to append the selection parameters

prepareProjectCondition

protected void prepareProjectCondition(CmsUUID projectId,
                                       int mode,
                                       java.lang.StringBuffer conditions,
                                       java.util.List params)
Appends the appropriate selection criteria related with the projectId.

Parameters:
projectId - the id of the project of the resources
mode - the selection mode
conditions - buffer to append the selection criteria
params - list to append the selection parameters

prepareRelationConditions

protected java.lang.String prepareRelationConditions(CmsUUID projectId,
                                                     CmsRelationFilter filter,
                                                     CmsResource resource,
                                                     java.util.List params,
                                                     boolean checkSource)
Build the whole WHERE sql statement part for the given relation filter.

Parameters:
projectId - the current project id
filter - the filter
resource - the resource (may be null, if you want to delete all relations for the resource in the filter)
params - the parameter values (return parameter)
checkSource - if the query is for the source relations
Returns:
the WHERE sql statement part string

prepareReleasedTimeRangeCondition

protected void prepareReleasedTimeRangeCondition(CmsUUID projectId,
                                                 long startTime,
                                                 long endTime,
                                                 java.lang.StringBuffer conditions,
                                                 java.util.List params)
Appends the appropriate selection criteria related with the released date.

Parameters:
projectId - the id of the project
startTime - the start time
endTime - the stop time
conditions - buffer to append the selection criteria
params - list to append the selection parameters

prepareResourceCondition

protected void prepareResourceCondition(CmsUUID projectId,
                                        int mode,
                                        java.lang.StringBuffer conditions)
Appends the appropriate selection criteria related with the read mode.

Parameters:
projectId - the id of the project of the resources
mode - the selection mode
conditions - buffer to append the selection criteria

prepareStateCondition

protected void prepareStateCondition(CmsUUID projectId,
                                     CmsResourceState state,
                                     int mode,
                                     java.lang.StringBuffer conditions,
                                     java.util.List params)
Appends the appropriate selection criteria related with the resource state.

Parameters:
projectId - the id of the project of the resources
state - the resource state
mode - the selection mode
conditions - buffer to append the selection criteria
params - list to append the selection parameters

prepareTimeRangeCondition

protected void prepareTimeRangeCondition(CmsUUID projectId,
                                         long startTime,
                                         long endTime,
                                         java.lang.StringBuffer conditions,
                                         java.util.List params)
Appends the appropriate selection criteria related with the date of the last modification.

Parameters:
projectId - the id of the project of the resources
startTime - start of the time range
endTime - end of the time range
conditions - buffer to append the selection criteria
params - list to append the selection parameters

prepareTypeCondition

protected void prepareTypeCondition(CmsUUID projectId,
                                    int type,
                                    int mode,
                                    java.lang.StringBuffer conditions,
                                    java.util.List params)
Appends the appropriate selection criteria related with the resource type.

Parameters:
projectId - the id of the project of the resources
type - the resource type
mode - the selection mode
conditions - buffer to append the selection criteria
params - list to append the selection parameters

repairBrokenRelations

protected void repairBrokenRelations(CmsDbContext dbc,
                                     CmsUUID projectId,
                                     CmsUUID structureId,
                                     java.lang.String rootPath)
                              throws CmsDataAccessException
Repairs broken links.

When a resource is created any relation pointing to it is updated to use the right id.

Parameters:
dbc - the current database context
projectId - the project id
structureId - the structure id of the resource that may help to repair broken links
rootPath - the path of the resource that may help to repair broken links
Throws:
CmsDataAccessException - if something goes wrong

updateBrokenRelations

protected void updateBrokenRelations(CmsDbContext dbc,
                                     CmsUUID projectId,
                                     java.lang.String rootPath)
                              throws CmsDataAccessException
Updates broken links.

When a resource is deleted, then the relations pointing to the deleted resource are set to the null uuid.

Parameters:
dbc - the current database context
projectId - the project id
rootPath - the root path of the resource that has been deleted
Throws:
CmsDataAccessException - if something goes wrong