/** * Returns the value for the given key from the configuration file.<p> * @param key the key to get the value for * @return the value for the given key */ protected String getConfigValue(String key) { if (m_localizationContent != null) { try { return m_localizationContent.getStringValue(null, m_pathPrefix + key, m_locale); } catch (NullPointerException e) { // a cms object is needed, log this error if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_NULL_CMSOBJECT_0)); } } } return null; }
/** * Returns the value for the given key from the configuration file.<p> * @param key the key to get the value for * @return the value for the given key */ protected String getConfigValue(String key) { if (m_localizationContent != null) { try { return m_localizationContent.getStringValue(null, m_pathPrefix + key, m_locale); } catch (NullPointerException e) { // a cms object is needed, log this error if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_NULL_CMSOBJECT_0)); } } } return null; }
if (value instanceof String) { result = xmlContentFileLink.getStringValue(getCmsObject(), (String)value, locale); } else if (value instanceof Vector) { while (it_title.hasNext()) { String next = (String)it_title.next(); if (!CmsStringUtil.isEmptyOrWhitespaceOnly(xmlContentFileLink.getStringValue( getCmsObject(), next, locale)) && !xmlContentFileLink.getStringValue(getCmsObject(), next, locale).equals("(none)")) { if (result.length() > 1 && result.lastIndexOf(",") != result.length()) { result += xmlContentFileLink.getStringValue(getCmsObject(), next, locale);
/** * Loads the localization for the current locale from a bundle of type xmlvfsbundle. * It assumes, the content has already been unmarshalled before. * @param locale the locale for which the localization should be loaded */ private void loadLocalizationFromXmlBundle(Locale locale) { CmsXmlContentValueSequence messages = m_xmlBundle.getValueSequence("Message", locale); SortedProperties props = new SortedProperties(); if (null != messages) { for (I_CmsXmlContentValue msg : messages.getValues()) { String msgpath = msg.getPath(); props.put( m_xmlBundle.getStringValue(m_cms, msgpath + "/Key", locale), m_xmlBundle.getStringValue(m_cms, msgpath + "/Value", locale)); } } m_localizations.put(locale, props); }
try { nodeValue = m_configuration.getStringValue(getCmsObject(), nodeName, getRequestContext().getLocale()); } catch (Exception e) {
/** * Returns the value for the specified property key name from the configuration.<p> * * Returns the default value argument if the property is not found.<p> * * @param key the property key name to look up * @param defaultValue a default value * @return the value for the specified property key name */ public String getConfigurationValue(String key, String defaultValue) { String value = null; try { value = getConfiguration().getStringValue(null, key, getRequestContext().getLocale()); } catch (Exception e) { // log error in debug mode if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } } if (CmsStringUtil.isEmpty(value)) { value = defaultValue; } return value; }
/** * Reads the link exclude definition file and extracts all excluded links stored in it.<p> * * @param cms the current CmsObject * @return list of Strings, containing link exclude paths */ private List readLinkExcludes(CmsObject cms) { List linkExcludes = new ArrayList(); try { // get the link exclude file CmsResource res = cms.readResource(LINK_EXCLUDE_DEFINIFITON_FILE); CmsFile file = cms.readFile(res); CmsXmlContent linkExcludeDefinitions = CmsXmlContentFactory.unmarshal(cms, file); // get number of excludes int count = linkExcludeDefinitions.getIndexCount(XPATH_LINK, Locale.ENGLISH); for (int i = 1; i <= count; i++) { String exclude = linkExcludeDefinitions.getStringValue(cms, XPATH_LINK + "[" + i + "]", Locale.ENGLISH); linkExcludes.add(exclude); } } catch (CmsException e) { LOG.error(e); } return linkExcludes; }
/** * Returns the value for the specified property key name from the configuration.<p> * * Returns the default value argument if the property is not found.<p> * * @param key the property key name to look up * @param defaultValue a default value * @return the value for the specified property key name */ public String getConfigurationValue(String key, String defaultValue) { String value = null; try { value = getConfiguration().getStringValue(null, key, getRequestContext().getLocale()); } catch (Exception e) { // log error in debug mode if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } } if (CmsStringUtil.isEmpty(value)) { value = defaultValue; } return value; }
String exclude = linkExcludeDefinitions.getStringValue(cms, XPATH_LINK + "[" + i + "]", Locale.ENGLISH); linkExcludes.add(exclude);
/** * Returns the configuration value for the specified key from the configuration.<p> * * @param key the key name to look up * @param defaultValue the default value used when no value was found for the key * @return the configuration value for the specified key */ public String getConfigValue(String key, String defaultValue) { String value = null; try { value = m_configuration.getStringValue(getCmsObject(), key, getRequestContext().getLocale()); if (CmsStringUtil.isEmpty(value)) { // value not found for current Locale, try to get it from first found Locale value = m_configuration.getStringValue(getCmsObject(), key, (Locale)m_configuration.getLocales().get(0)); } } catch (Exception e) { // log error in debug mode if (LOG.isDebugEnabled()) { LOG.debug(e.getMessage(), e); } } if (CmsStringUtil.isEmpty(value)) { // no configuration value found, use the default value value = defaultValue; } return value; }
/** * Initialize the key set for an xml bundle. */ private void initKeySetForXmlBundle() { // consider only available locales for (Locale l : m_locales) { if (m_xmlBundle.hasLocale(l)) { Set<Object> keys = new HashSet<Object>(); for (I_CmsXmlContentValue msg : m_xmlBundle.getValueSequence("Message", l).getValues()) { String msgpath = msg.getPath(); keys.add(m_xmlBundle.getStringValue(m_cms, msgpath + "/Key", l)); } m_keyset.updateKeySet(null, keys); } } }
/** * Returns the content value of the given path as String.<p> * * @param path the path to get the content value for * * @return the content value of the given path as String */ public String getConfigurationContentStringValue(String path) { if (getConfigurationContent() != null) { return getConfigurationContent().getStringValue(getCms(), path, getLocale()); } return ""; }
/** * Reads the referenced formatters.<p> * * @param xmlContent the XML content * * @return the referenced formatters */ private Map<String, CmsUUID> readReferencedFormatters(CmsXmlContent xmlContent) { Map<String, CmsUUID> result = new LinkedHashMap<String, CmsUUID>(); List<I_CmsXmlContentValue> formatters = xmlContent.getValues( CmsMacroFormatterResolver.N_FORMATTERS, CmsLocaleManager.MASTER_LOCALE); for (I_CmsXmlContentValue formatterValue : formatters) { CmsXmlVfsFileValue file = (CmsXmlVfsFileValue)xmlContent.getValue( formatterValue.getPath() + "/" + CmsMacroFormatterResolver.N_FORMATTER, CmsLocaleManager.MASTER_LOCALE); CmsUUID formatterId = file.getLink(m_cms).getStructureId(); String macroName = xmlContent.getStringValue( m_cms, formatterValue.getPath() + "/" + CmsMacroFormatterResolver.N_MACRO_NAME, CmsLocaleManager.MASTER_LOCALE); result.put(macroName, formatterId); } return result; }
/** * Returns the value of the specified node name from the imprint configuration.<p> * * @param nodeName the name of the imprint configuration node * @return the value of the specified node name from the imprint configuration */ public String getImprintValue(String nodeName) { String nodeValue = ""; try { // get value from configuration nodeValue = m_configuration.getStringValue(getCmsObject(), nodeName, getRequestContext().getLocale()); if (CmsStringUtil.isEmpty(nodeValue)) { return ""; } } catch (Exception e) { // ignore this exception, either configuration is not found or XML value is incorrect } return nodeValue; }
/** * Returns the email address provided in the imprint configuration.<p> * * @param defaultValue email address used if no email is provided in the configuration.<p> * * @return the email address provided in the imprint configuration */ protected String getEmail(String defaultValue) { String nodeValue = ""; try { // get email value from configuration nodeValue = m_configuration.getStringValue(getCmsObject(), "email", getRequestContext().getLocale()); } catch (Exception e) { // ignore this exception } if (CmsStringUtil.isEmpty(nodeValue)) { // no email in configuration, use default value nodeValue = defaultValue; } return nodeValue; }
/** * Returns the parameters of the collector with resolved macros.<p> * * @return the parameters of the collector with resolved macros */ public String getParameter() { Locale locale = getRequestContext().getLocale(); String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale); List links = m_content.getValues(NODE_LINKS, locale); CmsMacroResolver macroResolver = CmsMacroResolver.newInstance(); macroResolver.setKeepEmptyMacros(true); for (int i = 0; i < links.size(); i++) { I_CmsXmlContentValue xmlValue = (I_CmsXmlContentValue)links.get(i); String value = xmlValue.getStringValue(getCmsObject()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) { StringBuffer macro = new StringBuffer(10); macro.append(MACRO_LINK_PREFIX).append(i + 1); macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value)); } } return macroResolver.resolveMacros(params); }
result = document.getStringValue(cms, xpath, locale); if ((result == null) && (isMappingUsingDefault(xpath, TITLE_PROPERTY_MAPPING)
/** * Returns the parameters of the collector with resolved macros.<p> * * @return the parameters of the collector with resolved macros */ public String getParameter() { Locale locale = getRequestContext().getLocale(); String params = m_content.getStringValue(getCmsObject(), NODE_PARAMETER, locale); List<I_CmsXmlContentValue> links = m_content.getValues(NODE_LINKS, locale); CmsMacroResolver macroResolver = CmsMacroResolver.newInstance().setCmsObject(getCmsObject()); macroResolver.setKeepEmptyMacros(true); for (int i = 0; i < links.size(); i++) { I_CmsXmlContentValue xmlValue = links.get(i); String value = xmlValue.getStringValue(getCmsObject()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) { StringBuffer macro = new StringBuffer(10); macro.append(MACRO_LINK_PREFIX).append(i + 1); macroResolver.addMacro(macro.toString(), getRequestContext().removeSiteRoot(value)); } } return macroResolver.resolveMacros(params); }
/** * Returns the preset path set in the given xml content.<p> * * @param config the xml content with the config where to get the preset path from * * @return the preset path set in the given xml content */ private String getConfigPreset(CmsXmlContent config) { String result = null; if (config != null) { Locale locale = OpenCms.getLocaleManager().getDefaultLocale( getCmsObject(), getCmsObject().getSitePath(m_config.getFile())); if (config.getFile().getTypeId() == RESOURCE_TYPE_ID_CONFIG) { result = config.getStringValue(getCmsObject(), NODE_PRESET, locale); } else { result = config.getStringValue(getCmsObject(), NODE_PRESET_NESTED, locale); } } return result; }
String stringValue = xmlContent.getStringValue(cms, xPathCaptcha + NODE_FIELDLABEL, locale); String fieldLabel = getConfigurationValue(stringValue, "");