Class CmsResourceTypeConfig

java.lang.Object
org.opencms.ade.configuration.CmsResourceTypeConfig
All Implemented Interfaces:
Cloneable, I_CmsConfigurationObject<CmsResourceTypeConfig>

The configuration for a single resource type.

  • Field Details

    • m_cms

      protected CmsObject 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 name
      disabled - true if this is a disabled configuration
      folder - the folder reference
      pattern - the name pattern
    • CmsResourceTypeConfig

      public 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.

      Parameters:
      typeName - the resource type name
      disabled - true if this is a disabled configuration
      folder - the folder reference
      pattern - the name pattern
      detailPagesDisabled - true if detail page creation should be disabled for this type
      addDisabled - true if adding elements of this type via ADE should be disabled
      editDisabled - true if editing container elements of the type should be disabled
      enableInLists - 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 disabled
      availabilityNotSet - true if the availability has not been set
      elementView - the element view id
      localization - the base name of the bundle to add as workplace bundle for the resource type
      showInDefaultView - if true, the element type should be shown in the default element view even if it doesn't belong to it
      copyInModels - if elements of this type when used in models should be copied instead of reused
      order - the display order
      elementDeleteMode - the element delete mode
      checkReuse - indicates whether element reuse should be checked for this type
  • Method Details

    • checkCreatable

      public boolean checkCreatable(CmsObject cms, String pageFolderRootPath) throws CmsException
      Checks if this resource type is creatable.

      Parameters:
      cms - the current CMS context
      pageFolderRootPath - 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, 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 context
      referenceUri - 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 context
      pageFolderRootPath - the page folder root path
      builder - 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 use
      modelResource - the model resource to use
      pageFolderRootPath - 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 use
      pageFolderRootPath - root path of the folder containing the current container page
      Returns:
      the created resource
      Throws:
      CmsException - if something goes wrong
    • getAddMenuVisibility

      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 status
      menuType - 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, or null 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

      public String getFolderPath(CmsObject cms, String pageFolderRootPath)
      Computes the folder path for this resource type.

      Parameters:
      cms - the cms context to use
      pageFolderRootPath - root path of the folder containing the current container page
      Returns:
      the folder root path for this resource type
    • getKey

      public 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 interface I_CmsConfigurationObject<CmsResourceTypeConfig>
      Returns:
      the name
      See Also:
    • getNamePattern

      public 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

      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

      public String getTypeName()
      Returns the type name.

      Returns:
      the type name
    • 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
    • isAvailableInTemplate

      public boolean isAvailableInTemplate(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
    • isCheckReuse

      public boolean 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

      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 interface I_CmsConfigurationObject<CmsResourceTypeConfig>
      Returns:
      true if this configuration object is marked as "disabled"
      See Also:
    • 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

      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 interface I_CmsConfigurationObject<CmsResourceTypeConfig>
      Parameters:
      childConfig - the child configuration object
      Returns:
      the merged configuration objects
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • 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

      Returns the folder bean from the configuration.

      Normally, you should use getFolderPath() instead.

      Returns:
      the folder bean from the configuration
    • getNamePattern

      protected 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, 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 context
      folderPath - the path for which the lock should be removed
      Throws:
      CmsException - if something goes wrong
    • updateBasePath

      protected void updateBasePath(String basePath)
      Updates the base path for the folder information.

      Parameters:
      basePath - the new base path