📄 cmselementrename.java
字号:
Iterator i = templates.keySet().iterator();
int counter = 2;
while (i.hasNext()) {
String key = (String)i.next();
String path = (String)templates.get(key);
if (path.equals(getParamTemplate())) {
selectedIndex = counter;
}
options.add(key);
values.add(path);
counter++;
}
}
return buildSelect(attributes, options, values, selectedIndex, false);
}
/**
* @see org.opencms.workplace.CmsWorkplace#getCms()
*/
public CmsObject getCms() {
if (m_cms == null) {
return super.getCms();
}
return m_cms;
}
/**
* Returns the errorMessage.<p>
*
* @return the errorMessage
*/
public String getErrorMessage() {
if (CmsStringUtil.isEmpty(m_errorMessage)) {
return "";
}
return m_errorMessage;
}
/**
* Returns the paramLocale.<p>
*
* @return the paramLocale
*/
public String getParamLocale() {
return m_paramLocale;
}
/**
* Returns the value of the newvalue parameter.<p>
*
* @return the value of the newvalue parameter
*/
public String getParamNewElement() {
return m_paramNewElement;
}
/**
* Returns the value of the oldvalue parametere.<p>
*
* @return the value of the oldvalue parameter
*/
public String getParamOldElement() {
return m_paramOldElement;
}
/**
* Returns the value of the recursive parameter.<p>
*
* @return the value of the recursive parameter
*/
public String getParamRecursive() {
return m_paramRecursive;
}
/**
* Returns true if the user has set remove empty elements parameter; otherwise false.<p>
*
* @return true if the user has set remove empty elements parameter; otherwise false
*/
public String getParamRemoveEmptyElements() {
return m_paramRemoveEmptyElements;
}
/**
* Returns the template.<p>
*
* @return the template
*/
public String getParamTemplate() {
return m_paramTemplate;
}
/**
* Returns true if the user has set validate new element parameter; otherwise false.<p>.<p>
*
* @return true if the user has set validate new element parameter; otherwise false
*/
public String getParamValidateNewElement() {
return m_paramValidateNewElement;
}
/**
* Sets the errorMessage.<p>
*
* @param errorMessage the errorMessage to set
*/
public void setErrorMessage(String errorMessage) {
m_errorMessage = errorMessage;
}
/**
* Sets the locale.<p>
*
* @param paramLocale the locale to set
*/
public void setParamLocale(String paramLocale) {
m_paramLocale = paramLocale;
}
/**
* Sets the value of the newvalue parameter.<p>
*
* @param paramNewValue the value of the newvalue parameter
*/
public void setParamNewElement(String paramNewValue) {
m_paramNewElement = paramNewValue;
}
/**
* Sets the value of the oldvalue parameter.<p>
*
* @param paramOldValue the value of the oldvalue parameter
*/
public void setParamOldElement(String paramOldValue) {
m_paramOldElement = paramOldValue;
}
/**
* Sets the value of the recursive parameter.<p>
*
* @param paramRecursive the value of the recursive parameter
*/
public void setParamRecursive(String paramRecursive) {
m_paramRecursive = paramRecursive;
}
/**
* Sets the remove empty elements parameter to true or false.<p>
*
* @param paramRemoveEmptyElements the remove empty elements parameter to set
*/
public void setParamRemoveEmptyElements(String paramRemoveEmptyElements) {
m_paramRemoveEmptyElements = paramRemoveEmptyElements;
}
/**
* Sets the param Template.<p>
*
* @param paramTemplate the template name to set
*/
public void setParamTemplate(String paramTemplate) {
m_paramTemplate = paramTemplate;
}
/**
* Sets the paramValidateNewElement.<p>
*
* @param paramValidateNewElement the validate new element parameter to set
*/
public void setParamValidateNewElement(String paramValidateNewElement) {
m_paramValidateNewElement = paramValidateNewElement;
}
/**
* Does validate the request parameters and returns a buffer with error messages.<p>
*
* If there were no error messages, the buffer is empty.<p>
*/
public void validateParameters() {
// localisation
CmsMessages messages = Messages.get().getBundle(getLocale());
StringBuffer validationErrors = new StringBuffer();
if (CmsStringUtil.isEmpty(getParamResource())) {
validationErrors.append(messages.key(Messages.GUI_ELEM_RENAME_VALIDATE_RESOURCE_FOLDER_0)).append("<br>");
}
if (CmsStringUtil.isEmpty(getParamTemplate())) {
validationErrors.append(messages.key(Messages.GUI_ELEM_RENAME_VALIDATE_SELECT_TEMPLATE_0)).append("<br>");
}
if (CmsStringUtil.isEmpty(getParamLocale())) {
validationErrors.append(messages.key(Messages.GUI_ELEM_RENAME_VALIDATE_SELECT_LANGUAGE_0)).append("<br>");
}
if (CmsStringUtil.isEmpty(getParamOldElement())) {
validationErrors.append(messages.key(Messages.GUI_ELEM_RENAME_VALIDATE_ENTER_OLD_ELEM_0)).append("<br>");
}
if (CmsStringUtil.isEmpty(getParamNewElement())) {
validationErrors.append(messages.key(Messages.GUI_ELEM_RENAME_VALIDATE_ENTER_NEW_ELEM_0)).append("<br>");
}
if (!isValidElement(getParamNewElement())) {
validationErrors.append(
messages.key(
Messages.GUI_ELEM_RENAME_VALIDATE_INVALID_NEW_ELEM_2,
getParamNewElement(),
getParamTemplate())).append("<br>");
}
setErrorMessage(validationErrors.toString());
}
/**
* @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
// set the action for the JSP switch
if (DIALOG_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_CONFIRMED);
} else if (DIALOG_OK.equals(getParamAction())) {
setAction(ACTION_OK);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else if (REPORT_UPDATE.equals(getParamAction())) {
setAction(ACTION_REPORT_UPDATE);
} else if (REPORT_BEGIN.equals(getParamAction())) {
setAction(ACTION_REPORT_BEGIN);
} else if (REPORT_END.equals(getParamAction())) {
setAction(ACTION_REPORT_END);
} else {
setAction(ACTION_DEFAULT);
// add the title for the dialog
setParamTitle(key("title.renameelement"));
}
}
/**
* Returns a retained list of xml pages that belongs to the specified template.<p>
*
* @param xmlPages a list of all xml pages
* @return a retained list of xml pages that belongs to the specified template
*/
private List getRetainedPagesWithTemplate(List xmlPages) {
// list of resources belongs to the selected template
List resourcesWithTemplate = new ArrayList();
TreeMap templates = null;
try {
templates = CmsNewResourceXmlPage.getTemplates(getCms(), null);
} catch (CmsException e) {
if (LOG.isErrorEnabled()) {
LOG.error(e);
}
}
// check if the users selected template is valid.
if (templates != null && templates.containsValue(getParamTemplate())) {
// iterate the xmlPages list and add all resources with the specified template to the resourcesWithTemplate list
Iterator i = xmlPages.iterator();
while (i.hasNext()) {
CmsResource currentPage = (CmsResource)i.next();
// read the template property
CmsProperty templateProperty;
try {
templateProperty = getCms().readPropertyObject(
getCms().getSitePath(currentPage),
CmsPropertyDefinition.PROPERTY_TEMPLATE,
false);
} catch (CmsException e2) {
if (LOG.isErrorEnabled()) {
LOG.error(e2);
}
continue;
}
// add currentResource if the template property value is the same as the given template
if (getParamTemplate().equals(templateProperty.getValue())) {
resourcesWithTemplate.add(currentPage);
}
}
// retain the list of pages against the list with template
xmlPages.retainAll(resourcesWithTemplate);
}
return xmlPages;
}
/**
* Returns a set of elements stored in the given template property.<p>
*
* The elements are stored in the property I_CmsConstants.C_PROPERTY_TEMPLATE_ELEMENTS.<p>
*
* @param currentTemplate the path of the template to look in
* @return a set of elements stored in the given template path
*/
private Set getTemplateElements(String currentTemplate) {
Set templateElements = new HashSet();
if (currentTemplate != null && currentTemplate.length() > 0) {
// template found, check template-elements property
String elements = null;
try {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -