📄 cmsprojectdriver.java
字号:
m_driverManager.getVfsDriver().readResource(
dbc,
dbc.currentProject().getId(),
offlineResource.getStructureId(),
true);
} catch (CmsVfsResourceNotFoundException e) {
// remove the online file only if it is really deleted offline
m_driverManager.getVfsDriver().removeFile(dbc, onlineProject, onlineResource, true);
}
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_REMOVING_RESOURCE_1,
offlineResource.getRootPath()), e);
}
throw e;
}
try {
// delete the ACL online and offline
m_driverManager.getUserDriver().removeAccessControlEntries(
dbc,
onlineProject,
onlineResource.getResourceId());
m_driverManager.getUserDriver().removeAccessControlEntries(
dbc,
dbc.currentProject(),
offlineResource.getResourceId());
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_REMOVING_ACL_1,
offlineResource.toString()), 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()) {
LOG.debug(Messages.get().getBundle().key(
Messages.LOG_DEL_FILE_3,
offlineResource.getRootPath(),
String.valueOf(m),
String.valueOf(n)));
}
} else if (offlineResource.getState() == CmsResource.STATE_CHANGED) {
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_PUBLISH_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(),
false);
// reset the labeled link flag before writing the online file
int flags = offlineResource.getFlags();
flags &= ~CmsResource.FLAG_LABELED;
offlineResource.setFlags(flags);
// delete the properties online
m_driverManager.getVfsDriver().deletePropertyObjects(
dbc,
onlineProject.getId(),
onlineResource,
CmsProperty.DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES);
// 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 mapped to the "old" resource ID have to be
// deleted also offline. if this is the case, the online and offline structure
// ID's do match, but the resource ID's are different. structure IDs are reused
// to prevent orphan structure records in the online project.
if (!onlineResource.getResourceId().equals(offlineResource.getResourceId())) {
offlineProperties = m_driverManager.getVfsDriver().readPropertyObjects(
dbc,
dbc.currentProject(),
onlineResource);
if (offlineProperties.size() > 0) {
for (int i = 0; i < offlineProperties.size(); i++) {
property = (CmsProperty)offlineProperties.get(i);
property.setStructureValue(null);
property.setResourceValue(CmsProperty.DELETE_VALUE);
}
m_driverManager.getVfsDriver().writePropertyObjects(
dbc,
dbc.currentProject(),
onlineResource,
offlineProperties);
}
}
// remove the file online
boolean removeContent = !publishedContentIds.contains(offlineResource.getResourceId());
m_driverManager.getVfsDriver().removeFile(dbc, onlineProject, onlineResource, removeContent);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_DELETING_PROPERTIES_1,
offlineResource.toString()), e);
}
throw e;
}
try {
// publish the file content
newFile = m_driverManager.getProjectDriver().publishFileContent(
dbc,
dbc.currentProject(),
onlineProject,
offlineResource,
publishedContentIds);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_RESOURCE_1,
offlineResource.getRootPath()), e);
}
throw e;
}
try {
// write the properties online
offlineProperties = m_driverManager.getVfsDriver().readPropertyObjects(
dbc,
dbc.currentProject(),
offlineResource);
CmsProperty.setAutoCreatePropertyDefinitions(offlineProperties, true);
m_driverManager.getVfsDriver().writePropertyObjects(dbc, onlineProject, newFile, offlineProperties);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_PROPERTIES_1,
newFile.getRootPath()), e);
}
throw e;
}
try {
// write the ACL online
m_driverManager.getUserDriver().publishAccessControlEntries(
dbc,
dbc.currentProject(),
onlineProject,
newFile.getResourceId(),
onlineResource.getResourceId());
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(Messages.LOG_PUBLISHING_ACL_1, newFile.getRootPath()),
e);
}
throw e;
}
try {
// write the file to the backup and publishing history
if (backupEnabled) {
if (offlineProperties == null) {
offlineProperties = m_driverManager.getVfsDriver().readPropertyObjects(
dbc,
dbc.currentProject(),
offlineResource);
}
m_driverManager.getBackupDriver().writeBackupResource(
dbc,
newFile,
offlineProperties,
backupTagId,
publishDate,
maxVersions);
}
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,
newFile.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()) {
LOG.debug(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_FILE_3,
offlineResource.getRootPath(),
String.valueOf(m),
String.valueOf(n)));
}
} else if (offlineResource.getState() == CmsResource.STATE_NEW) {
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_PUBLISH_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 {
// reset the labeled link flag before writing the online file
int flags = offlineResource.getFlags();
flags &= ~CmsResource.FLAG_LABELED;
offlineResource.setFlags(flags);
// publish the file content
newFile = m_driverManager.getProjectDriver().publishFileContent(
dbc,
dbc.currentProject(),
onlineProject,
offlineResource,
publishedContentIds);
} catch (CmsVfsResourceAlreadyExistsException e) {
try {
// remove the existing file and ensure that it's content is written
// in any case by removing it's content ID from the set of published content IDs
m_driverManager.getVfsDriver().removeFile(dbc, onlineProject, offlineResource, true);
publishedContentIds.remove(offlineResource.getResourceId());
newFile = m_driverManager.getProjectDriver().publishFileContent(
dbc,
dbc.currentProject(),
onlineProject,
offlineResource,
publishedContentIds);
} catch (CmsDataAccessException e1) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_RESOURCE_1,
offlineResource.getRootPath()), e);
}
throw e1;
}
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_RESOURCE_1,
offlineResource.getRootPath()), e);
}
throw e;
}
try {
// write the properties online
offlineProperties = m_driverManager.getVfsDriver().readPropertyObjects(
dbc,
dbc.currentProject(),
offlineResource);
CmsProperty.setAutoCreatePropertyDefinitions(offlineProperties, true);
m_driverManager.getVfsDriver().writePropertyObjects(dbc, onlineProject, newFile, offlineProperties);
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(
Messages.LOG_PUBLISHING_PROPERTIES_1,
newFile.getRootPath()), e);
}
throw e;
}
try {
// write the ACL online
m_driverManager.getUserDriver().publishAccessControlEntries(
dbc,
dbc.currentProject(),
onlineProject,
offlineResource.getResourceId(),
newFile.getResourceId());
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(Messages.LOG_PUBLISHING_ACL_1, newFile.getRootPath()),
e);
}
throw e;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -