cmspublishproject.java
来自「找了很久才找到到源代码」· Java 代码 · 共 945 行 · 第 1/3 页
JAVA
945 行
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
}
return locked || unlocked;
}
/**
* Sets if a resource will be directly published.<p>
*
* @param value <code>"true"</code> (String) if a resource will be directly published
*/
public void setParamDirectpublish(String value) {
m_paramDirectpublish = value;
}
/**
* Sets the value for the progress key.<p>
*
* @param value the value for the progress key to set
*/
public void setParamProgresskey(String value) {
m_paramProgresskey = value;
}
/**
* Sets the value of the project id which will be published.<p>
*
* @param value the String value of the project id
*/
public void setParamProjectid(String value) {
m_paramProjectid = value;
}
/**
* Sets the value of the project name which will be published.<p>
*
* @param value the String value of the project name
*/
public void setParamProjectname(String value) {
m_paramProjectname = value;
}
/**
* Sets if siblings of the resource should be published.<p>
*
* @param value <code>"true"</code> (String) if siblings of the resource should be published
*/
public void setParamPublishsiblings(String value) {
m_paramPublishsiblings = value;
}
/**
* Sets the value of the related resources parameter.<p>
*
* @param relatedResources the value of the related resources parameter
*/
public void setParamRelatedresources(String relatedResources) {
m_paramRelatedresources = relatedResources;
}
/**
* Sets the value of the subresources parameter.<p>
*
* @param paramSubresources the value of the subresources parameter
*/
public void setParamSubresources(String paramSubresources) {
m_paramSubresources = paramSubresources;
}
/**
* @see org.opencms.workplace.CmsDialog#actionCloseDialog()
*/
public void actionCloseDialog() throws JspException {
CmsProgressThread thread = CmsProgressWidget.getProgressThread(getParamProgresskey());
if (thread != null) {
thread.interrupt();
CmsProgressWidget.removeProgressThread(thread.getKey());
}
super.actionCloseDialog();
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// fill the parameter values in the get/set methods
fillParamValues(request);
// set the dialog type
setParamDialogtype(DIALOG_TYPE);
m_progress = new CmsProgressWidget(getJsp());
m_progress.setWidth("300px");
// set the publishing type: publish project or direct publish
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamResource()) || isMultiOperation()) {
setParamDirectpublish(CmsStringUtil.TRUE);
}
// set default options
if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamAction()) || DIALOG_INITIAL.equals(getParamAction())) {
// siblings option. set to the default value defined in the opencms-workplace.xml
setParamPublishsiblings(String.valueOf(getSettings().getUserSettings().getDialogPublishSiblings()));
// sub resources option. default value is true
setParamSubresources(Boolean.TRUE.toString());
// related resources option.
String defValue = CmsStringUtil.TRUE;
if (OpenCms.getWorkplaceManager().getDefaultUserSettings().getPublishRelatedResources() == CmsDefaultUserSettings.PUBLISH_RELATED_RESOURCES_MODE_FALSE) {
defValue = CmsStringUtil.FALSE;
}
setParamRelatedresources(defValue);
}
// set the action for the JSP switch
if (DIALOG_TYPE.equals(getParamAction())) {
setAction(ACTION_PUBLISH);
} else if (DIALOG_LOCKS_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_LOCKS_CONFIRMED);
} else if (DIALOG_RESOURCES_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_RESOURCES_CONFIRMED);
// merge publish list with related resources if needed
CmsPublishList publishList = getSettings().getPublishList();
if (Boolean.valueOf(getParamRelatedresources()).booleanValue() && publishList.isDirectPublish()) {
try {
// try to find the publish list with related related resources in the progress thread
CmsProgressThread thread = CmsProgressWidget.getProgressThread(getParamProgresskey());
CmsPublishList storedList = null;
if (thread != null) {
storedList = ((CmsPublishResourcesList)thread.getList()).getPublishList();
}
if (storedList == null) {
CmsPublishList relResources = OpenCms.getPublishManager().getRelatedResourcesToPublish(
getCms(),
publishList);
publishList = OpenCms.getPublishManager().mergePublishLists(getCms(), publishList, relResources);
} else {
publishList = storedList;
}
getSettings().setPublishList(publishList);
} catch (CmsException e) {
// should never happen
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
}
// start the progress
CmsProgressWidget.removeProgressThread(getProgress().getKey());
getProgress().startProgress(getBrokenRelationsList());
// wait to see if already finished
synchronized (this) {
try {
wait(500);
} catch (InterruptedException e) {
// ignore
}
}
CmsProgressThread thread = CmsProgressWidget.getProgressThread(getProgress().getKey());
if ((!thread.isAlive()) && (thread.getList().getList().getTotalSize() == 0)) {
// skip broken links confirmation screen
setAction(ACTION_PUBLISH);
}
} else if (DIALOG_WAIT.equals(getParamAction())) {
setAction(ACTION_WAIT);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else {
setAction(ACTION_DEFAULT);
// set parameters depending on publishing type
if (isDirectPublish()) {
// check the required permissions to publish the resource directly
if (!getCms().isManagerOfProject()
&& !checkResourcePermissions(CmsPermissionSet.ACCESS_DIRECT_PUBLISH, false)) {
// no publish permissions for the single resource, set cancel action to close dialog
setAction(ACTION_CANCEL);
return;
}
// add the title for the direct publish dialog
setDialogTitle(Messages.GUI_PUBLISH_RESOURCE_1, Messages.GUI_PUBLISH_MULTI_2);
} else {
// add the title for the publish project dialog
setParamTitle(key(Messages.GUI_PUBLISH_PROJECT_0));
// determine the project id and name for publishing
computePublishProject();
// determine target to close the report
}
// if lock state if not as expected
if (isLockStateOk()) { // this may take a while :(
// skip lock confirmation screen
setAction(ACTION_LOCKS_CONFIRMED);
}
}
}
/**
* @see org.opencms.workplace.CmsMultiDialog#performDialogOperation()
*/
protected boolean performDialogOperation() throws CmsException {
CmsPublishList publishList = getSettings().getPublishList();
if (publishList == null) {
throw new CmsException(Messages.get().container(
org.opencms.db.Messages.ERR_GET_PUBLISH_LIST_PROJECT_1,
getProjectname()));
}
OpenCms.getPublishManager().publishProject(
getCms(),
new CmsHtmlReport(getLocale(), getCms().getRequestContext().getSiteRoot(), true, false),
publishList);
// wait 2 seconds, may be it finishes fast
OpenCms.getPublishManager().waitWhileRunning(1500);
return true;
}
/**
* Determine the right project id and name if no request parameter "projectid" is given.<p>
*/
private void computePublishProject() {
String projectId = getParamProjectid();
CmsUUID id;
if (CmsStringUtil.isEmptyOrWhitespaceOnly(projectId)) {
// projectid not found in request parameter,
id = getCms().getRequestContext().currentProject().getUuid();
setParamProjectname(getCms().getRequestContext().currentProject().getName());
setParamProjectid("" + id);
} else {
id = new CmsUUID(projectId);
try {
setParamProjectname(getCms().readProject(id).getName());
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.LOG_SET_PROJECT_NAME_FAILED_0), e);
}
}
}
/**
* Returns the filter to identify blocking locks.<p>
*
* @return the filter to identify blocking locks
*/
private CmsLockFilter getBlockingFilter() {
CmsLockFilter blockingFilter = CmsLockFilter.FILTER_ALL;
blockingFilter = blockingFilter.filterNotLockableByUser(getCms().getRequestContext().currentUser());
if (!isDirectPublish()) {
blockingFilter = blockingFilter.filterProject(new CmsUUID(getParamProjectid()));
}
return blockingFilter;
}
/**
* Returns the parent folder for the publish process.<p>
*
* @return the parent folder for the publish process
*/
private String getParentFolder() {
String relativeTo;
if (isDirectPublish()) {
relativeTo = CmsResource.getParentFolder((String)getResourceList().get(0));
} else {
relativeTo = getCms().getRequestContext().getSiteRoot() + "/";
}
return relativeTo;
}
/**
* Returns the project name.<p>
*
* @return the project name
*/
private String getProjectname() {
CmsUUID id = new CmsUUID(getParamProjectid());
try {
return getCms().readProject(id).getName();
} catch (CmsException e) {
LOG.error(Messages.get().getBundle().key(Messages.LOG_SET_PROJECT_NAME_FAILED_0), e);
}
return "-error-";
}
/**
* Returns <code>false</code> if this is a publish project operation.<p>
*
* @return <code>true</code> if this is a direct publish operation
*/
private boolean isDirectPublish() {
if (getParamDirectpublish() != null) {
return Boolean.valueOf(getParamDirectpublish()).booleanValue();
}
return getDialogUri().endsWith("publishresource.jsp");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?