📄 cmsprojectdriver.java
字号:
if (successiveDrivers != null && !successiveDrivers.isEmpty()) {
if (LOG.isWarnEnabled()) {
LOG.warn(Messages.get().getBundle().key(
Messages.LOG_SUCCESSIVE_DRIVERS_UNSUPPORTED_1,
getClass().getName()));
}
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#initSqlManager(String)
*/
public org.opencms.db.generic.CmsSqlManager initSqlManager(String classname) {
return CmsSqlManager.getInstance(classname);
}
/**
* @see org.opencms.db.I_CmsProjectDriver#publishDeletedFolder(org.opencms.db.CmsDbContext, org.opencms.report.I_CmsReport, int, int, org.opencms.file.CmsProject, org.opencms.file.CmsFolder, boolean, long, org.opencms.util.CmsUUID, int, int)
*/
public void publishDeletedFolder(
CmsDbContext dbc,
I_CmsReport report,
int m,
int n,
CmsProject onlineProject,
CmsFolder currentFolder,
boolean backupEnabled,
long publishDate,
CmsUUID publishHistoryId,
int backupTagId,
int maxVersions) throws CmsDataAccessException {
CmsFolder onlineFolder = null;
List offlineProperties = null;
try {
report.print(org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_SUCCESSION_2,
String.valueOf(m),
String.valueOf(n)), I_CmsReport.FORMAT_NOTE);
report.print(Messages.get().container(Messages.RPT_DELETE_FOLDER_0), I_CmsReport.FORMAT_NOTE);
report.print(org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
dbc.removeSiteRoot(currentFolder.getRootPath())));
report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
try {
// write the folder to the backup and publishing history
if (backupEnabled) {
offlineProperties = m_driverManager.getVfsDriver().readPropertyObjects(
dbc,
dbc.currentProject(),
currentFolder);
m_driverManager.getBackupDriver().writeBackupResource(
dbc,
currentFolder,
offlineProperties,
backupTagId,
publishDate,
maxVersions);
}
m_driverManager.getProjectDriver().writePublishHistory(
dbc,
dbc.currentProject(),
publishHistoryId,
new CmsPublishedResource(currentFolder, backupTagId));
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_WRITING_PUBLISHING_HISTORY_1,
currentFolder.getRootPath()), e);
}
throw e;
}
// read the folder online
onlineFolder = m_driverManager.readFolder(dbc, currentFolder.getRootPath(), CmsResourceFilter.ALL);
try {
// delete the properties online and offline
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
onlineProject.getId(),
onlineFolder,
CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES);
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
dbc.currentProject().getId(),
currentFolder,
CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_DELETING_PROPERTIES_1,
currentFolder.getRootPath()), e);
}
throw e;
}
try {
// remove the folder online and offline
m_driverManager.getVfsDriver().removeFolder(dbc, dbc.currentProject(), currentFolder);
try {
m_driverManager.getVfsDriver().readFolder(
dbc,
dbc.currentProject().getId(),
currentFolder.getRootPath());
} catch (CmsVfsResourceNotFoundException e) {
// remove the online folder only if it is really deleted offline
m_driverManager.getVfsDriver().removeFolder(dbc, onlineProject, currentFolder);
}
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_REMOVING_RESOURCE_1,
currentFolder.getRootPath()), e);
}
throw e;
}
try {
// remove the ACL online and offline
m_driverManager.getUserDriver().removeAccessControlEntries(
dbc,
onlineProject,
onlineFolder.getResourceId());
m_driverManager.getUserDriver().removeAccessControlEntries(
dbc,
dbc.currentProject(),
currentFolder.getResourceId());
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(Messages.LOG_REMOVING_ACL_1, currentFolder.getRootPath()),
e);
}
throw e;
}
report.println(
org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_OK_0),
I_CmsReport.FORMAT_OK);
if (LOG.isDebugEnabled()) {
if (LOG.isDebugEnabled()) {
LOG.debug(Messages.get().getBundle().key(
Messages.LOG_DEL_FOLDER_3,
currentFolder.getRootPath(),
String.valueOf(m),
String.valueOf(n)));
}
}
} finally {
// notify the app. that the published folder and it's properties have been modified offline
OpenCms.fireCmsEvent(new CmsEvent(
I_CmsEventListener.EVENT_RESOURCE_AND_PROPERTIES_MODIFIED,
Collections.singletonMap("resource", currentFolder)));
}
}
/**
* @see org.opencms.db.I_CmsProjectDriver#publishFile(org.opencms.db.CmsDbContext, org.opencms.report.I_CmsReport, int, int, org.opencms.file.CmsProject, org.opencms.file.CmsResource, java.util.Set, boolean, long, org.opencms.util.CmsUUID, int, int)
*/
public void publishFile(
CmsDbContext dbc,
I_CmsReport report,
int m,
int n,
CmsProject onlineProject,
CmsResource offlineResource,
Set publishedContentIds,
boolean backupEnabled,
long publishDate,
CmsUUID publishHistoryId,
int backupTagId,
int maxVersions) throws CmsDataAccessException {
CmsFile newFile = null;
CmsResource onlineResource = null;
List offlineProperties = null;
CmsProperty property = null;
int propertyDeleteOption = -1;
/*
* Never use onlineResource.getState() here!
* Only use offlineResource.getState() to determine the state of an offline resource!
*
* In case a resource has siblings, after a sibling was published the structure
* and resource states are reset to UNCHANGED -> the state of the corresponding
* onlineResource is still NEW, DELETED or CHANGED.
* Thus, using onlineResource.getState() will inevitably result in unpublished resources!
*/
try {
if (offlineResource.getState() == CmsResource.STATE_DELETED) {
report.print(org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_SUCCESSION_2,
String.valueOf(m),
String.valueOf(n)), I_CmsReport.FORMAT_NOTE);
report.print(Messages.get().container(Messages.RPT_DELETE_FILE_0), I_CmsReport.FORMAT_NOTE);
report.print(org.opencms.report.Messages.get().container(
org.opencms.report.Messages.RPT_ARGUMENT_1,
dbc.removeSiteRoot(offlineResource.getRootPath())));
report.print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));
try {
// read the file header online
onlineResource = m_driverManager.getVfsDriver().readResource(
dbc,
onlineProject.getId(),
offlineResource.getStructureId(),
true);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_READING_RESOURCE_1,
offlineResource.getRootPath()), e);
}
throw e;
}
if (offlineResource.isLabeled() && !m_driverManager.labelResource(dbc, offlineResource, null, 2)) {
// update the resource flags to "unlabeled" of the siblings of the offline resource
int flags = offlineResource.getFlags();
flags &= ~CmsResource.FLAG_LABELED;
offlineResource.setFlags(flags);
}
try {
// write the file to the backup and publishing history
if (backupEnabled && !OpenCms.getSystemInfo().keepVersionHistory()) {
// delete all backups as well
m_driverManager.deleteBackup(dbc, offlineResource);
}
m_driverManager.getProjectDriver().writePublishHistory(
dbc,
dbc.currentProject(),
publishHistoryId,
new CmsPublishedResource(offlineResource, backupTagId));
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_WRITING_PUBLISHING_HISTORY_1,
offlineResource.getRootPath()), e);
}
throw e;
}
try {
// delete the properties online and offline
if (offlineResource.getSiblingCount() > 1) {
// there are other siblings- delete only structure property values and keep the resource property values
propertyDeleteOption = CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_VALUES;
} else {
// there are no other siblings- delete both the structure and resource property values
propertyDeleteOption = CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES;
}
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
onlineProject.getId(),
onlineResource,
propertyDeleteOption);
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
dbc.currentProject().getId(),
offlineResource,
propertyDeleteOption);
// if the offline file has a resource ID different from the online file
// (probably because a (deleted) file was replaced by a new file with the
// same name), the properties with the "old" resource ID have to be
// deleted also offline
if (!onlineResource.getResourceId().equals(offlineResource.getResourceId())) {
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
dbc.currentProject().getId(),
onlineResource,
CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES);
}
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_DELETING_PROPERTIES_1,
offlineResource.getRootPath()), e);
}
throw e;
}
try {
// remove the file online and offline
m_driverManager.getVfsDriver().removeFile(dbc, dbc.currentProject(), offlineResource, true);
try {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -