Package org.opencms.ade.configuration
Class CmsResourceTypeConfig
java.lang.Object
org.opencms.ade.configuration.CmsResourceTypeConfig
- All Implemented Interfaces:
Cloneable
,I_CmsConfigurationObject<CmsResourceTypeConfig>
public class CmsResourceTypeConfig
extends Object
implements I_CmsConfigurationObject<CmsResourceTypeConfig>, Cloneable
The configuration for a single resource type.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum used to distinguish the type of menu in which a configured resource type can be displayed.static enum
Represents the visibility status of a resource type in the 'Add' menu of the container page editor. -
Field Summary
Fields inherited from interface org.opencms.ade.configuration.I_CmsConfigurationObject
DEFAULT_ORDER
-
Constructor Summary
ConstructorDescriptionCmsResourceTypeConfig
(String typeName, boolean disabled, CmsContentFolderDescriptor folder, String pattern) Creates a new resource type configuration.CmsResourceTypeConfig
(String typeName, boolean disabled, CmsContentFolderDescriptor folder, String pattern, boolean detailPagesDisabled, boolean addDisabled, boolean createDisabled, boolean editDisabled, boolean enableInLists, boolean availabilityNotSet, CmsUUID elementView, String localization, Boolean showInDefaultView, Boolean copyInModels, Integer order, CmsCntPageData.ElementDeleteMode elementDeleteMode, Boolean checkReuse) Creates a new resource type configuration. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkCreatable
(CmsObject cms, String pageFolderRootPath) Checks if this resource type is creatable.void
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, String referenceUri) Checks if a resource type is viewable for the current user.void
configureCreateNewElement
(CmsObject cms, 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.createNewElement
(CmsObject userCms, String pageFolderRootPath) Creates a new element.createNewElement
(CmsObject userCms, CmsResource modelResource, String pageFolderRootPath) Creates a new element.getAddMenuVisibility
(CmsUUID elementViewId, CmsResourceTypeConfig.AddMenuType menuType) Gets the visibility status in the 'add' menu for this type and the given element view.Gets the 'check reuse' value, without applying the default value.Returns the bundle that is configured as workplace bundle for the resource type, ornull
if none is configured.Gets the element delete mode.Returns the element view id.protected CmsContentFolderDescriptor
Returns the folder bean from the configuration.getFolderPath
(CmsObject cms, String pageFolderRootPath) Computes the folder path for this resource type.getKey()
The name of the configuration object.protected String
Gets the configured name pattern.getNamePattern
(boolean useDefaultIfEmpty) Gets the name pattern.int
getOrder()
Returns the number used for sorting module resource types.Returns the order as an object (or null if it's not set).getType()
Gets the actual resource type for which this is a configuration.Returns the type name.void
initialize
(CmsObject cms) Initializes this instance.boolean
Returns true if adding elements of this type via ADE should be disabled.boolean
isAvailableInTemplate
(String template) Checks if the type can be used for the given template context key.boolean
Returns true if reuse should be checked for elements of this type.boolean
Returns if elements of this type when used in models should be copied instead of reused.boolean
Returns whether creating elements of this type via ADE should be disabled.boolean
True if the detail page creation should be disabled for this resource type.boolean
If true, this configuration object will disable an inherited configuration object of the same name.boolean
Checks if editing should be disabled for container elements of this type.boolean
Checks if creating and editing resources of this type should be possible via the edit buttons generated by lists.boolean
Returns true if this resource type is configured as 'page relative', i.e.boolean
Returns true if the type should be shown in the default view if it is not assigned to it.markWithTemplate
(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.merge
(CmsResourceTypeConfig childConfig) Merges this configuration object with a child configuration object.protected CmsObject
Creates a new CMS object based on existing one and changes its site root to the site root.toString()
protected void
tryToUnlock
(CmsObject cms, String folderPath) Tries to remove a lock on an ancestor of a given path owned by the current user.protected void
updateBasePath
(String basePath) Updates the base path for the folder information.
-
Field Details
-
m_cms
The CMS object used for VFS operations.
-
-
Constructor Details
-
CmsResourceTypeConfig
public CmsResourceTypeConfig(String typeName, boolean disabled, CmsContentFolderDescriptor folder, 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
-
-
Method Details
-
checkCreatable
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
Checks whether the object is initialized and throws an exception otherwise. -
checkOffline
Checks whether the cms context is in the offline project and throws an exception otherwise.- Parameters:
cms
- the cms context
-
checkViewable
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, 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, 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, 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
-
getCheckReuseObj
Gets the 'check reuse' value, without applying the default value.The return value may be null if this is not set.
- Returns:
- the value of the 'check reuse' option
-
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
Gets the element delete mode.- Returns:
- the element delete mode
-
getElementView
Returns the element view id.- Returns:
- the element view id
-
getFolderPath
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
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:
-
getNamePattern
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
Returns the number used for sorting module resource types.- Returns:
- the number used for sorting module resource types
-
getOrderObject
Returns the order as an object (or null if it's not set).- Returns:
- the order
-
getType
Gets the actual resource type for which this is a configuration.- Returns:
- the actual resource type
- Throws:
CmsException
- if something goes wrong
-
getTypeName
Returns the type name.- Returns:
- the type name
-
initialize
Initializes this instance.- Parameters:
cms
- the CMS context to use
-
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
-
isAvailableInTemplate
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
-
isCheckReuse
Returns true if reuse should be checked for elements of this type.This tries to use the value configured for this type first, and if it doesn't have one, returns the global default.
- Returns:
- true if reuse should be checked for this type
-
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
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
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
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:
-
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
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
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
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
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
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:
-
toString
-
copy
Creates a shallow copy of this resource type configuration object.- Returns:
- a copy of the resource type configuration object
-
copy
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
Returns the folder bean from the configuration.Normally, you should use getFolderPath() instead.
- Returns:
- the folder bean from the configuration
-
getNamePattern
Gets the configured name pattern.- Returns:
- the configured name pattern
-
rootCms
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
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
Updates the base path for the folder information.- Parameters:
basePath
- the new base path
-