Package org.opencms.xml.containerpage
Class CmsContainerElementBean
- java.lang.Object
-
- org.opencms.xml.containerpage.CmsContainerElementBean
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
CmsJspStandardContextBean.CmsContainerElementWrapper
public class CmsContainerElementBean extends java.lang.Object implements java.lang.Cloneable
One element of a container in a container page.- Since:
- 8.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CmsContainerElementBean()
Constructor to enable wrapped elements.CmsContainerElementBean(CmsFile file, CmsUUID formatterId, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean inMemoryOnly, java.lang.String editorHash, boolean createNew)
Creates a new container page element bean.CmsContainerElementBean(CmsUUID elementId, CmsUUID formatterId, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean createNew)
Creates a new container page element bean.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFormatterSetting(java.lang.String containerName, java.lang.String formatterId)
Adds a formatter setting.CmsContainerElementBean
clone()
static CmsContainerElementBean
cloneWithFormatter(CmsContainerElementBean source, CmsUUID formatterId)
Clones the given element bean with a different formatter.static CmsContainerElementBean
cloneWithSettings(CmsContainerElementBean source, java.util.Map<java.lang.String,java.lang.String> settings)
Clones the given element bean with a different set of settings.static CmsContainerElementBean
createElementForResourceType(CmsObject cms, I_CmsResourceType resourceType, java.lang.String targetFolder, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean isCopyModels, java.util.Locale locale)
Creates an element bean for the given resource type.java.lang.String
editorHash()
Returns the ADE client editor has value.void
ensureNewInstanceId()
Ensures the element has a new element instance id.boolean
equals(java.lang.Object obj)
CmsUUID
getFormatterId()
Returns the structure id of the formatter of this element.CmsUUID
getId()
Returns the structure id of the resource of this element.java.util.Map<java.lang.String,java.lang.String>
getIndividualSettings()
Returns the settings of this element.CmsInheritanceInfo
getInheritanceInfo()
Returns the inheritance info.java.lang.String
getInstanceId()
Returns the element instance id.CmsResource
getResource()
Returns the resource of this element.java.util.Map<java.lang.String,java.lang.String>
getSettings()
Returns the element settings including default values for settings not set.java.lang.String
getSitePath()
Returns the site path of the resource of this element.java.lang.String
getTypeName()
Returns the resource type name.int
hashCode()
void
initResource(CmsObject cms)
Initializes the resource and the site path of this element.void
initSettings(CmsObject cms, CmsADEConfigData config, I_CmsFormatterBean formatterBean, java.util.Locale locale, javax.servlet.ServletRequest request, java.util.Map<java.lang.String,java.lang.String> presets)
Initializes the element settings.boolean
isCopyModel()
Returns if the given element should be used as a copy model.boolean
isCreateNew()
Returns if a new element should be created replacing the given one on first edit of a container-page.boolean
isDoNotCache()
Checks if the element is uncacheable.boolean
isGroupContainer(CmsObject cms)
Tests whether this element refers to a group container.boolean
isHistoryContent()
Checks if the element is used for displaying a historical content (usually from the history dialog).boolean
isInheritedContainer(CmsObject cms)
Returns whether this element refers to an inherited container element.boolean
isInMemoryOnly()
Returns if the represented resource is in memory only and not persisted in the VFS.boolean
isModelGroup()
Returns if the given element is a model group.boolean
isModelGroupAlwaysReplace()
Returns if all instances of this element should be replaced within a copy model.boolean
isReleasedAndNotExpired()
Returns if the element resource is released and not expired.boolean
isTemporaryContent()
Returns if the element resource contains temporary file content.void
removeInstanceId()
Removes the instance id.void
setDoNotCache(boolean doNotCache)
Enables / disables 'do not cache' status, which prevents the element from being cached in the session cache.void
setFormatterId(CmsUUID formatterId)
Sets the formatter id.void
setHistoryFile(CmsFile file)
Sets a historical file.void
setInheritanceInfo(CmsInheritanceInfo inheritanceInfo)
Sets the inheritance info for this element.void
setTemporaryFile(CmsFile elementFile)
Sets the element resource as a temporary file.java.lang.String
toString()
void
updateIndividualSettings(java.util.Map<java.lang.String,java.lang.String> newSettings)
Updates the individual settings.
-
-
-
Constructor Detail
-
CmsContainerElementBean
public CmsContainerElementBean(CmsFile file, CmsUUID formatterId, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean inMemoryOnly, java.lang.String editorHash, boolean createNew)
Creates a new container page element bean.- Parameters:
file
- the element's fileformatterId
- the formatter's structure id, could benull
individualSettings
- the element settings as a map of name/value pairsinMemoryOnly
- the in memory flageditorHash
- the editor hash to usecreateNew
-true
if a new element should be created replacing the given one on first edit of a container-page
-
CmsContainerElementBean
public CmsContainerElementBean(CmsUUID elementId, CmsUUID formatterId, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean createNew)
Creates a new container page element bean.- Parameters:
elementId
- the element's structure idformatterId
- the formatter's structure id, could benull
individualSettings
- the element settings as a map of name/value pairscreateNew
-true
if a new element should be created replacing the given one on first edit of a container-page
-
CmsContainerElementBean
protected CmsContainerElementBean()
Constructor to enable wrapped elements.
-
-
Method Detail
-
cloneWithFormatter
public static CmsContainerElementBean cloneWithFormatter(CmsContainerElementBean source, CmsUUID formatterId)
Clones the given element bean with a different formatter.- Parameters:
source
- the element to cloneformatterId
- the new formatter id- Returns:
- the element bean
-
cloneWithSettings
public static CmsContainerElementBean cloneWithSettings(CmsContainerElementBean source, java.util.Map<java.lang.String,java.lang.String> settings)
Clones the given element bean with a different set of settings.- Parameters:
source
- the element to clonesettings
- the new settings- Returns:
- the element bean
-
createElementForResourceType
public static CmsContainerElementBean createElementForResourceType(CmsObject cms, I_CmsResourceType resourceType, java.lang.String targetFolder, java.util.Map<java.lang.String,java.lang.String> individualSettings, boolean isCopyModels, java.util.Locale locale) throws CmsException
Creates an element bean for the given resource type.The represented resource will be in memory only and not in the VFS!!!.
- Parameters:
cms
- the CMS contextresourceType
- the resource typetargetFolder
- the parent folder of the resourceindividualSettings
- the element settings as a map of name/value pairsisCopyModels
- if this element when used in models should be copied instead of reusedlocale
- the locale to use- Returns:
- the created element bean
- Throws:
CmsException
- if something goes wrong creating the elementjava.lang.IllegalArgumentException
- if the resource type not instance ofCmsResourceTypeXmlContent
-
addFormatterSetting
public void addFormatterSetting(java.lang.String containerName, java.lang.String formatterId)
Adds a formatter setting.- Parameters:
containerName
- the container nameformatterId
- the formatter id
-
clone
public CmsContainerElementBean clone()
- Overrides:
clone
in classjava.lang.Object
- See Also:
Object.clone()
-
editorHash
public java.lang.String editorHash()
Returns the ADE client editor has value.- Returns:
- the ADE client editor has value
-
ensureNewInstanceId
public void ensureNewInstanceId()
Ensures the element has a new element instance id.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getFormatterId
public CmsUUID getFormatterId()
Returns the structure id of the formatter of this element.- Returns:
- the structure id of the formatter of this element
-
getId
public CmsUUID getId()
Returns the structure id of the resource of this element.- Returns:
- the structure id of the resource of this element
-
getIndividualSettings
public java.util.Map<java.lang.String,java.lang.String> getIndividualSettings()
Returns the settings of this element.- Returns:
- the settings of this element
-
getInheritanceInfo
public CmsInheritanceInfo getInheritanceInfo()
Returns the inheritance info.- Returns:
- the inheritance info or
null
if not available
-
getInstanceId
public java.lang.String getInstanceId()
Returns the element instance id.- Returns:
- the element instance id
-
getResource
public CmsResource getResource()
Returns the resource of this element.It is required to call
initResource(CmsObject)
before this method can be used.- Returns:
- the resource of this element
- See Also:
initResource(CmsObject)
-
getSettings
public java.util.Map<java.lang.String,java.lang.String> getSettings()
Returns the element settings including default values for settings not set.Will return
null
if the element bean has not been initialized withinitResource(org.opencms.file.CmsObject)
.- Returns:
- the element settings
-
getSitePath
public java.lang.String getSitePath()
Returns the site path of the resource of this element.It is required to call
initResource(CmsObject)
before this method can be used.- Returns:
- the site path of the resource of this element
- See Also:
initResource(CmsObject)
-
getTypeName
public java.lang.String getTypeName()
Returns the resource type name.- Returns:
- the type name
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
initResource
public void initResource(CmsObject cms) throws CmsException
Initializes the resource and the site path of this element.- Parameters:
cms
- the CMS context- Throws:
CmsException
- if something goes wrong reading the element resource
-
initSettings
public void initSettings(CmsObject cms, CmsADEConfigData config, I_CmsFormatterBean formatterBean, java.util.Locale locale, javax.servlet.ServletRequest request, java.util.Map<java.lang.String,java.lang.String> presets)
Initializes the element settings.- Parameters:
cms
- the CMS contextformatterBean
- the formatter configuration beanlocale
- the content localerequest
- the current request, if availablepresets
- the presets for container element settings
-
isCopyModel
public boolean isCopyModel()
Returns if the given element should be used as a copy model.- Returns:
true
if the given element should be used as a copy model
-
isCreateNew
public boolean isCreateNew()
Returns if a new element should be created replacing the given one on first edit of a container-page.- Returns:
true
if a new element should be created replacing the given one on first edit of a container-page
-
isDoNotCache
public boolean isDoNotCache()
Checks if the element is uncacheable.- Returns:
- true if the element is uncacheable
-
isGroupContainer
public boolean isGroupContainer(CmsObject cms) throws CmsException
Tests whether this element refers to a group container.- Parameters:
cms
- the CmsObject used for VFS operations- Returns:
true
if the container element refers to a group container- Throws:
CmsException
- if something goes wrong
-
isHistoryContent
public boolean isHistoryContent()
Checks if the element is used for displaying a historical content (usually from the history dialog).- Returns:
- true if the element is used for displaying a historical content
-
isInheritedContainer
public boolean isInheritedContainer(CmsObject cms) throws CmsException
Returns whether this element refers to an inherited container element.- Parameters:
cms
- the CmsObject used for VFS operations- Returns:
true
if the container element refers to an inherited container- Throws:
CmsException
- if something goes wrong
-
isInMemoryOnly
public boolean isInMemoryOnly()
Returns if the represented resource is in memory only and not persisted in the VFS.- Returns:
true
if the represented resource is in memory only and not persisted in the VFS
-
isModelGroup
public boolean isModelGroup()
Returns if the given element is a model group.- Returns:
true
if the given element is a model group
-
isModelGroupAlwaysReplace
public boolean isModelGroupAlwaysReplace()
Returns if all instances of this element should be replaced within a copy model.- Returns:
true
if all instances of this element should be replaced within a copy model
-
isReleasedAndNotExpired
public boolean isReleasedAndNotExpired()
Returns if the element resource is released and not expired.- Returns:
true
if the element resource is released and not expired
-
isTemporaryContent
public boolean isTemporaryContent()
Returns if the element resource contains temporary file content.- Returns:
true
if the element resource contains temporary file content
-
removeInstanceId
public void removeInstanceId()
Removes the instance id.
-
setDoNotCache
public void setDoNotCache(boolean doNotCache)
Enables / disables 'do not cache' status, which prevents the element from being cached in the session cache.- Parameters:
doNotCache
- the new value
-
setFormatterId
public void setFormatterId(CmsUUID formatterId)
Sets the formatter id.- Parameters:
formatterId
- the formatter id
-
setHistoryFile
public void setHistoryFile(CmsFile file)
Sets a historical file.- Parameters:
file
- the historical file
-
setInheritanceInfo
public void setInheritanceInfo(CmsInheritanceInfo inheritanceInfo)
Sets the inheritance info for this element.- Parameters:
inheritanceInfo
- the inheritance info
-
setTemporaryFile
public void setTemporaryFile(CmsFile elementFile)
Sets the element resource as a temporary file.- Parameters:
elementFile
- the temporary file
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
updateIndividualSettings
public void updateIndividualSettings(java.util.Map<java.lang.String,java.lang.String> newSettings)
Updates the individual settings.This causes all merged settings (from defaults etc.) to be lost.
- Parameters:
newSettings
- the new settings
-
-