📄 cmslock.java
字号:
case TYPE_LOCKCHANGE:
return key(Messages.GUI_LOCK_CHANGE_CONFIRMATION_0);
case TYPE_UNLOCK:
default:
if (isMultiOperation()) {
return key(Messages.GUI_LOCK_MULTI_UNLOCK_CONFIRMATION_0);
} else {
return key(Messages.GUI_LOCK_UNLOCK_CONFIRMATION_0);
}
}
}
/**
* @see org.opencms.workplace.I_CmsDialogHandler#getDialogHandler()
*/
public String getDialogHandler() {
return CmsDialogSelector.DIALOG_LOCK;
}
/**
* @see org.opencms.workplace.I_CmsDialogHandler#getDialogUri(java.lang.String, CmsJspActionElement)
*/
public String getDialogUri(String resource, CmsJspActionElement jsp) {
switch (getDialogAction(jsp.getCmsObject())) {
case TYPE_LOCK:
return URI_LOCK_DIALOG;
case TYPE_LOCKCHANGE:
return URI_LOCKCHANGE_DIALOG;
case TYPE_UNLOCK:
default:
return URI_UNLOCK_DIALOG;
}
}
/**
* Returns true if the resources to lock have locked subresources.<p>
*
* @return true if the resources to lock have locked subresources
*/
public boolean hasLockedSubResources() {
return m_hasLockedSubResources;
}
/**
* Sets if the resources to lock have locked subresources.<p>
*
* @param hasLockedSubResources if the resources to lock have locked subresources
*/
public void setHasLockedSubResources(boolean hasLockedSubResources) {
m_hasLockedSubResources = hasLockedSubResources;
}
/**
* Determines whether to show the lock dialog depending on the users settings and the dilaog type.<p>
*
* In case of locking a folder, a confirmation dialog is needed if any sub resources are already locked.<p>
*
* @return true if dialogs should be shown, otherwise false
*/
public boolean showConfirmation() {
boolean showConfirmation = getSettings().getUserSettings().getDialogShowLock();
if (DIALOG_TYPE_LOCK.equals(getParamDialogtype())) {
// in case of locking resources, check if there are locked sub resources in the selected folder(s)
Iterator i = getResourceList().iterator();
while (i.hasNext()) {
String resName = (String)i.next();
try {
CmsResource res = getCms().readResource(resName);
if (res.isFolder() && getCms().countLockedResources(resName) > 0) {
// found folder with locked subresources, set flag to show confirmation dialog
setHasLockedSubResources(true);
return true;
}
} catch (CmsException e) {
// error reading a resource, should usually never happen
}
}
}
return showConfirmation;
}
/**
* @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 action for the JSP switch
if (DIALOG_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_CONFIRMED);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else if (DIALOG_WAIT.equals(getParamAction())) {
setAction(ACTION_WAIT);
} else {
switch (getDialogAction(getCms())) {
case TYPE_LOCK:
setDialogTitle(Messages.GUI_LOCK_RESOURCE_1, Messages.GUI_LOCK_MULTI_LOCK_2);
setParamDialogtype(DIALOG_TYPE_LOCK);
// check the required permissions to lock/unlock a single resource
if (!isMultiOperation() && !checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) {
// no write permissions for the resource, set cancel action to close dialog
setAction(ACTION_CANCEL);
return;
}
break;
case TYPE_LOCKCHANGE:
setDialogTitle(Messages.GUI_LOCK_STEAL_1, Messages.GUI_LOCK_MULTI_STEAL_2);
setParamDialogtype(DIALOG_TYPE_UNLOCK);
break;
case TYPE_UNLOCK:
default:
setDialogTitle(Messages.GUI_LOCK_UNLOCK_1, Messages.GUI_LOCK_MULTI_UNLOCK_2);
setParamDialogtype(DIALOG_TYPE_UNLOCK);
}
// set action depending on user settings
if (showConfirmation()) {
// show confirmation dialog
setAction(ACTION_DEFAULT);
} else {
// lock/unlock resource without confirmation
setAction(ACTION_SUBMIT_NOCONFIRMATION);
}
}
}
/**
* Performs the lock/unlock/steal lock operation.<p>
*
* @return true, if the operation was performed, otherwise false
* @throws CmsException if operation is not successful
*/
protected boolean performDialogOperation() throws CmsException {
//on multi resource operation display "please wait" screen
if (isMultiOperation() && !DIALOG_WAIT.equals(getParamAction())) {
return false;
}
// determine action to perform (lock, unlock, change lock)
int dialogAction = getDialogAction(getCms());
// now perform the operation on the resource(s)
Iterator i = getResourceList().iterator();
while (i.hasNext()) {
String resName = (String)i.next();
try {
performSingleResourceOperation(resName, dialogAction);
} catch (CmsException e) {
// collect exceptions to create a detailed output
addMultiOperationException(e);
}
}
// generate the error message for exception
String message;
if (dialogAction == TYPE_LOCK) {
message = Messages.ERR_LOCK_MULTI_0;
} else {
message = Messages.ERR_UNLOCK_MULTI_0;
}
checkMultiOperationException(Messages.get(), message);
return true;
}
/**
* Performs the lock state operation on a single resource.<p>
*
* @param resourceName the resource name to perform the operation on
* @param dialogAction the lock action: lock, unlock or change lock
* @throws CmsException if the operation fails
*/
protected void performSingleResourceOperation(String resourceName, int dialogAction) throws CmsException {
// store original name to use for lock action
String originalResourceName = resourceName;
CmsResource res = getCms().readResource(resourceName, CmsResourceFilter.ALL);
if (res.isFolder() && !resourceName.endsWith("/")) {
resourceName += "/";
}
// perform action depending on dialog uri
switch (dialogAction) {
case TYPE_LOCK:
getCms().lockResource(originalResourceName);
break;
case TYPE_LOCKCHANGE:
getCms().changeLock(resourceName);
break;
case TYPE_UNLOCK:
default:
getCms().unlockResource(resourceName);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -