/** * 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); } } }
/** * Adds a value element of the type indicated by the given xpath * at the selected index to the XML content document.<p> * * @param cms the current users OpenCms context * @param xpath the path that indicates the element type in the content definition * @param index the index where to add the new value element * * @return the added XML content value element * * @see CmsXmlContent#addValue(CmsObject, String, Locale, int) * @see #addValue(CmsObject, I_CmsXmlSchemaType, int) * @see #addValue(CmsObject, int) */ public I_CmsXmlContentValue addValue(CmsObject cms, String xpath, int index) { I_CmsXmlContentValue newValue = m_content.addValue(cms, xpath, getLocale(), index); // re-initialize the value list m_values = m_content.getValues(getPath(), getLocale()); return newValue; }
String value = props.getProperty(key.toString()); if (!value.isEmpty()) { m_xmlBundle.addValue(m_cms, "Message", l, i); i++; m_xmlBundle.getValue("Message[" + i + "]/Key", l).setStringValue(m_cms, key.toString());
if (conf != null) { conf.addValue(getCmsObject(), NODE_OPTIONALCONFIG, getRequestContext().getLocale(), 0); I_CmsXmlContentValue value = conf.getValue( NODE_OPTIONALCONFIG + "/headlines.set",
/** * Adds a value element of the sequence type at the selected index to the XML content document.<p> * * @param cms the current users OpenCms context * @param index the index where to add the new value element * * @return the added XML content value element * * @see CmsXmlContent#addValue(CmsObject, String, Locale, int) */ public I_CmsXmlContentValue addValue(CmsObject cms, int index) { I_CmsXmlContentValue newValue = m_content.addValue(cms, getPath(), getLocale(), index); // re-initialize the value list m_values = m_content.getValues(getPath(), getLocale()); return newValue; }
/** * 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); }
/** * Writes a single item of detail page information to the XML content.<p> * * @param type the type which the detail page should render * @param id the page id of the detail page * @param index the position at which the detail page info should be added */ private void writeValue(String type, CmsUUID id, int index) { Locale locale = CmsLocaleManager.getLocale("en"); // todo: check actual locale. m_document.addValue(m_cms, N_DETAIL_PAGE, locale, index); String typePath = N_DETAIL_PAGE + "[" + (1 + index) + "]/" + N_TYPE; I_CmsXmlContentValue typeVal = m_document.getValue(typePath, locale); String pagePath = N_DETAIL_PAGE + "[" + (1 + index) + "]/" + N_PAGE; CmsXmlVfsFileValue pageVal = (CmsXmlVfsFileValue)m_document.getValue(pagePath, locale); typeVal.setStringValue(m_cms, type); pageVal.setIdValue(m_cms, id); } }
if ((null != key) && !key.toString().isEmpty()) { m_descContent.addValue(m_cms, Descriptor.N_MESSAGE, Descriptor.LOCALE, i); i++; String messagePrefix = Descriptor.N_MESSAGE + "[" + i + "]/";
I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i); if (field == null) { field = content.addValue(cms, elementPath, contentLocale, i); I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i); if (field == null) { field = content.addValue(cms, elementPath, contentLocale, i); I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i); if (field == null) { field = content.addValue(cms, elementPath, contentLocale, i); I_CmsXmlContentValue field = content.getValue(elementPath, contentLocale, i); if (field == null) { field = content.addValue(cms, elementPath, contentLocale, i);
value = content.getValue(CmsConfigurationReader.N_MODEL_PAGE, Locale.ENGLISH, i); } else { 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); CmsResource model = m_cms.readResource(structureId, CmsResourceFilter.IGNORE_EXPIRATION); linkValue.setStringValue(m_cms, m_cms.getSitePath(model)); I_CmsXmlContentValue disabledValue = content.hasValue(disabledPath, Locale.ENGLISH) ? content.getValue(disabledPath, Locale.ENGLISH) : content.addValue(m_cms, disabledPath, Locale.ENGLISH, 0); disabledValue.setStringValue(m_cms, Boolean.toString(disabled)); writeSitemapConfig(content, sitemapConfigFile);
I_CmsXmlContentValue newValue = addValue(cms, parentElement, type, locale, insertIndex);
I_CmsXmlContentValue newValue = addValue(cms, parentElement, type, locale, insertIndex);
/** * 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)); } } } }
content.getValue(target, locale).setStringValue(cms, prop.getValue()); } else { content.addValue(cms, target, locale, 0).setStringValue(cms, prop.getValue());
content.addValue(m_cms, CmsConfigurationReader.N_MODEL_PAGE, Locale.ENGLISH, i);
m_content.addValue(getCms(), getParamElementName(), getElementLocale(), index);
content.addValue(m_cms, CmsConfigurationReader.N_MODEL_PAGE, locale, 0); content.getValue( CmsConfigurationReader.N_MODEL_PAGE + "[1]/" + CmsConfigurationReader.N_PAGE,
} else { m_content.addValue(getCms(), elementPath, getElementLocale(), index); elementPath = CmsXmlUtils.createXpathElement(elementPath, index + 1); ? CmsXmlUtils.removeFirstXpathElement(pathToChoice) : null; I_CmsXmlContentValue newVal = m_content.addValue(getCms(), newPath, getElementLocale(), index); newPath = newVal.getPath(); m_content.addValue(getCms(), elementPath, getElementLocale(), index);
: m_resInfo.getName())); configContent.addValue(cms, CmsFormatterBeanParser.N_MATCH, CmsConfigurationReader.DEFAULT_LOCALE, 0); configContent.addValue( cms, CmsFormatterBeanParser.N_MATCH + "/" + CmsFormatterBeanParser.N_WIDTH, lockTemporary(moduleConfigFile); CmsXmlContent moduleConfigContent = CmsXmlContentFactory.unmarshal(cms, moduleConfigFile); I_CmsXmlContentValue resourceTypeValue = moduleConfigContent.addValue( cms, CmsConfigurationReader.N_RESOURCE_TYPE,