org.opencms.ade.configuration
Class CmsResourceTypeConfig

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

public class CmsResourceTypeConfig
extends java.lang.Object
implements I_CmsConfigurationObject<CmsResourceTypeConfig>

The configuration for a single resource type.


Field Summary
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
CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsFolderOrName folder, java.lang.String pattern, CmsFormatterConfiguration formatterConfig)
          Creates a new resource type configuration.
CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsFolderOrName folder, java.lang.String pattern, CmsFormatterConfiguration formatterConfig, boolean detailPagesDisabled, int order)
          Creates a new resource type configuration.
CmsResourceTypeConfig(java.lang.String typeName, boolean disabled, CmsFolderOrName folder, java.lang.String pattern, CmsFormatterConfiguration formatterConfig, int order)
          Creates a new resource type configuration.
 
Method Summary
 boolean checkCreatable(CmsObject cms)
          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.
protected  CmsResourceTypeConfig copy()
          Creates a shallow copy of this resource type configuration object.
 void createFolder(CmsObject cms, java.lang.String rootPath)
          Creates a folder and its parent folders if they don't exist.
 CmsResource createNewElement(CmsObject userCms)
          Creates a new element.
 CmsResource createNewElement(CmsObject userCms, CmsResource modelResource)
          Creates a new element.
protected  CmsFolderOrName getFolderOrName()
          Returns the folder bean from the configuration.
 java.lang.String getFolderPath(CmsObject cms)
          Computes the folder path for this resource type.
protected  CmsFormatterConfiguration getFormatterConfiguration()
          Gets the formatter configuration of 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.
 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 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.
 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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_cms

protected CmsObject m_cms
The CMS object used for VFS operations.

Constructor Detail

CmsResourceTypeConfig

public CmsResourceTypeConfig(java.lang.String typeName,
                             boolean disabled,
                             CmsFolderOrName folder,
                             java.lang.String pattern,
                             CmsFormatterConfiguration formatterConfig)
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
formatterConfig - the formatter configuration

CmsResourceTypeConfig

public CmsResourceTypeConfig(java.lang.String typeName,
                             boolean disabled,
                             CmsFolderOrName folder,
                             java.lang.String pattern,
                             CmsFormatterConfiguration formatterConfig,
                             boolean detailPagesDisabled,
                             int order)
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
formatterConfig - the formatter configuration
detailPagesDisabled - true if detail page creation should be disabled for this type
order - the number used for sorting resource types from modules

CmsResourceTypeConfig

public CmsResourceTypeConfig(java.lang.String typeName,
                             boolean disabled,
                             CmsFolderOrName folder,
                             java.lang.String pattern,
                             CmsFormatterConfiguration formatterConfig,
                             int order)
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
formatterConfig - the formatter configuration
order - the number used for sorting resource types from modules
Method Detail

checkCreatable

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

Parameters:
cms - the current CMS context
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 -

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 context
referenceUri - the resource URI to check permissions for
Returns:
true if the resource type is viewable

createFolder

public void createFolder(CmsObject cms,
                         java.lang.String rootPath)
                  throws CmsException
Creates a folder and its parent folders if they don't exist.

Parameters:
cms - the CMS context to use
rootPath - the folder root path
Throws:
CmsException - if something goes wrong

createNewElement

public CmsResource createNewElement(CmsObject userCms)
                             throws CmsException
Creates a new element.

Parameters:
userCms - the CMS context to use
Returns:
the created resource
Throws:
CmsException - if something goes wrong

createNewElement

public CmsResource createNewElement(CmsObject userCms,
                                    CmsResource modelResource)
                             throws CmsException
Creates a new element.

Parameters:
userCms - the CMS context to use
modelResource - the model resource to use
Returns:
the created resource
Throws:
CmsException - if something goes wrong

getFolderPath

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

Parameters:
cms - the cms context to use
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 interface I_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

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

initialize

public void initialize(CmsObject cms)
Initializes this instance.

Parameters:
cms - the CMS context to use

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:
I_CmsConfigurationObject.isDisabled()

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 interface I_CmsConfigurationObject<CmsResourceTypeConfig>
Parameters:
childConfig - the child configuration object
Returns:
the merged configuration objects
See Also:
I_CmsConfigurationObject.merge(org.opencms.ade.configuration.I_CmsConfigurationObject)

copy

protected CmsResourceTypeConfig copy()
Creates a shallow copy of this resource type configuration object.

Returns:
a copy of the resource type configuration object

getFolderOrName

protected CmsFolderOrName getFolderOrName()
Returns the folder bean from the configuration.

Normally, you should use getFolderPath() instead.

Returns:
the folder bean from the configuration

getFormatterConfiguration

protected CmsFormatterConfiguration getFormatterConfiguration()
Gets the formatter configuration of this resource type.

Returns:
the formatter configuration of this resource type

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 context
folderPath - 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