public final class CmsXmlContentPropertyHelper extends java.lang.Object implements java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
CmsXmlContentPropertyHelper.JsonProperty
Element Property json property constants.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PAGE_PROPERTY_PREFIX
The prefix for macros used to acess properties of the current container page.
|
protected static java.lang.Object |
PROPERTY_EMPTY_MARKER
If a property has this value, the page-property macro for this property will expand to the empty string instead.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
addFileListPropertyValue(CmsObject cms,
org.dom4j.Element valueElement,
java.lang.String propValue)
Adds the XML for a property value of a property of type 'vfslist' to the DOM.
|
protected static java.lang.String |
convertIdsToPaths(CmsObject cms,
java.lang.String value)
Converts a string containing zero or more structure ids into a string containing the corresponding VFS paths.
|
protected static java.lang.String |
convertPathsToIds(CmsObject cms,
java.lang.String value)
Converts a string containing zero or more VFS paths into a string containing the corresponding structure ids.
|
protected static java.util.Map<java.lang.String,java.lang.String> |
convertProperties(CmsObject cms,
java.util.Map<java.lang.String,java.lang.String> props,
java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig,
boolean toClient)
Helper method for converting a map of properties from client format to server format or vice versa.
|
static java.util.Map<java.lang.String,java.lang.String> |
convertPropertiesToClientFormat(CmsObject cms,
java.util.Map<java.lang.String,java.lang.String> props,
java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
Converts a map of properties from server format to client format.
|
static java.util.Map<java.lang.String,java.lang.String> |
convertPropertiesToServerFormat(CmsObject cms,
java.util.Map<java.lang.String,java.lang.String> props,
java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
Converts a map of properties from client format to server format.
|
protected static java.lang.String |
convertStringPropertyValue(CmsObject cms,
java.lang.String propValue,
java.lang.String type,
boolean toClient)
Converts a property value given as a string between server format and client format.
|
static java.util.Map<java.lang.String,CmsXmlContentProperty> |
copyPropertyConfiguration(java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
Creates a deep copy of a property configuration map.
|
protected static CmsVfsFileValueBean |
getFileValueForIdOrUri(CmsObject cms,
java.lang.String idOrUri)
Given a string which might be a id or a (sitemap or VFS) URI, this method will return
a bean containing the right (sitemap or vfs) root path and (sitemap entry or structure) id.
|
static CmsUUID |
getIdForUri(CmsObject cms,
java.lang.String uri)
Looks up an URI in the sitemap and returns either a sitemap entry id (if the URI is a sitemap URI)
or the structure id of a resource (if the URI is a VFS path).
|
static CmsMacroResolver |
getMacroResolverForProperties(CmsObject cms,
I_CmsXmlContentHandler contentHandler,
CmsResource containerPage)
Creates and configures a new macro resolver for resolving macros which occur in property definitions.
|
protected static CmsXmlContentProperty |
getPropertyConfig(java.util.Map<java.lang.String,CmsXmlContentProperty> propertyConfig,
java.lang.String propName)
Helper method for accessing the property configuration for a single property.
|
static java.util.Map<java.lang.String,CmsXmlContentProperty> |
getPropertyInfo(CmsObject cms,
CmsResource page,
CmsResource resource)
Returns the property information for the given resource (type) AND the current user.
|
static java.lang.String |
getPropValueIds(CmsObject cms,
java.lang.String type,
java.lang.String value)
Returns a converted property value depending on the given type.
|
static java.lang.String |
getPropValuePaths(CmsObject cms,
java.lang.String type,
java.lang.String value)
Returns a converted property value depending on the given type.
|
static java.lang.String |
getUriForId(CmsObject cms,
CmsUUID id)
Returns a sitemap or VFS path given a sitemap entry id or structure id.
|
static JSONObject |
getWidgetConfigurationAsJSON(java.lang.String widgetConfiguration)
Returns the widget configuration string parsed into a JSONObject.
|
static java.util.Map<java.lang.String,java.lang.String> |
mergeDefaults(CmsObject cms,
CmsResource resource,
java.util.Map<java.lang.String,java.lang.String> properties)
Extends the given properties with the default values
from the resource's property configuration.
|
static java.util.Map<java.lang.String,java.lang.String> |
mergeDefaults(CmsObject cms,
java.util.Map<java.lang.String,CmsXmlContentProperty> propertyConfig,
java.util.Map<java.lang.String,java.lang.String> properties)
Extends the given properties with the default values
from property configuration.
|
static java.util.Map<java.lang.String,java.lang.String> |
readProperties(CmsObject cms,
I_CmsXmlContentLocation baseLocation)
Reads property nodes from the given location.
|
static java.util.Map<java.lang.String,java.lang.String> |
readProperties(CmsXmlContent xmlContent,
java.util.Locale locale,
org.dom4j.Element element,
java.lang.String elemPath,
CmsXmlContentDefinition elemDef)
Reads the properties from property-enabled xml content values.
|
static java.util.Map<java.lang.String,CmsXmlContentProperty> |
resolveMacrosForPropertyInfo(CmsObject cms,
CmsResource page,
CmsResource resource,
java.util.Map<java.lang.String,CmsXmlContentProperty> propertiesConf)
Resolves macros in the given property information for the given resource (type) AND the current user.
|
static java.util.Map<java.lang.String,CmsXmlContentProperty> |
resolveMacrosInProperties(java.util.Map<java.lang.String,CmsXmlContentProperty> properties,
I_CmsMacroResolver resolver)
Resolves macros in all properties in a map.
|
static CmsXmlContentProperty |
resolveMacrosInProperty(CmsXmlContentProperty property,
I_CmsMacroResolver resolver)
Resolves the macros in a single property.
|
static void |
saveProperties(CmsObject cms,
org.dom4j.Element parentElement,
java.util.Map<java.lang.String,java.lang.String> properties,
java.util.Map<java.lang.String,CmsXmlContentProperty> propertiesConf)
Saves the given properties to the given xml element.
|
public static final java.lang.String PAGE_PROPERTY_PREFIX
protected static final java.lang.Object PROPERTY_EMPTY_MARKER
public static java.util.Map<java.lang.String,java.lang.String> convertPropertiesToClientFormat(CmsObject cms, java.util.Map<java.lang.String,java.lang.String> props, java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
cms
- the CmsObject to use for VFS operationsprops
- the map of propertiespropConfig
- the property configurationpublic static java.util.Map<java.lang.String,java.lang.String> convertPropertiesToServerFormat(CmsObject cms, java.util.Map<java.lang.String,java.lang.String> props, java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
cms
- the CmsObject to use for VFS operationsprops
- the map of propertiespropConfig
- the property configurationpublic static java.util.Map<java.lang.String,CmsXmlContentProperty> copyPropertyConfiguration(java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig)
propConfig
- the property configuration which should be copiedpublic static CmsUUID getIdForUri(CmsObject cms, java.lang.String uri) throws CmsException
cms
- the current CMS contexturi
- the URI to look upCmsException
- if something goes wrongpublic static CmsMacroResolver getMacroResolverForProperties(CmsObject cms, I_CmsXmlContentHandler contentHandler, CmsResource containerPage)
cms
- the CMS contextcontentHandler
- the content handler which contains the message bundle that should be available in the macro resolvercontainerPage
- the current container pagepublic static java.util.Map<java.lang.String,CmsXmlContentProperty> getPropertyInfo(CmsObject cms, CmsResource page, CmsResource resource) throws CmsException
cms
- the current CMS contextpage
- the current container pageresource
- the resourceCmsException
- if something goes wrongpublic static java.lang.String getPropValueIds(CmsObject cms, java.lang.String type, java.lang.String value)
If the type is CmsXmlContentProperty.PropType.vfslist
, the value is parsed as a
list of paths and converted to a list of IDs.
cms
- the current CMS contexttype
- the property typevalue
- the raw property valuepublic static java.lang.String getPropValuePaths(CmsObject cms, java.lang.String type, java.lang.String value)
If the type is CmsXmlContentProperty.PropType.vfslist
, the value is parsed as a
list of IDs and converted to a list of paths.
cms
- the current CMS contexttype
- the property typevalue
- the raw property valuepublic static java.lang.String getUriForId(CmsObject cms, CmsUUID id) throws CmsException
This method first tries to read a sitemap entry with the given id. If this succeeds, the sitemap entry's sitemap path will be returned. If it fails, the method interprets the id as a structure id and tries to read the corresponding resource, and then returns its VFS path.
cms
- the CMS contextid
- a sitemap entry id or structure idCmsException
- if something goes wrongpublic static JSONObject getWidgetConfigurationAsJSON(java.lang.String widgetConfiguration)
The configuration string should be a map of key value pairs separated by ':' and '|': KEY_1:VALUE_1|KEY_2:VALUE_2 ...
widgetConfiguration
- the configuration to parsepublic static java.util.Map<java.lang.String,java.lang.String> mergeDefaults(CmsObject cms, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> properties)
cms
- the current CMS contextresource
- the resource to get the property configuration fromproperties
- the properties to extendpublic static java.util.Map<java.lang.String,java.lang.String> mergeDefaults(CmsObject cms, java.util.Map<java.lang.String,CmsXmlContentProperty> propertyConfig, java.util.Map<java.lang.String,java.lang.String> properties)
cms
- the current CMS contextpropertyConfig
- the property configurationproperties
- the properties to extendpublic static java.util.Map<java.lang.String,java.lang.String> readProperties(CmsObject cms, I_CmsXmlContentLocation baseLocation)
cms
- the current cms contextbaseLocation
- the base locationpublic static java.util.Map<java.lang.String,java.lang.String> readProperties(CmsXmlContent xmlContent, java.util.Locale locale, org.dom4j.Element element, java.lang.String elemPath, CmsXmlContentDefinition elemDef)
xmlContent
- the xml contentlocale
- the current localeelement
- the xml elementelemPath
- the xpathelemDef
- the element definitionCmsXmlContainerPage.XmlNode.Elements
public static java.util.Map<java.lang.String,CmsXmlContentProperty> resolveMacrosForPropertyInfo(CmsObject cms, CmsResource page, CmsResource resource, java.util.Map<java.lang.String,CmsXmlContentProperty> propertiesConf) throws CmsException
cms
- the current CMS contextpage
- the current container pageresource
- the resourcepropertiesConf
- the property informationCmsException
- if something goes wrongpublic static java.util.Map<java.lang.String,CmsXmlContentProperty> resolveMacrosInProperties(java.util.Map<java.lang.String,CmsXmlContentProperty> properties, I_CmsMacroResolver resolver)
properties
- the map of properties in which macros should be resolvedresolver
- the macro resolver to usepublic static CmsXmlContentProperty resolveMacrosInProperty(CmsXmlContentProperty property, I_CmsMacroResolver resolver)
property
- the property in which macros should be resolvedresolver
- the macro resolver to usepublic static void saveProperties(CmsObject cms, org.dom4j.Element parentElement, java.util.Map<java.lang.String,java.lang.String> properties, java.util.Map<java.lang.String,CmsXmlContentProperty> propertiesConf)
cms
- the current CMS contextparentElement
- the parent xml elementproperties
- the properties to save, if there is a list of resources, every entry can be a site path or a UUIDpropertiesConf
- the configuration of the propertiesprotected static void addFileListPropertyValue(CmsObject cms, org.dom4j.Element valueElement, java.lang.String propValue)
cms
- the current CMS contextvalueElement
- the element to which the vfslist property value should be addedpropValue
- the property value which should be savedprotected static java.lang.String convertIdsToPaths(CmsObject cms, java.lang.String value)
cms
- the CmsObject to use for the VFS operationsvalue
- a string representation of a list of idsprotected static java.lang.String convertPathsToIds(CmsObject cms, java.lang.String value)
cms
- the CmsObject to use for the VFS operationsvalue
- a string representation of a list of pathsprotected static java.util.Map<java.lang.String,java.lang.String> convertProperties(CmsObject cms, java.util.Map<java.lang.String,java.lang.String> props, java.util.Map<java.lang.String,CmsXmlContentProperty> propConfig, boolean toClient)
cms
- the CmsObject to use for VFS operationsprops
- the map of propertiespropConfig
- the property configurationtoClient
- if true, convert from server to client, else from client to serverprotected static java.lang.String convertStringPropertyValue(CmsObject cms, java.lang.String propValue, java.lang.String type, boolean toClient)
cms
- the current CMS contextpropValue
- the property value to converttype
- the type of the propertytoClient
- if true, convert to client format, else convert to server formatprotected static CmsVfsFileValueBean getFileValueForIdOrUri(CmsObject cms, java.lang.String idOrUri) throws CmsException
cms
- the current CMS contextidOrUri
- a string containing an id or an URICmsException
- if something goes wrongprotected static CmsXmlContentProperty getPropertyConfig(java.util.Map<java.lang.String,CmsXmlContentProperty> propertyConfig, java.lang.String propName)
This method uses the base name of the property to access the property configuration, i.e. if propName starts with a '#', the part after the '#' will be used as the key for the property configuration.
propertyConfig
- the property configuration mappropName
- the name of a property