|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.opencms.defaults.master.genericsql.CmsDbAccess
This class provides methods to access the database in a generic way.
| Field Summary | |
static String |
C_COS_PREFIX
|
protected String |
m_backupPoolName
The pool to access the backup ressources |
protected String |
m_onlinePoolName
The pool to access the online ressources |
protected String |
m_poolName
The pool to access offline ressources |
protected Properties |
m_queries
The query properties for this accessmodule |
protected String |
m_rootChannel
The root channel of the module |
| Constructor Summary | |
CmsDbAccess()
Public empty constructor, call "init()" on this class afterwards. |
|
CmsDbAccess(String poolName,
String onlinePoolName,
String backupPoolName)
Constructs a new DbAccessObject. |
|
| Method Summary | |
void |
changePermissions(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
Changes the perrmissions of the Master |
protected boolean |
checkAccess(CmsMasterContent content,
boolean viewonly)
Checks if read (and visible) permissions are granted. |
protected int |
computeProjectId(CmsObject cms,
CmsMasterDataSet dataset)
Computes the correct project id based on the channels. |
int |
copy(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
Vector mediaToAdd,
Vector channelToAdd)
Inserts a new row in the database with the copied dataset. |
protected Vector |
createVectorOfCd(ResultSet res,
Class contentDefinitionClass,
CmsObject cms)
Returns a vector of contentdefinitions based on the sql resultset. |
protected Vector |
createVectorOfCd(ResultSet res,
Class contentDefinitionClass,
CmsObject cms,
boolean viewonly)
Returns a vector of contentdefinitions based on the sql resultset. |
protected Vector |
createVectorOfCd(Vector datasets,
Class contentDefinitionClass,
CmsObject cms)
Returns a vector of contentdefinitions based on the sql resultset. |
void |
delete(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
|
protected void |
deleteAllChannels(int masterId)
Deletes all channel lines for one master. |
protected void |
deleteAllMedia(int masterId)
Deletes all media lines for one master. |
Connection |
getConnection(CmsObject cms)
Returns the correct connection. |
Vector |
getHistory(CmsObject cms,
Class contentDefinitionClass,
int masterId,
int subId)
Returns a vector with all version of a master in the backup |
String |
getRootChannel()
Get the root channel |
CmsMasterContent |
getVersionFromHistory(CmsObject cms,
Class contentDefinitionClass,
int masterId,
int subId,
int versionId)
Returns the version of a master in the backup |
CmsMasterDataSet |
getVersionFromHistory(CmsObject cms,
int masterId,
int subId,
int versionId)
Returns the version of a master in the backup |
void |
init(String offline,
String online,
String backup)
Initializes the DBAccessObject. |
void |
insert(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
Inserts a new row in the database with the dataset. |
protected boolean |
isOnlineProject(CmsObject cms)
Returns true, if this is the onlineproject |
protected void |
publishBackupData(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
int versionId,
long publishDate)
|
protected void |
publishCopyData(CmsMasterDataSet dataset,
int subId)
|
protected void |
publishDeleteData(int masterId,
int subId,
String table)
|
protected void |
publishOneLine(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
String contentDefinitionName,
boolean enableHistory,
int versionId,
long publishingDate,
Vector changedRessources,
Vector changedModuleData)
|
void |
publishProject(CmsObject cms,
boolean enableHistory,
int projectId,
int versionId,
long publishingDate,
int subId,
String contentDefinitionName,
Vector changedRessources,
Vector changedModuleData)
Publishes all ressources for this project Publishes all modified content definitions for this project. |
void |
publishResource(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
String contentDefinitionName,
boolean enableHistory,
int versionId,
long publishingDate,
Vector changedResources,
Vector changedModuleData)
Publishes a single content definition |
void |
read(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
int masterId)
|
Vector |
readAllByChannel(CmsObject cms,
int channelId,
int subId)
Reads all content definitions of a given channel |
Vector |
readChannels(CmsObject cms,
CmsMasterContent content)
Reads all channels from the database. |
protected void |
readLockstate(CmsMasterDataSet dataset,
int subId)
Read the lockstate from the database. |
Vector |
readMedia(CmsObject cms,
CmsMasterContent content)
Reads all media from the database. |
void |
restore(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
int versionId)
Restores a version of the master and media from backup |
void |
setRootChannel(String newRootChannel)
Set the root channel |
protected void |
sqlClose(Connection con,
Statement stmnt,
ResultSet res)
Closes all sql ressources. |
protected int |
sqlFillValues(PreparedStatement stmnt,
CmsMasterMedia media)
Fills a prepared statement with media values. |
protected int |
sqlFillValues(PreparedStatement stmnt,
int subId,
CmsMasterDataSet dataset)
Inserts all values to the statement for insert and update. |
protected int |
sqlFillValues(ResultSet res,
CmsObject cms,
CmsMasterDataSet dataset)
Inserts all values to the statement for insert and update. |
protected PreparedStatement |
sqlPrepare(CmsObject cms,
Connection con,
String queryKey)
Creates a new connection and prepares a stement. |
protected PreparedStatement |
sqlPrepare(CmsObject cms,
Connection con,
String queryKey,
HashMap optionalSqlTokens)
Replaces in a SQL statement $XXX tokens by strings and returns a prepared statement. |
protected PreparedStatement |
sqlPrepare(Connection con,
String queryKey)
Creates a new connection and prepares a stement. |
protected int |
sqlSetDateArray(PreparedStatement stmnt,
long[] array,
int columnscounter)
Sets an array of ints into the stmnt. |
protected int |
sqlSetDateArray(ResultSet res,
long[] array,
int columnscounter)
Sets an array of ints from the resultset. |
protected int |
sqlSetIntArray(PreparedStatement stmnt,
int[] array,
int columnscounter)
Sets an array of ints into the stmnt. |
protected int |
sqlSetIntArray(ResultSet res,
int[] array,
int columnscounter)
Sets an array of ints from the resultset. |
protected int |
sqlSetTextArray(PreparedStatement stmnt,
String[] array,
int columnscounter)
Sets an array of strings into the stmnt. |
protected int |
sqlSetTextArray(ResultSet res,
String[] array,
int columnscounter)
Sets an array of strings from the resultset. |
String |
toString()
Returns a string representation of this instance. |
void |
undelete(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
|
protected void |
updateChannels(CmsObject cms,
int masterId,
Vector channelToAdd,
Vector channelToDelete)
Updates the channels of a content definition. |
protected void |
updateMedia(int masterId,
Vector mediaToAdd,
Vector mediaToUpdate,
Vector mediaToDelete)
Updates the media object of a content definition. |
void |
write(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
|
void |
writeLockstate(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
Updates the lockstate in the database. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String C_COS_PREFIX
protected String m_poolName
protected String m_onlinePoolName
protected String m_backupPoolName
protected Properties m_queries
protected String m_rootChannel
| Constructor Detail |
public CmsDbAccess()
public CmsDbAccess(String poolName,
String onlinePoolName,
String backupPoolName)
poolName - the pool to access offline ressources.onlinePoolName - the pool to access the online ressources.backupPoolName - the pool to access the backup ressources.| Method Detail |
public void init(String offline,
String online,
String backup)
public void setRootChannel(String newRootChannel)
newRootChannel - the new value for the rootChannelpublic String getRootChannel()
public void insert(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
public int copy(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
Vector mediaToAdd,
Vector channelToAdd)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.mediaToAdd - a Vector of media to add.channelToAdd - a Vector of channels to add.
CmsException
public void writeLockstate(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
public void write(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
public void read(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
int masterId)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
protected void readLockstate(CmsMasterDataSet dataset,
int subId)
throws CmsException
dataset - the dataset to read the lockstate into.subId - the subId of this cd
CmsException
public Vector readMedia(CmsObject cms,
CmsMasterContent content)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.
CmsException
public Vector readChannels(CmsObject cms,
CmsMasterContent content)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.
CmsException
public Vector readAllByChannel(CmsObject cms,
int channelId,
int subId)
throws CmsException
cms - the CmsObject to get access to cms-ressources.channelId - the id of the channel.
CmsException
public void delete(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
public void undelete(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsException
public void changePermissions(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset)
throws CmsException
cms - the CmsObject to get access to cms-ressources.content - the CmsMasterContent to write to the database.dataset - the set of data for this contentdefinition.
CmsExceptionpublic String toString()
toString in class Object
protected PreparedStatement sqlPrepare(Connection con,
String queryKey)
throws SQLException
con - the Connection to use.queryKey - the key for the query to use. The query will be get
by m_queries.getParameter(key)
SQLException
protected PreparedStatement sqlPrepare(CmsObject cms,
Connection con,
String queryKey)
throws SQLException
cms - the CmsObject to get access to cms-ressources.con - the Connection to use.queryKey - the key for the query to use. The query will be get
by m_queries.getParameter(key)
SQLException
protected PreparedStatement sqlPrepare(CmsObject cms,
Connection con,
String queryKey,
HashMap optionalSqlTokens)
throws SQLException
cms - the current user's CmsObject instancecon - the JDBC connectionqueryKey - the name of the SQL statement (in query.properties)optionalSqlTokens - a HashMap with optional SQL tokens to be replaced in the SQL statement
SQLException
protected void sqlClose(Connection con,
Statement stmnt,
ResultSet res)
con - the Connection to close.stmnt - the SqlStatement to close.
protected int sqlFillValues(PreparedStatement stmnt,
int subId,
CmsMasterDataSet dataset)
throws SQLException
stmnt - the Statement to fill the values to.subId - the subid of this module.dataset - the set of data for this contentdefinition.
SQLException
protected int sqlFillValues(ResultSet res,
CmsObject cms,
CmsMasterDataSet dataset)
throws SQLException
res - the Resultset read the values from.cms - the CmsObject to get access to cms-ressources.dataset - the set of data for this contentdefinition.
SQLException
protected int computeProjectId(CmsObject cms,
CmsMasterDataSet dataset)
throws SQLException
SQLException
protected int sqlSetTextArray(PreparedStatement stmnt,
String[] array,
int columnscounter)
throws SQLException
stmnt - the PreparedStatement to set the values into.array - the array of strings to set.
SQLException
protected int sqlSetTextArray(ResultSet res,
String[] array,
int columnscounter)
throws SQLException
res - the ResultSet to get the values from.array - the array of strings to set.
SQLException
protected int sqlSetIntArray(PreparedStatement stmnt,
int[] array,
int columnscounter)
throws SQLException
stmnt - the PreparedStatement to set the values into.array - the array of ints to set.
SQLException
protected int sqlSetIntArray(ResultSet res,
int[] array,
int columnscounter)
throws SQLException
res - the ResultSet to get the values from.array - the array of ints to set.
SQLException
protected int sqlSetDateArray(PreparedStatement stmnt,
long[] array,
int columnscounter)
throws SQLException
stmnt - the PreparedStatement to set the values into.array - the array of longs to set.
SQLException
protected int sqlSetDateArray(ResultSet res,
long[] array,
int columnscounter)
throws SQLException
res - the ResultSet to get the values from.array - the array of longs to set.
SQLException
protected Vector createVectorOfCd(ResultSet res,
Class contentDefinitionClass,
CmsObject cms)
throws SQLException
res - - the ResultSet to get data-lines from.contentDefinitionClass - - the class of the cd to create new instances.cms - - the CmsObject to get access to cms-ressources.
SqlException - if nothing could be read from the resultset.
SQLException
protected Vector createVectorOfCd(ResultSet res,
Class contentDefinitionClass,
CmsObject cms,
boolean viewonly)
throws SQLException
res - - the ResultSet to get data-lines from.contentDefinitionClass - - the class of the cd to create new instances.cms - - the CmsObject to get access to cms-ressources.viewonly - - decides, if only the ones that are visible should be returned
SqlException - if nothing could be read from the resultset.
SQLException
protected Vector createVectorOfCd(Vector datasets,
Class contentDefinitionClass,
CmsObject cms)
throws SQLException
datasets - - the vector with the datasets.contentDefinitionClass - - the class of the cd to create new instances.cms - - the CmsObject to get access to cms-ressources.
SqlException - if nothing could be read from the resultset.
SQLException
protected boolean checkAccess(CmsMasterContent content,
boolean viewonly)
content - - the cd to check.viewonly - - if set to true the v-Flag will be checked, tooprotected boolean isOnlineProject(CmsObject cms)
cms - - the CmsObject to get access to cms-ressources.
protected void deleteAllMedia(int masterId)
throws SQLException
masterId - - the masterId to delete the media for
SQLException - if an sql-error occur
protected void deleteAllChannels(int masterId)
throws SQLException
masterId - - the masterId to delete the media for
SQLException - if an sql-error occur
protected void updateMedia(int masterId,
Vector mediaToAdd,
Vector mediaToUpdate,
Vector mediaToDelete)
throws SQLException,
CmsException
masterId - the content definition master idmediaToAdd - vector of media objects to addmediaToUpdate - vector of media objects to updatemediaToDelete - vector of media objects to delete
SQLException
CmsException
protected void updateChannels(CmsObject cms,
int masterId,
Vector channelToAdd,
Vector channelToDelete)
throws SQLException
cms - the current context objectmasterId - the content definition master idchannelToAdd - vector of channels to addchannelToDelete - vector of channels to delete
SQLException
protected int sqlFillValues(PreparedStatement stmnt,
CmsMasterMedia media)
throws SQLException
stmnt - the statement to fillmedia - the data to fill the statement with
SQLException - if data could not be set in statement
public Vector getHistory(CmsObject cms,
Class contentDefinitionClass,
int masterId,
int subId)
throws CmsException
cms - The CmsObjectmasterId - The id of the mastersubId - The sub_id
CmsException
public CmsMasterContent getVersionFromHistory(CmsObject cms,
Class contentDefinitionClass,
int masterId,
int subId,
int versionId)
throws CmsException
cms - The CmsObjectcontentDefinitionClass - The class of the content definitionmasterId - The id of the mastersubId - The sub_idversionId - The version id
CmsException
public CmsMasterDataSet getVersionFromHistory(CmsObject cms,
int masterId,
int subId,
int versionId)
throws CmsException
cms - The CmsObjectmasterId - The id of the mastersubId - The sub_idversionId - The version id
CmsException
public void restore(CmsObject cms,
CmsMasterContent content,
CmsMasterDataSet dataset,
int versionId)
throws CmsException
cms - The CmsObjectcontent - The master contentdataset - The dataset of the masterversionId - The version id of the master and media to restore
CmsException
public void publishResource(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
String contentDefinitionName,
boolean enableHistory,
int versionId,
long publishingDate,
Vector changedResources,
Vector changedModuleData)
throws CmsException
cms - The CmsObjectdataset - the dataset to publish.subId - the subId to publish cd's for.contentDefinitionName - the name of the contentdefinition.enableHistory - set to true if backup tables should be filled.versionId - the versionId to save in the backup tables.publishingDate - the date and time of this publishing process.
CmsException
public void publishProject(CmsObject cms,
boolean enableHistory,
int projectId,
int versionId,
long publishingDate,
int subId,
String contentDefinitionName,
Vector changedRessources,
Vector changedModuleData)
throws CmsException
cms - The CmsObjectenableHistory - set to true if backup tables should be filled.projectId - the Project that should be published.versionId - the versionId to save in the backup tables.publishingDate - the date and time of this publishing process.subId - the subId to publish cd's for.contentDefinitionName - the name of the contentdefinition.changedRessources - a Vector of Ressources that were changed by this
publishing process.changedModuleData - a Vector of Ressource that were changed by this
publishing process. New published data will be add to this Vector to
return it.
CmsException
protected void publishOneLine(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
String contentDefinitionName,
boolean enableHistory,
int versionId,
long publishingDate,
Vector changedRessources,
Vector changedModuleData)
throws CmsException
cms - The CmsObjectdataset - the dataset to publish.subId - the subId to publish cd's for.contentDefinitionName - the name of the contentdefinition.enableHistory - set to true if backup tables should be filled.versionId - the versionId to save in the backup tables.publishingDate - the date and time of this publishing process.changedRessources - a Vector of Ressources that were changed by this
publishing process.changedModuleData - a Vector of Ressource that were changed by this
publishing process. New published data will be add to this Vector to
return it.
CmsException
protected void publishDeleteData(int masterId,
int subId,
String table)
throws CmsException
CmsException
protected void publishCopyData(CmsMasterDataSet dataset,
int subId)
throws CmsException
CmsException
protected void publishBackupData(CmsObject cms,
CmsMasterDataSet dataset,
int subId,
int versionId,
long publishDate)
throws CmsException
CmsException
public Connection getConnection(CmsObject cms)
throws SQLException
cms - the CmsObject to get access to cms-ressources.
SQLException - if the connection can not be returned.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||