Package org.opencms.ade.configuration
Class CmsResourceTypeConfig
- java.lang.Object
-
- org.opencms.ade.configuration.CmsResourceTypeConfig
-
- All Implemented Interfaces:
java.lang.Cloneable
,I_CmsConfigurationObject<CmsResourceTypeConfig>
public class CmsResourceTypeConfig extends java.lang.Object implements I_CmsConfigurationObject<CmsResourceTypeConfig>, java.lang.Cloneable
The configuration for a single resource type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsResourceTypeConfig.AddMenuType
Enum used to distinguish the type of menu in which a configured resource type can be displayed.static class
CmsResourceTypeConfig.AddMenuVisibility
Represents the visibility status of a resource type in the 'Add' menu of the container page editor.
-
Field Summary
Fields Modifier and Type Field Description protected CmsObject
m_cms
The CMS object used for VFS operations.-
Fields inherited from interface org.opencms.ade.configuration.I_CmsConfigurationObject
DEFAULT_ORDER
-
-
Constructor Summary
Constructors Constructor Description CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsContentFolderDescriptor folder, java.lang.String pattern)
Creates a new resource type configuration.CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsContentFolderDescriptor folder, java.lang.String pattern, boolean detailPagesDisabled, boolean addDisabled, boolean createDisabled, boolean editDisabled, boolean enableInLists, boolean availabilityNotSet, CmsUUID elementView, java.lang.String localization, java.lang.Boolean showInDefaultView, java.lang.Boolean copyInModels, java.lang.Integer order, CmsCntPageData.ElementDeleteMode elementDeleteMode)
Creates a new resource type configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkCreatable(CmsObject cms, java.lang.String pageFolderRootPath)
Checks if this resource type is creatable.void
checkInitialized()
Checks whether the object is initialized and throws an exception otherwise.void
checkOffline(CmsObject cms)
Checks whether the cms context is in the offline project and throws an exception otherwise.boolean
checkViewable(CmsObject cms, java.lang.String referenceUri)
Checks if a resource type is viewable for the current user.void
configureCreateNewElement(CmsObject cms, java.lang.String pageFolderRootPath, CmsNewResourceBuilder builder)
Similar to createNewElement, but just sets parameters on a resource builder instead of actually creating the resource.protected CmsResourceTypeConfig
copy()
Creates a shallow copy of this resource type configuration object.protected CmsResourceTypeConfig
copy(boolean disabled)
Creates a shallow copy of this resource type configuration object.CmsResource
createNewElement(CmsObject userCms, java.lang.String pageFolderRootPath)
Creates a new element.CmsResource
createNewElement(CmsObject userCms, CmsResource modelResource, java.lang.String pageFolderRootPath)
Creates a new element.CmsResourceTypeConfig.AddMenuVisibility
getAddMenuVisibility(CmsUUID elementViewId, CmsResourceTypeConfig.AddMenuType menuType)
Gets the visibility status in the 'add' menu for this type and the given element view.java.lang.String
getConfiguredWorkplaceBundle()
Returns the bundle that is configured as workplace bundle for the resource type, ornull
if none is configured.CmsCntPageData.ElementDeleteMode
getElementDeleteMode()
Gets the element delete mode.CmsUUID
getElementView()
Returns the element view id.protected CmsContentFolderDescriptor
getFolderOrName()
Returns the folder bean from the configuration.java.lang.String
getFolderPath(CmsObject cms, java.lang.String pageFolderRootPath)
Computes the folder path for this resource type.java.lang.String
getKey()
The name of the configuration object.protected java.lang.String
getNamePattern()
Gets the configured name pattern.java.lang.String
getNamePattern(boolean useDefaultIfEmpty)
Gets the name pattern.int
getOrder()
Returns the number used for sorting module resource types.java.lang.Integer
getOrderObject()
Returns the order as an object (or null if it's not set).I_CmsResourceType
getType()
Gets the actual resource type for which this is a configuration.java.lang.String
getTypeName()
Returns the type name.void
initialize(CmsObject cms)
Initializes this instance.boolean
isAddDisabled()
Returns true if adding elements of this type via ADE should be disabled.boolean
isAvailableInTemplate(java.lang.String template)
Checks if the type can be used for the given template context key.boolean
isCopyInModels()
Returns if elements of this type when used in models should be copied instead of reused.boolean
isCreateDisabled()
Returns whether creating elements of this type via ADE should be disabled.boolean
isDetailPagesDisabled()
True if the detail page creation should be disabled for this resource type.boolean
isDisabled()
If true, this configuration object will disable an inherited configuration object of the same name.boolean
isEditDisabled()
Checks if editing should be disabled for container elements of this type.boolean
isEnabledInLists()
Checks if creating and editing resources of this type should be possible via the edit buttons generated by lists.boolean
isPageRelative()
Returns true if this resource type is configured as 'page relative', i.e.boolean
isShowInDefaultView()
Returns true if the type should be shown in the default view if it is not assigned to it.CmsResourceTypeConfig
markWithTemplate(java.lang.String template)
If 'template' is not null, returns a copy of this type bean, but adds 'template' to the set of supported templates in the copy.CmsResourceTypeConfig
merge(CmsResourceTypeConfig childConfig)
Merges this configuration object with a child configuration object.protected CmsObject
rootCms(CmsObject cms)
Creates a new CMS object based on existing one and changes its site root to the site root.java.lang.String
toString()
protected void
tryToUnlock(CmsObject cms, java.lang.String folderPath)
Tries to remove a lock on an ancestor of a given path owned by the current user.protected void
updateBasePath(java.lang.String basePath)
Updates the base path for the folder information.
-
-
-
Constructor Detail
-
CmsResourceTypeConfig
public CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsContentFolderDescriptor folder, java.lang.String pattern)
Creates a new resource type configuration.- Parameters:
typeName
- the resource type namedisabled
- true if this is a disabled configurationfolder
- the folder referencepattern
- the name pattern
-
CmsResourceTypeConfig
public CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsContentFolderDescriptor folder, java.lang.String pattern, boolean detailPagesDisabled, boolean addDisabled, boolean createDisabled, boolean editDisabled, boolean enableInLists, boolean availabilityNotSet, CmsUUID elementView, java.lang.String localization, java.lang.Boolean showInDefaultView, java.lang.Boolean copyInModels, java.lang.Integer order, CmsCntPageData.ElementDeleteMode elementDeleteMode)
Creates a new resource type configuration.- Parameters:
typeName
- the resource type namedisabled
- true if this is a disabled configurationfolder
- the folder referencepattern
- the name patterndetailPagesDisabled
- true if detail page creation should be disabled for this typeaddDisabled
- true if adding elements of this type via ADE should be disablededitDisabled
- true if editing container elements of the type should be disabledenableInLists
- true if the type should be enabled, but only for the direct edit buttons in lists and not ADE/drag/drop.createDisabled
- true if creating elements of this type via ADE should be disabledavailabilityNotSet
- true if the availability has not been setelementView
- the element view idlocalization
- the base name of the bundle to add as workplace bundle for the resource typeshowInDefaultView
- if true, the element type should be shown in the default element view even if it doesn't belong to itcopyInModels
- if elements of this type when used in models should be copied instead of reusedorder
- the display orderelementDeleteMode
- the element delete mode
-
-
Method Detail
-
checkCreatable
public boolean checkCreatable(CmsObject cms, java.lang.String pageFolderRootPath) throws CmsException
Checks if this resource type is creatable.- Parameters:
cms
- the current CMS contextpageFolderRootPath
- the root path of the folder containing the current container page- Returns:
true
if the resource type is creatable- Throws:
CmsException
- if something goes wrong
-
checkInitialized
public void checkInitialized()
Checks whether the object is initialized and throws an exception otherwise.
-
checkOffline
public void checkOffline(CmsObject cms)
Checks whether the cms context is in the offline project and throws an exception otherwise.- Parameters:
cms
- the cms context
-
checkViewable
public boolean checkViewable(CmsObject cms, java.lang.String referenceUri)
Checks if a resource type is viewable for the current user. If not, this resource type should not be available at all within the ADE 'add-wizard'.- Parameters:
cms
- the current CMS contextreferenceUri
- the resource URI to check permissions for- Returns:
true
if the resource type is viewable
-
configureCreateNewElement
public void configureCreateNewElement(CmsObject cms, java.lang.String pageFolderRootPath, CmsNewResourceBuilder builder) throws CmsException
Similar to createNewElement, but just sets parameters on a resource builder instead of actually creating the resource.- Parameters:
cms
- the CMS contextpageFolderRootPath
- the page folder root pathbuilder
- the resource builder- Throws:
CmsException
- if something goes wrong
-
createNewElement
public CmsResource createNewElement(CmsObject userCms, CmsResource modelResource, java.lang.String pageFolderRootPath) throws CmsException
Creates a new element.- Parameters:
userCms
- the CMS context to usemodelResource
- the model resource to usepageFolderRootPath
- the root path of the folder containing the current container page- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrong
-
createNewElement
public CmsResource createNewElement(CmsObject userCms, java.lang.String pageFolderRootPath) throws CmsException
Creates a new element.- Parameters:
userCms
- the CMS context to usepageFolderRootPath
- root path of the folder containing the current container page- Returns:
- the created resource
- Throws:
CmsException
- if something goes wrong
-
getAddMenuVisibility
public CmsResourceTypeConfig.AddMenuVisibility getAddMenuVisibility(CmsUUID elementViewId, CmsResourceTypeConfig.AddMenuType menuType)
Gets the visibility status in the 'add' menu for this type and the given element view.- Parameters:
elementViewId
- the id of the view for which to compute the visibility statusmenuType
- the menu type for which we want to evaluate the visibility- Returns:
- the visibility status
-
getConfiguredWorkplaceBundle
public java.lang.String getConfiguredWorkplaceBundle()
Returns the bundle that is configured as workplace bundle for the resource type, ornull
if none is configured.- Returns:
- the bundle that is configured as workplace bundle for the resource type, or
null
if none is configured.
-
getElementDeleteMode
public CmsCntPageData.ElementDeleteMode getElementDeleteMode()
Gets the element delete mode.- Returns:
- the element delete mode
-
getElementView
public CmsUUID getElementView()
Returns the element view id.- Returns:
- the element view id
-
getFolderPath
public java.lang.String getFolderPath(CmsObject cms, java.lang.String pageFolderRootPath)
Computes the folder path for this resource type.- Parameters:
cms
- the cms context to usepageFolderRootPath
- root path of the folder containing the current container page- Returns:
- the folder root path for this resource type
-
getKey
public java.lang.String getKey()
Description copied from interface:I_CmsConfigurationObject
The name of the configuration object.This name should be unique for each single configuration
- Specified by:
getKey
in interfaceI_CmsConfigurationObject<CmsResourceTypeConfig>
- Returns:
- the name
- See Also:
I_CmsConfigurationObject.getKey()
-
getNamePattern
public java.lang.String getNamePattern(boolean useDefaultIfEmpty)
Gets the name pattern.- Parameters:
useDefaultIfEmpty
- if true, uses a default value if the name pattern isn't set directly- Returns:
- the name pattern
-
getOrder
public int getOrder()
Returns the number used for sorting module resource types.- Returns:
- the number used for sorting module resource types
-
getOrderObject
public java.lang.Integer getOrderObject()
Returns the order as an object (or null if it's not set).- Returns:
- the order
-
getType
public I_CmsResourceType getType() throws CmsException
Gets the actual resource type for which this is a configuration.- Returns:
- the actual resource type
- Throws:
CmsException
- if something goes wrong
-
getTypeName
public java.lang.String getTypeName()
Returns the type name.- Returns:
- the type name
-
isAvailableInTemplate
public boolean isAvailableInTemplate(java.lang.String template)
Checks if the type can be used for the given template context key.If this type isn't specifically associated with one or more template keys, this returns true, otherwise it will check if the 'template' argument is among the template keys
- Parameters:
template
- the template key to check- Returns:
- true if the type should be available for the template
-
initialize
public void initialize(CmsObject cms)
Initializes this instance.- Parameters:
cms
- the CMS context to use
-
isAddDisabled
public boolean isAddDisabled()
Returns true if adding elements of this type via ADE should be disabled.- Returns:
- true if elements of this type shouldn't be added to the page
-
isCopyInModels
public boolean isCopyInModels()
Returns if elements of this type when used in models should be copied instead of reused.- Returns:
- if elements of this type when used in models should be copied instead of reused
-
isCreateDisabled
public boolean isCreateDisabled()
Returns whether creating elements of this type via ADE should be disabled.- Returns:
true
if creating elements of this type via ADE should be disabled
-
isDetailPagesDisabled
public boolean isDetailPagesDisabled()
True if the detail page creation should be disabled for this resource type.- Returns:
- true if detail page creation should be disabled for this type
-
isDisabled
public boolean isDisabled()
Description copied from interface:I_CmsConfigurationObject
If true, this configuration object will disable an inherited configuration object of the same name.- Specified by:
isDisabled
in interfaceI_CmsConfigurationObject<CmsResourceTypeConfig>
- Returns:
- true if this configuration object is marked as "disabled"
- See Also:
I_CmsConfigurationObject.isDisabled()
-
isEditDisabled
public boolean isEditDisabled()
Checks if editing should be disabled for container elements of this type.- Returns:
- true if editing should be disabled for container elements of this type
-
isEnabledInLists
public boolean isEnabledInLists()
Checks if creating and editing resources of this type should be possible via the edit buttons generated by lists.- Returns:
- true if creating/editing resources of this type in lists should be possible
-
isPageRelative
public boolean isPageRelative()
Returns true if this resource type is configured as 'page relative', i.e. elements of this type are to be stored with the container page on which they were created.- Returns:
- true if this is a page relative type configuration
-
isShowInDefaultView
public boolean isShowInDefaultView()
Returns true if the type should be shown in the default view if it is not assigned to it.This defaults to 'false' if not set.
- Returns:
- true if the type should be shown in the default view event if it doens't belong to that element view
-
markWithTemplate
public CmsResourceTypeConfig markWithTemplate(java.lang.String template)
If 'template' is not null, returns a copy of this type bean, but adds 'template' to the set of supported templates in the copy.- Parameters:
template
- a template context key- Returns:
- a new copy associated with the given template key
-
merge
public CmsResourceTypeConfig merge(CmsResourceTypeConfig childConfig)
Description copied from interface:I_CmsConfigurationObject
Merges this configuration object with a child configuration object.- Specified by:
merge
in interfaceI_CmsConfigurationObject<CmsResourceTypeConfig>
- Parameters:
childConfig
- the child configuration object- Returns:
- the merged configuration objects
- See Also:
I_CmsConfigurationObject.merge(org.opencms.ade.configuration.I_CmsConfigurationObject)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
copy
protected CmsResourceTypeConfig copy()
Creates a shallow copy of this resource type configuration object.- Returns:
- a copy of the resource type configuration object
-
copy
protected CmsResourceTypeConfig copy(boolean disabled)
Creates a shallow copy of this resource type configuration object.- Parameters:
disabled
- true if the copy should be disabled regardless of whether the original is disabled- Returns:
- a copy of the resource type configuration object
-
getFolderOrName
protected CmsContentFolderDescriptor getFolderOrName()
Returns the folder bean from the configuration.Normally, you should use getFolderPath() instead.
- Returns:
- the folder bean from the configuration
-
getNamePattern
protected java.lang.String getNamePattern()
Gets the configured name pattern.- Returns:
- the configured name pattern
-
rootCms
protected CmsObject rootCms(CmsObject cms) throws CmsException
Creates a new CMS object based on existing one and changes its site root to the site root.- Parameters:
cms
- the CMS context- Returns:
- the root site CMS context
- Throws:
CmsException
- if something goes wrong
-
tryToUnlock
protected void tryToUnlock(CmsObject cms, java.lang.String folderPath) throws CmsException
Tries to remove a lock on an ancestor of a given path owned by the current user.- Parameters:
cms
- the CMS contextfolderPath
- the path for which the lock should be removed- Throws:
CmsException
- if something goes wrong
-
updateBasePath
protected void updateBasePath(java.lang.String basePath)
Updates the base path for the folder information.- Parameters:
basePath
- the new base path
-
-