cmsundochanges.java
来自「找了很久才找到到源代码」· Java 代码 · 共 478 行 · 第 1/2 页
JAVA
478 行
}
result.append(dialogSpacer());
result.append(key(Messages.GUI_UNDO_CONFIRMATION_0));
if (isMoved || isOperationOnFolder()) {
// show undo move option if both options are available
result.append(dialogSpacer());
result.append("<input type=\"checkbox\" name=\"");
result.append(PARAM_MOVE);
result.append("\" value=\"true\" checked='checked'> ");
if (isMultiOperation()) {
result.append(key(Messages.GUI_UNDO_CHANGES_MOVE_MULTI_SUBRESOURCES_0));
} else {
result.append(key(Messages.GUI_UNDO_CHANGES_MOVE_SUBRESOURCES_0));
}
} else {
if (isMoved) {
result.append(dialogSpacer());
result.append("<input type=\"hidden\" name=\"");
result.append(PARAM_MOVE);
result.append("\" value=\"true\"> ");
}
}
if (isOperationOnFolder()) {
// show recursive option if folder(s) is/are selected
result.append(dialogSpacer());
result.append(dialogBlockStart(key(Messages.GUI_UNDO_CHANGES_RECURSIVE_TITLE_0)));
result.append("<input type=\"checkbox\" name=\"");
result.append(PARAM_RECURSIVE);
result.append("\" value=\"true\"> ");
if (isMultiOperation()) {
result.append(key(Messages.GUI_UNDO_CHANGES_RECURSIVE_MULTI_SUBRESOURCES_0));
} else {
result.append(key(Messages.GUI_UNDO_CHANGES_RECURSIVE_SUBRESOURCES_0));
}
result.append(dialogBlockEnd());
}
return result.toString();
}
/**
* Returns the undo move operation flag parameter value.<p>
*
* @return the undo move operation flag parameter value
*/
public String getParamMove() {
return m_paramMove;
}
/**
* Returns the value of the recursive parameter,
* or <code>null</code> if this parameter was not provided.<p>
*
* The recursive parameter on folders decides if all subresources
* of the folder should be unchanged, too.<p>
*
* @return the value of the recursive parameter
*/
public String getParamRecursive() {
return m_paramRecursive;
}
/**
* Sets the undo move operation flag parameter value.<p>
*
* @param paramMove the undo move operation flag to set
*/
public void setParamMove(String paramMove) {
m_paramMove = paramMove;
}
/**
* Sets the value of the recursive parameter.<p>
*
* @param value the value to set
*/
public void setParamRecursive(String value) {
m_paramRecursive = value;
}
/**
* Returns the current CmsResource.<p>
*
* @return the CmsResource
*/
protected CmsResource getCurrentResource() {
return m_currentResource;
}
/**
* Returns the file name without path information of the current resource.<p>
*
* @return the name of the current resource
*/
protected String getFileName() {
return CmsResource.getName(getParamResource());
}
/**
* Returns the last modified date of the current resource as localized String.<p>
*
* @return the date of last modification
*/
protected String getLastModifiedDate() {
long dateLong = getCurrentResource().getDateLastModified();
return getMessages().getDateTime(dateLong);
}
/**
* Returns the user who made the last changes to the current resource.<p>
*
* @return the user who changed the resource
*/
protected String getLastModifiedUser() {
CmsUUID userId = getCurrentResource().getUserLastModified();
try {
return getCms().readUser(userId).getName();
} catch (CmsException e) {
return "";
}
}
/**
* @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);
// check the required permissions to undo changes of the resource
if (!checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) {
// no write permissions for the resource, set cancel action to close dialog
setParamAction(DIALOG_CANCEL);
}
// set the dialog type
setParamDialogtype(DIALOG_TYPE);
// set the action for the JSP switch
if (DIALOG_TYPE.equals(getParamAction())) {
setAction(ACTION_UNDOCHANGES);
} else if (DIALOG_WAIT.equals(getParamAction())) {
setAction(ACTION_WAIT);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else if (DIALOG_LOCKS_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_LOCKS_CONFIRMED);
} else {
setAction(ACTION_DEFAULT);
// build title for undo changes dialog
setDialogTitle(Messages.GUI_UNDO_CHANGES_1, Messages.GUI_UNDO_CHANGES_MULTI_2);
}
if (!isMultiOperation()) {
// collect resource to display information on single operation dialog
try {
setCurrentResource(getCms().readResource(getParamResource(), CmsResourceFilter.ALL));
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
}
}
/**
* Performs the undo changes operation on a resource.<p>
*
* @return true, if the changes on a resource were undone, otherwise false
* @throws CmsException if undo changes is not successful
*/
protected boolean performDialogOperation() throws CmsException {
// check if the current resource is a folder for single operation
boolean isFolder = isOperationOnFolder();
// on folder undo changes or multi operation display "please wait" screen, not for simple file undo changes
if ((isMultiOperation() || isFolder) && !DIALOG_WAIT.equals(getParamAction())) {
// return false, this will trigger the "please wait" screen
return false;
}
// get the flag if the undo changes is recursive from request parameter
boolean undoRecursive = Boolean.valueOf(getParamRecursive()).booleanValue();
boolean undoMove = Boolean.valueOf(getParamMove()).booleanValue();
CmsResourceUndoMode mode = CmsResource.UNDO_CONTENT;
if (undoRecursive) {
mode = CmsResource.UNDO_CONTENT_RECURSIVE;
}
if (undoMove) {
mode = mode.includeMove();
}
Iterator i = getResourceList().iterator();
// iterate the resources to delete
while (i.hasNext()) {
String resName = (String)i.next();
try {
// lock resource if autolock is enabled
checkLock(resName);
// undo changes on the resource
getCms().undoChanges(resName, mode);
} catch (CmsException e) {
if (isMultiOperation()) {
// collect exceptions to create a detailed output
addMultiOperationException(e);
} else {
// for single operation, throw the exception immediately
throw e;
}
}
}
// check if exceptions occured
checkMultiOperationException(Messages.get(), Messages.ERR_UNDO_CHANGES_MULTI_0);
return true;
}
/**
* Sets the current CmsResource.<p>
*
* @param res the CmsResource
*/
protected void setCurrentResource(CmsResource res) {
m_currentResource = res;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?