/** * Removes all values of the given path in the other locales.<p> * * @param elementPath the element path * @param sourceLocale the source locale */ private void removeValuesInOtherLocales(String elementPath, Locale sourceLocale) { for (Locale locale : getLocales()) { if (locale.equals(sourceLocale)) { continue; } while (hasValue(elementPath, locale)) { removeValue(elementPath, locale, 0); } } }
/** * Ensures the parent values to the given path are created.<p> * * @param cms the cms context * @param valuePath the value path * @param locale the content locale */ private void ensureParentValues(CmsObject cms, String valuePath, Locale locale) { if (valuePath.contains("/")) { String parentPath = valuePath.substring(0, valuePath.lastIndexOf("/")); if (!hasValue(parentPath, locale)) { ensureParentValues(cms, parentPath, locale); int index = CmsXmlUtils.getXpathIndexInt(parentPath) - 1; addValue(cms, parentPath, locale, index); } } }
if (content.hasValue(path, locale)) { continue; } else {
/** * Adds the given value to the content document.<p> * * @param content the content document * @param locale the content locale * @param path the value XPath * @param value the value */ protected void addContentValue(CmsXmlContent content, Locale locale, String path, String value) { boolean hasValue = content.hasValue(path, locale); if (!hasValue) { String[] pathElements = path.split("/"); String currentPath = pathElements[0]; for (int i = 0; i < pathElements.length; i++) { if (i > 0) { currentPath = CmsStringUtil.joinPaths(currentPath, pathElements[i]); } while (!content.hasValue(currentPath, locale)) { content.addValue(m_cms, currentPath, locale, CmsXmlUtils.getXpathIndexInt(currentPath) - 1); } } } content.getValue(path, locale).setStringValue(m_cms, value); }
if (content.hasValue(path, locale)) {
String removeAllStringValue = content.getStringValue(cms, removeAllPath, locale); boolean removeAll = Boolean.valueOf(removeAllStringValue).booleanValue(); if (removeAll && content.hasValue(REMOVE_PATH, locale)) { content.removeValue(REMOVE_PATH, locale, 0); } else if (content.hasValue(ADD_PATH, locale)) { String rootPath = content.getFile().getRootPath(); List<String> optionValues = CmsAddFormatterWidget.getSelectOptionValues(cms, rootPath, false);
/** * Deletes the given value path from the content document.<p> * * @param content the content document * @param locale the content locale * @param path the value XPath */ protected void deleteContentValue(CmsXmlContent content, Locale locale, String path) { boolean hasValue = content.hasValue(path, locale); if (hasValue) { int index = CmsXmlUtils.getXpathIndexInt(path) - 1; I_CmsXmlContentValue val = content.getValue(path, locale); if (index >= val.getMinOccurs()) { content.removeValue(path, locale, index); } else { val.setStringValue(m_cms, ""); } } }
/** * Sets the value in all other locales.<p> * * @param cms the cms context * @param value the value * @param requiredParent the path to the required parent value */ private void setValueForOtherLocales(CmsObject cms, I_CmsXmlContentValue value, String requiredParent) { if (!value.isSimpleType()) { throw new IllegalArgumentException(); } for (Locale locale : getLocales()) { if (locale.equals(value.getLocale())) { continue; } String valuePath = value.getPath(); if (CmsStringUtil.isEmptyOrWhitespaceOnly(requiredParent) || hasValue(requiredParent, locale)) { ensureParentValues(cms, valuePath, locale); if (hasValue(valuePath, locale)) { I_CmsXmlContentValue localeValue = getValue(valuePath, locale); localeValue.setStringValue(cms, value.getStringValue(cms)); } else { int index = CmsXmlUtils.getXpathIndexInt(valuePath) - 1; I_CmsXmlContentValue localeValue = addValue(cms, valuePath, locale, index); localeValue.setStringValue(cms, value.getStringValue(cms)); } } } }
if (hasValue(valuePath, sourceLocale)) { List<I_CmsXmlContentValue> subValues = getValues(valuePath, sourceLocale); removeSurplusValuesInOtherLocales(elementPath, subValues.size(), sourceLocale); if (hasValue(elementPath, sourceLocale)) { List<I_CmsXmlContentValue> subValues = getValues(elementPath, sourceLocale); removeSurplusValuesInOtherLocales(elementPath, subValues.size(), sourceLocale);
value = content.addValue(m_cms, CmsConfigurationReader.N_MODEL_PAGE, Locale.ENGLISH, i); String linkValuePath = value.getPath() + "/" + CmsConfigurationReader.N_MODEL_PAGE; I_CmsXmlContentValue linkValue = content.hasValue(linkValuePath, Locale.ENGLISH) ? content.getValue(linkValuePath, Locale.ENGLISH) : content.addValue(m_cms, linkValuePath, Locale.ENGLISH, 0); I_CmsXmlContentValue disabledValue = content.hasValue(disabledPath, Locale.ENGLISH) ? content.getValue(disabledPath, Locale.ENGLISH) : content.addValue(m_cms, disabledPath, Locale.ENGLISH, 0);
boolean hasFileLink = m_content.hasValue(xPath + NODE_FILELINK, locale); if (m_content.hasValue(xPath + NODE_HEADLINE, locale)) { headline = m_content.getStringValue(getCmsObject(), xPath + NODE_HEADLINE, locale); boolean imagePresent = false; if (m_content.hasValue(xPath, locale)) { if (m_content.hasValue(xPath + NODE_DESCRIPTION, locale)) {
if (content.hasValue(target, locale)) { content.getValue(target, locale).setStringValue(cms, prop.getValue()); } else {
} else { if (m_content.hasValue(getParamElementName(), getElementLocale())) {
if (m_content.hasValue(getParamElementName(), getElementLocale())) {
if (CmsResourceTypeXmlContent.isXmlContent(resource)) { CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCmsObject(), resource); if (xmlContent.hasValue(NODE_CONFIG, getRequestContext().getLocale())) { m_config = xmlContent; m_presetPath = getConfigPreset(xmlContent);