📄 cmspropertychange.java
字号:
} else {
return CmsProperty.DELETE_VALUE;
}
}
/**
* Returns the value of the oldvalue parametere.<p>
*
* @return the value of the oldvalue parameter
*/
public String getParamOldValue() {
return m_paramOldValue;
}
/**
* Returns the value of the propertyname parameter.<p>
*
* @return the value of the propertyname parameter
*/
public String getParamPropertyName() {
return m_paramPropertyName;
}
/**
* Returns the value of the recursive parameter.<p>
*
* @return the value of the recursive parameter
*/
public String getParamRecursive() {
return m_paramRecursive;
}
/**
* Returns the height for the result list of changed resources.<p>
*
* @return the height for the result list of changed resources
*/
public String getResultListHeight() {
if (getChangedResources() != null && getChangedResources().size() > 0) {
int height = getChangedResources().size() * 14;
if (height > 300) {
height = 300;
}
return "" + height;
} else {
return "14";
}
}
/**
* Returns if validation errors were found.<p>
*
* @return true if validation errors were found, otherwise false
*/
public boolean hasValidationErrors() {
return m_validationErrors;
}
/**
* Sets the value of the newvalue parameter.<p>
*
* @param paramNewValue the value of the newvalue parameter
*/
public void setParamNewValue(String paramNewValue) {
m_paramNewValue = paramNewValue;
}
/**
* Sets the value of the oldvalue parameter.<p>
*
* @param paramOldValue the value of the oldvalue parameter
*/
public void setParamOldValue(String paramOldValue) {
m_paramOldValue = paramOldValue;
}
/**
* Sets the value of the propertyname parameter.<p>
*
* @param paramPropertyName the value of the propertyname parameter
*/
public void setParamPropertyName(String paramPropertyName) {
m_paramPropertyName = paramPropertyName;
}
/**
* Sets the value of the recursive parameter.<p>
*
* @param paramRecursive the value of the recursive parameter
*/
public void setParamRecursive(String paramRecursive) {
m_paramRecursive = paramRecursive;
}
/**
* @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);
// set the action for the JSP switch
if (DIALOG_OK.equals(getParamAction())) {
if (validateParameters()) {
// all parameters are valid, proceed
setAction(ACTION_OK);
} else {
// validation error(s), redisplay form
setAction(ACTION_DEFAULT);
}
} else if (DIALOG_WAIT.equals(getParamAction())) {
setAction(ACTION_WAIT);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else {
setAction(ACTION_DEFAULT);
// build title for change property value dialog
setParamTitle(Messages.get().getBundle(getLocale()).key(Messages.GUI_TITLE_PROPERTYCHANGE_0));
}
}
/**
* Sets the error message.<p>
*
* @param errorMessage the error message to set
*/
protected void setErrorMessage(String errorMessage) {
m_errorMessage = errorMessage;
}
/**
* Sets the validation error flag.<p>
*
* @param validationErrors the validation error flag, true if validation errors were found
*/
protected void setValidationErrors(boolean validationErrors) {
m_validationErrors = validationErrors;
}
/**
* Returns the changed resources that were affected by the property change action.<p>
*
* @return the changed resources that were affected by the property change action
*/
private List getChangedResources() {
return m_changedResources;
}
/**
* Performs the main property change value operation on the resource property.<p>
*
* @param recursive true, if the property value has to be changed recursively, otherwise false
* @return true, if the property values are changed successfully, otherwise false
* @throws CmsException if changing is not successful
*/
private boolean performChangeOperation(boolean recursive) throws CmsException {
// on recursive property changes display "please wait" screen
if (recursive && !DIALOG_WAIT.equals(getParamAction())) {
// return false, this will trigger the "please wait" screen
return false;
}
// lock the selected resource
checkLock(getParamResource());
// change the property values
List changedResources = new ArrayList();
changedResources = getCms().changeResourcesInFolderWithProperty(
getParamResource(),
getParamPropertyName(),
getParamOldValue(),
getParamNewValue(),
recursive);
setChangedResources(changedResources);
return true;
}
/**
* Sets the changed resources that were affected by the property change action.<p>
*
* @param changedResources the changed resources that were affected by the property change action
*/
private void setChangedResources(List changedResources) {
m_changedResources = changedResources;
}
/**
* Validates the submitted form parameters.<p>
*
* If parameters are missing, a localized error message String is created.<p>
*
* @return true if all parameters are correct, otherwise false
*
*/
private boolean validateParameters() {
boolean allOk = true;
StringBuffer validationErrors = new StringBuffer(32);
CmsMessages messages = Messages.get().getBundle(getLocale());
// check resource parameter presence
if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamResource()) || !getCms().existsResource(getParamResource())) {
allOk = false;
validationErrors.append(messages.key(Messages.GUI_PROP_CHANGE_VALIDATE_VFS_RESOURCE_0)).append("<br>");
}
// check selected property name
if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamPropertyName())) {
allOk = false;
validationErrors.append(messages.key(Messages.GUI_PROP_CHANGE_VALIDATE_SELECT_PROPERTY_0)).append("<br>");
}
// check old property value to look up
if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamOldValue())) {
allOk = false;
validationErrors.append(messages.key(Messages.GUI_PROP_CHANGE_VALIDATE_OLD_PROP_VALUE_0)).append("<br>");
} else {
try {
// compile regular expression pattern
Pattern.compile(getParamOldValue());
} catch (PatternSyntaxException e) {
allOk = false;
validationErrors.append(messages.key(Messages.GUI_PROP_CHANGE_VALIDATE_OLD_PROP_PATTERN_0)).append(
"<br>");
}
}
// check new property value
if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamNewValue())) {
// if no new value was given, set it to the delete value
setParamNewValue(CmsProperty.DELETE_VALUE);
}
setErrorMessage(validationErrors.toString());
setValidationErrors(!allOk);
return allOk;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -