org.opencms.file.types
Class A_CmsResourceType

java.lang.Object
  extended byorg.opencms.file.types.A_CmsResourceType
All Implemented Interfaces:
I_CmsConfigurationParameterHandler, I_CmsResourceType
Direct Known Subclasses:
A_CmsResourceTypeFolderBase, A_CmsResourceTypeLinkParseable, CmsResourceTypeBinary, CmsResourceTypeImage, CmsResourceTypePlain, CmsResourceTypePointer, CmsResourceTypeUnknown, CmsResourceTypeUnknownFile

public abstract class A_CmsResourceType
extends java.lang.Object
implements I_CmsResourceType

Base implementation for resource type classes.

Since:
6.0.0
Version:
$Revision: 1.51 $
Author:
Alexander Kandzior, Thomas Weckert

Field Summary
static java.lang.String CONFIGURATION_INTERNAL
          Configuration key for the (optional) internal flag.
protected  boolean m_addititionalModuleResourceType
          Flag for showing that this is an additional resource type which defined in a module.
protected  java.lang.String m_className
          The configured class name of this resource type.
protected  java.util.List m_copyResources
          The list of resources to copy.
protected  java.util.List m_defaultProperties
          The list of configured default properties.
protected  boolean m_frozen
          Indicates that the configuration of the resource type has been frozen.
protected  java.util.List m_mappings
          Contains the file extensions mapped to this resource type.
protected  int m_typeId
          The configured id of this resource type.
protected  java.lang.String m_typeName
          The configured name of this resource type.
static java.lang.String MACRO_RESOURCE_FOLDER_PATH
          Macro for the folder path of the current resource.
static java.lang.String MACRO_RESOURCE_NAME
          Macro for the name of the current resource.
static java.lang.String MACRO_RESOURCE_PARENT_PATH
          Macro for the parent folder path of the current resource.
static java.lang.String MACRO_RESOURCE_ROOT_PATH
          Macro for the root path of the current resource.
static java.lang.String MACRO_RESOURCE_SITE_PATH
          Macro for the site path of the current resource.
 
Fields inherited from interface org.opencms.file.types.I_CmsResourceType
ADD_MAPPING_METHOD, ADD_RESOURCE_TYPE_METHOD, CONFIGURATION_PROPERTY_CREATE, CONFIGURATION_RESOURCE_TYPE_ID, CONFIGURATION_RESOURCE_TYPE_NAME, PROPERTY_ON_RESOURCE, PROPERTY_ON_STRUCTURE
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
A_CmsResourceType()
          Default constructor, used to initialize some member variables.
 
Method Summary
 void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 void addCopyResource(java.lang.String source, java.lang.String target, java.lang.String type)
          Adds a new "copy resource" to this resource type, allowed only during the configuration phase.
 void addDefaultProperty(CmsProperty property)
          Adds a default property to this resource type, allowed only during the configuration phase.
 void addMappingType(java.lang.String mapping)
          Maps a file extension to a resource type.
 void changeLock(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
          Changes the lock of a resource to the current user, that is "steals" the lock from another user.
 void chflags(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int flags)
          Changes the resource flags of a resource.
 void chtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type)
          Changes the resource type of a resource.
 void copyResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, java.lang.String destination, CmsResource.CmsResourceCopyMode siblingMode)
          Copies a resource.
 void copyResourceToProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
          Copies a resource to the current project of the user.
protected  CmsResource createRelations(CmsObject cms, CmsSecurityManager securityManager, java.lang.String resourceName)
          Creates the relation information for the resource with the given resource name.
 CmsResource createResource(CmsObject cms, CmsSecurityManager securityManager, java.lang.String resourcename, byte[] content, java.util.List properties)
          Creates a new resource of the given resource type with the provided content and properties.
 CmsResource createSibling(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, java.lang.String destination, java.util.List properties)
          Creates a new sibling of the source resource.
 void deleteResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsResource.CmsResourceDeleteMode siblingMode)
          Deletes a resource given its name.
 boolean equals(java.lang.Object obj)
          Returns true, if this resource type is equal to the given Object.
 java.lang.String getCachePropertyDefault()
          Returns the default for the cache property setting of this resource type.
 java.lang.String getClassName()
          Returns the configured class name of this resource type.
 java.util.Map getConfiguration()
          Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.
 java.util.List getConfiguredCopyResources()
          Returns the (unmodifiable) list of copy resources.
 java.util.List getConfiguredDefaultProperties()
          Returns the default properties for this resource type in an unmodifiable List.
 java.util.List getConfiguredMappings()
          Returns the file extensions mappings for this resource type in an unmodifiable List.
abstract  int getLoaderId()
          Returns the loader type id of this resource type.
protected  CmsMacroResolver getMacroResolver(CmsObject cms, java.lang.String resourcename)
          Creates a macro resolver based on the current users OpenCms context and the provided resource name.
protected  I_CmsResourceType getResourceType(CmsResource resource)
          Convenience method to get the initialized resource type instance for the given resource, with a fall back to special "unknown" resource types in case the resource type is not configured.
 int getTypeId()
          Returns the type id of this resource type.
 java.lang.String getTypeName()
          Returns the name of this resource type.
 int hashCode()
          The hash code implementation simply returns the unique type id of this resource type.
 CmsResource importResource(CmsObject cms, CmsSecurityManager securityManager, java.lang.String resourcename, CmsResource resource, byte[] content, java.util.List properties)
          Imports a resource to the OpenCms VFS.
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
 void initConfiguration(java.lang.String name, java.lang.String id)
          Deprecated. use initConfiguration(String, String, String) instead
 void initConfiguration(java.lang.String name, java.lang.String id, java.lang.String className)
          Special version of the configuration initialization used with resource types to set resource type, id and class name, required for the XML configuration.
 void initialize(CmsObject cms)
          Initializes this resource type.
 boolean isAdditionalModuleResourceType()
          Indicates that this is an additional resource type which is defined in a module.
 boolean isDirectEditable()
          Returns true if this resource type is direct editable.
 boolean isFolder()
          Returns true if this resource type is a folder.
 boolean isIdentical(I_CmsResourceType type)
          Tests if the given resource type definition is identical to this resource type definition.
 void lockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsLockType type)
          Locks a resource.
 void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, java.lang.String destination)
          Moves a resource to the given destination.
protected  void processCopyResources(CmsObject cms, java.lang.String resourcename, CmsMacroResolver resolver)
          Processes the copy resources of this resource type.
protected  java.util.List processDefaultProperties(java.util.List properties, CmsMacroResolver resolver)
          Returns a list of property objects that are attached to the resource on creation.
 void removeResourceFromProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
          Removes a resource from the current project of the user.
 void replaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type, byte[] content, java.util.List properties)
          Replaces the content, type and properties of a resource.
 void restoreResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version)
          Restores a resource in the current project with a version from the historical archive.
 void restoreResourceBackup(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version)
          Restores a file in the current project with a version from the historical archive.
 void setAdditionalModuleResourceType(boolean additionalType)
          Sets the additional resource type flag.
 void setDateExpired(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateExpired, boolean recursive)
          Changes the "expire" date of a resource.
 void setDateLastModified(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateLastModified, boolean recursive)
          Changes the "last modified" date of a resource.
 void setDateReleased(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateReleased, boolean recursive)
          Changes the "release" date of a resource.
 java.lang.String toString()
           
 void undelete(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, boolean recursive)
          Undeletes a resource.
 void undoChanges(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsResource.CmsResourceUndoMode mode)
          Undos all changes in the resource by restoring the version from the online project to the current offline project.
 void unlockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
          Unlocks a resource.
protected  void updateRelationForUndo(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource)
          Update the relations after an undo changes operation.
 CmsFile writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource)
          Writes a resource, including it's content.
 void writePropertyObject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsProperty property)
          Writes a property for a specified resource.
 void writePropertyObjects(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, java.util.List properties)
          Writes a list of properties for a specified resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIGURATION_INTERNAL

public static final java.lang.String CONFIGURATION_INTERNAL
Configuration key for the (optional) internal flag.

See Also:
Constant Field Values

MACRO_RESOURCE_FOLDER_PATH

public static final java.lang.String MACRO_RESOURCE_FOLDER_PATH
Macro for the folder path of the current resource.

See Also:
Constant Field Values

MACRO_RESOURCE_NAME

public static final java.lang.String MACRO_RESOURCE_NAME
Macro for the name of the current resource.

See Also:
Constant Field Values

MACRO_RESOURCE_PARENT_PATH

public static final java.lang.String MACRO_RESOURCE_PARENT_PATH
Macro for the parent folder path of the current resource.

See Also:
Constant Field Values

MACRO_RESOURCE_ROOT_PATH

public static final java.lang.String MACRO_RESOURCE_ROOT_PATH
Macro for the root path of the current resource.

See Also:
Constant Field Values

MACRO_RESOURCE_SITE_PATH

public static final java.lang.String MACRO_RESOURCE_SITE_PATH
Macro for the site path of the current resource.

See Also:
Constant Field Values

m_addititionalModuleResourceType

protected boolean m_addititionalModuleResourceType
Flag for showing that this is an additional resource type which defined in a module.


m_className

protected java.lang.String m_className
The configured class name of this resource type.


m_copyResources

protected java.util.List m_copyResources
The list of resources to copy.


m_defaultProperties

protected java.util.List m_defaultProperties
The list of configured default properties.


m_frozen

protected boolean m_frozen
Indicates that the configuration of the resource type has been frozen.


m_mappings

protected java.util.List m_mappings
Contains the file extensions mapped to this resource type.


m_typeId

protected int m_typeId
The configured id of this resource type.


m_typeName

protected java.lang.String m_typeName
The configured name of this resource type.

Constructor Detail

A_CmsResourceType

public A_CmsResourceType()
Default constructor, used to initialize some member variables.

Method Detail

addConfigurationParameter

public void addConfigurationParameter(java.lang.String paramName,
                                      java.lang.String paramValue)
Description copied from interface: I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.

Specified by:
addConfigurationParameter in interface I_CmsConfigurationParameterHandler
Parameters:
paramName - the name of the parameter
paramValue - the value for the parameter
See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)

addCopyResource

public void addCopyResource(java.lang.String source,
                            java.lang.String target,
                            java.lang.String type)
                     throws CmsConfigurationException
Adds a new "copy resource" to this resource type, allowed only during the configuration phase.

The "copy resources" are copied to the specified location after a new resource of this type is created. Usually this feature is used to populate a newly created folder with some default resources.

If target is null, the macro MACRO_RESOURCE_FOLDER_PATH is used as default. If type is null, the copy type CmsResource.COPY_AS_NEW is used as default.

Parameters:
source - the source resource
target - the target resource (may contain macros)
type - the type of the copy, for example "as new", "as sibling" etc
Throws:
CmsConfigurationException - if the configuration is already frozen

addDefaultProperty

public void addDefaultProperty(CmsProperty property)
                        throws CmsConfigurationException
Adds a default property to this resource type, allowed only during the configuration phase.

Parameters:
property - the default property to add
Throws:
CmsConfigurationException - if the configuration is already frozen

addMappingType

public void addMappingType(java.lang.String mapping)
Description copied from interface: I_CmsResourceType
Maps a file extension to a resource type.

When uploading files into OpenCms, they must be mapped to the different OpenCms resource types. The configuration, to map which extension to which resouce type is done in the OpenCms VFS configuration.

Specified by:
addMappingType in interface I_CmsResourceType
Parameters:
mapping - the file extension mapped to the resource type
See Also:
I_CmsResourceType.addMappingType(java.lang.String)

changeLock

public void changeLock(CmsObject cms,
                       CmsSecurityManager securityManager,
                       CmsResource resource)
                throws CmsException
Description copied from interface: I_CmsResourceType
Changes the lock of a resource to the current user, that is "steals" the lock from another user.

Specified by:
changeLock in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the name of the resource to change the lock with complete path
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.changeLock(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource)

chflags

public void chflags(CmsObject cms,
                    CmsSecurityManager securityManager,
                    CmsResource resource,
                    int flags)
             throws CmsException
Description copied from interface: I_CmsResourceType
Changes the resource flags of a resource.

The resource flags are used to indicate various "special" conditions for a resource. Most notably, the "internal only" setting which signals that a resource can not be directly requested with it's URL.

Specified by:
chflags in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to change the flags for
flags - the new resource flags for this resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.chflags(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)

chtype

public void chtype(CmsObject cms,
                   CmsSecurityManager securityManager,
                   CmsResource resource,
                   int type)
            throws CmsException
Description copied from interface: I_CmsResourceType
Changes the resource type of a resource.

OpenCms handles resources according to the resource type, not the file suffix. This is e.g. why a JSP in OpenCms can have the suffix ".html" instead of ".jsp" only. Changing the resource type makes sense e.g. if you want to make a plain text file a JSP resource, or a binary file an image, etc.

Specified by:
chtype in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to change the type for
type - the new resource type for this resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.chtype(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)

copyResource

public void copyResource(CmsObject cms,
                         CmsSecurityManager securityManager,
                         CmsResource source,
                         java.lang.String destination,
                         CmsResource.CmsResourceCopyMode siblingMode)
                  throws CmsException
Description copied from interface: I_CmsResourceType
Copies a resource.

You must ensure that the destination path is an absolute, valid and existing VFS path. Relative paths from the source are currently not supported.

The copied resource will always be locked to the current user after the copy operation.

In case the target resource already exists, it is overwritten with the source resource.

The siblingMode parameter controls how to handle siblings during the copy operation.
Possible values for this parameter are:

Specified by:
copyResource in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
source - the resource to copy
destination - the name of the copy destination with complete path
siblingMode - indicates how to handle siblings during copy
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.copyResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, java.lang.String, CmsResource.CmsResourceCopyMode)

copyResourceToProject

public void copyResourceToProject(CmsObject cms,
                                  CmsSecurityManager securityManager,
                                  CmsResource resource)
                           throws CmsException
Description copied from interface: I_CmsResourceType
Copies a resource to the current project of the user.

This is used to extend the current users project with the specified resource, in case that the resource is not yet part of the project. The resource is not really copied like in a regular copy operation, it is in fact only "enabled" in the current users project.

Specified by:
copyResourceToProject in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to apply this operation to
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.copyResourceToProject(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource)

createResource

public CmsResource createResource(CmsObject cms,
                                  CmsSecurityManager securityManager,
                                  java.lang.String resourcename,
                                  byte[] content,
                                  java.util.List properties)
                           throws CmsException
Description copied from interface: I_CmsResourceType
Creates a new resource of the given resource type with the provided content and properties.

Specified by:
createResource in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resourcename - the name of the resource to create (full path)
content - the content for the new resource
properties - the properties for the new resource
Returns:
the created resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.createResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, byte[], List)

createSibling

public CmsResource createSibling(CmsObject cms,
                                 CmsSecurityManager securityManager,
                                 CmsResource source,
                                 java.lang.String destination,
                                 java.util.List properties)
                          throws CmsException
Description copied from interface: I_CmsResourceType
Creates a new sibling of the source resource.

Specified by:
createSibling in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
source - the resource to create a sibling for
destination - the name of the sibling to create with complete path
properties - the individual properties for the new sibling
Returns:
the new created sibling
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.createSibling(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, CmsResource, java.lang.String, java.util.List)

deleteResource

public void deleteResource(CmsObject cms,
                           CmsSecurityManager securityManager,
                           CmsResource resource,
                           CmsResource.CmsResourceDeleteMode siblingMode)
                    throws CmsException
Description copied from interface: I_CmsResourceType
Deletes a resource given its name.

The siblingMode parameter controls how to handle siblings during the delete operation.
Possible values for this parameter are:

Specified by:
deleteResource in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to delete
siblingMode - indicates how to handle siblings of the deleted resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.deleteResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, CmsResource.CmsResourceDeleteMode)

equals

public boolean equals(java.lang.Object obj)
Returns true, if this resource type is equal to the given Object.

Please note: A resource type is identified by it's id getTypeId() and it's name getTypeName(). Two resource types are considered equal, if either their id or their name is equal. This is to prevent issues in the configuration with multiple occurrences of the same name or id.

Parameters:
obj - the Object to compare this resource type with
Returns:
true, if this resource type is equal to the given Object
See Also:
getTypeId(), getTypeName(), isIdentical(I_CmsResourceType), Object.equals(java.lang.Object)

getCachePropertyDefault

public java.lang.String getCachePropertyDefault()
Description copied from interface: I_CmsResourceType
Returns the default for the cache property setting of this resource type.

The cache property is used by the Flex cache implementation to build the cache key that controls the caching behaviour of a resource.

If null is returnd, this is the same as turning the cache off by default for this resource type.

Specified by:
getCachePropertyDefault in interface I_CmsResourceType
Returns:
the default for the cache property setting of this resource type
See Also:
I_CmsResourceType.getCachePropertyDefault()

getClassName

public java.lang.String getClassName()
Returns the configured class name of this resource type.

Specified by:
getClassName in interface I_CmsResourceType
Returns:
the class name configured for this resouce type
See Also:
I_CmsResourceType.getClassName()

getConfiguration

public java.util.Map getConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.

All elements in the configuration are key, value String pairs, set using the I_CmsConfigurationParameterHandler.addConfigurationParameter(String, String) method during initialization of the loader.

Implementations will (should) not to return a direct reference to the internal configuration but just a copy of it, to avoid unwanted external manipulation.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Returns:
the configuration of this resource loader, or null
See Also:
I_CmsConfigurationParameterHandler.getConfiguration()

getConfiguredCopyResources

public java.util.List getConfiguredCopyResources()
Returns the (unmodifiable) list of copy resources.

Specified by:
getConfiguredCopyResources in interface I_CmsResourceType
Returns:
the (unmodifiable) list of copy resources

getConfiguredDefaultProperties

public java.util.List getConfiguredDefaultProperties()
Returns the default properties for this resource type in an unmodifiable List.

Specified by:
getConfiguredDefaultProperties in interface I_CmsResourceType
Returns:
the default properties for this resource type in an unmodifiable List

getConfiguredMappings

public java.util.List getConfiguredMappings()
Description copied from interface: I_CmsResourceType
Returns the file extensions mappings for this resource type in an unmodifiable List.

Specified by:
getConfiguredMappings in interface I_CmsResourceType
Returns:
a list of file extensions mappings for this resource type in an unmodifiable List
See Also:
I_CmsResourceType.getConfiguredMappings()

getLoaderId

public abstract int getLoaderId()
Description copied from interface: I_CmsResourceType
Returns the loader type id of this resource type.

Specified by:
getLoaderId in interface I_CmsResourceType
Returns:
the loader type id of this resource type
See Also:
I_CmsResourceType.getLoaderId()

getTypeId

public int getTypeId()
Description copied from interface: I_CmsResourceType
Returns the type id of this resource type.

Specified by:
getTypeId in interface I_CmsResourceType
Returns:
the type id of this resource type
See Also:
I_CmsResourceType.getTypeId()

getTypeName

public java.lang.String getTypeName()
Description copied from interface: I_CmsResourceType
Returns the name of this resource type.

Specified by:
getTypeName in interface I_CmsResourceType
Returns:
the name of this resource type
See Also:
I_CmsResourceType.getTypeName()

hashCode

public int hashCode()
The hash code implementation simply returns the unique type id of this resource type.

See Also:
getTypeId(), Object.hashCode()

importResource

public CmsResource importResource(CmsObject cms,
                                  CmsSecurityManager securityManager,
                                  java.lang.String resourcename,
                                  CmsResource resource,
                                  byte[] content,
                                  java.util.List properties)
                           throws CmsException
Description copied from interface: I_CmsResourceType
Imports a resource to the OpenCms VFS.

If a resource already exists in the VFS (i.e. has the same name and same id) it is replaced by the imported resource.

If a resource with the same name but a different id exists, the imported resource is (usually) moved to the "lost and found" folder.

Specified by:
importResource in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resourcename - the target name (with full path) for the resource after import
resource - the resource to be imported
content - the content of the resource
properties - the properties of the resource
Returns:
the imported resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.importResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, org.opencms.file.CmsResource, byte[], List)

initConfiguration

public final void initConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.

Specified by:
initConfiguration in interface I_CmsConfigurationParameterHandler
See Also:
I_CmsConfigurationParameterHandler.initConfiguration()

initConfiguration

public void initConfiguration(java.lang.String name,
                              java.lang.String id)
                       throws CmsConfigurationException
Deprecated. use initConfiguration(String, String, String) instead

Special version of the configuration initialization used with resource types to set resource type and id, unsing the name of this class instance.

Parameters:
name - the resource type name
id - the resource type id
Throws:
CmsConfigurationException - if the configuration is invalid
See Also:
I_CmsResourceType.initConfiguration(String, String, String)

initConfiguration

public void initConfiguration(java.lang.String name,
                              java.lang.String id,
                              java.lang.String className)
                       throws CmsConfigurationException
Description copied from interface: I_CmsResourceType
Special version of the configuration initialization used with resource types to set resource type, id and class name, required for the XML configuration.

Please note: Many resource types defined in the core have in fact a fixed resource type and a fixed id. Configurable name and id is used only for certain types.

The provided named class must implement this interface (I_CmsResourceType). Usually the provided class name should be the class name of the resource type instance, but this may be different in special cases or configuration errors. For example, if a module is imported that contains it's own resource type class files, the included class file are usually not be available until the server is restarted. If the named class given in the XML configuration (or module manifest.xml) is not available, or not implementing I_CmsResourceType, then CmsResourceTypeUnknown is used for the resource type instance.

Specified by:
initConfiguration in interface I_CmsResourceType
Parameters:
name - the resource type name
id - the resource type id
className - the class name of the resource type (read from the XML configuration)
Throws:
CmsConfigurationException - if the configuration is invalid
See Also:
I_CmsResourceType.initConfiguration(java.lang.String, java.lang.String, java.lang.String)

initialize

public void initialize(CmsObject cms)
Description copied from interface: I_CmsResourceType
Initializes this resource type.

This method will be called once during the OpenCms initialization processs. The VFS will already be available at the time the method is called.

Specified by:
initialize in interface I_CmsResourceType
Parameters:
cms - a OpenCms context initialized with "Admin" permissions
See Also:
I_CmsResourceType.initialize(org.opencms.file.CmsObject)

isAdditionalModuleResourceType

public boolean isAdditionalModuleResourceType()
Description copied from interface: I_CmsResourceType
Indicates that this is an additional resource type which is defined in a module.

Specified by:
isAdditionalModuleResourceType in interface I_CmsResourceType
Returns:
true or false
See Also:
I_CmsResourceType.isAdditionalModuleResourceType()

isDirectEditable

public boolean isDirectEditable()
Description copied from interface: I_CmsResourceType
Returns true if this resource type is direct editable.

Specified by:
isDirectEditable in interface I_CmsResourceType
Returns:
true if this resource type is direct editable
See Also:
I_CmsResourceType.isDirectEditable()

isFolder

public boolean isFolder()
Description copied from interface: I_CmsResourceType
Returns true if this resource type is a folder.

Specified by:
isFolder in interface I_CmsResourceType
Returns:
true if this resource type is a folder
See Also:
I_CmsResourceType.isFolder()

isIdentical

public boolean isIdentical(I_CmsResourceType type)
Description copied from interface: I_CmsResourceType
Tests if the given resource type definition is identical to this resource type definition.

Two resource types are considered identical if their names I_CmsResourceType.getTypeName() and their ids I_CmsResourceType.getTypeId() are both the same.

Please note: Two resource type are considered equal in the sense of Object.equals(Object) if either if their names I_CmsResourceType.getTypeName() or their ids I_CmsResourceType.getTypeId() are equal.

Specified by:
isIdentical in interface I_CmsResourceType
Parameters:
type - another resource type
Returns:
true, if the specified resource type is identical to this resource type
See Also:
I_CmsResourceType.isIdentical(org.opencms.file.types.I_CmsResourceType)

lockResource

public void lockResource(CmsObject cms,
                         CmsSecurityManager securityManager,
                         CmsResource resource,
                         CmsLockType type)
                  throws CmsException
Description copied from interface: I_CmsResourceType
Locks a resource.

The type parameter controls what kind of lock is used.
Possible values for this parameter are:

Specified by:
lockResource in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to lock
type - type of the lock
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.lockResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, org.opencms.lock.CmsLockType)

moveResource

public void moveResource(CmsObject cms,
                         CmsSecurityManager securityManager,
                         CmsResource resource,
                         java.lang.String destination)
                  throws CmsException,
                         CmsIllegalArgumentException
Description copied from interface: I_CmsResourceType
Moves a resource to the given destination.

A move operation in OpenCms is always a copy (as sibling) followed by a delete, this is a result of the online/offline structure of the OpenCms VFS. This way you can see the deleted files/folders in the offline project, and you will be unable to undelete them.

Specified by:
moveResource in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to move
destination - the destination resource name
Throws:
CmsIllegalArgumentException - if the source argument is null or of length 0
CmsException - if something goes wrong
See Also:
I_CmsResourceType.moveResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, java.lang.String)

removeResourceFromProject

public void removeResourceFromProject(CmsObject cms,
                                      CmsSecurityManager securityManager,
                                      CmsResource resource)
                               throws CmsException
Description copied from interface: I_CmsResourceType
Removes a resource from the current project of the user.

This is used to reduce the current users project with the specified resource, in case that the resource is already part of the project. The resource is not really removed like in a regular copy operation, it is in fact only "disabled" in the current users project.

Specified by:
removeResourceFromProject in interface I_CmsResourceType
Parameters:
cms - the initialized CmsObject
securityManager - the initialized OpenCms security manager
resource - the resource to apply this operation to
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.removeResourceFromProject(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource)

replaceResource

public void replaceResource(CmsObject cms,
                            CmsSecurityManager securityManager,
                            CmsResource resource,
                            int type,
                            byte[] content,
                            java.util.List properties)
                     throws CmsException
Description copied from interface: I_CmsResourceType
Replaces the content, type and properties of a resource.

Specified by:
replaceResource in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the name of the resource to replace
type - the new type of the resource
content - the new content of the resource
properties - the new properties of the resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.replaceResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int, byte[], List)

restoreResource

public void restoreResource(CmsObject cms,
                            CmsSecurityManager securityManager,
                            CmsResource resource,
                            int version)
                     throws CmsException
Description copied from interface: I_CmsResourceType
Restores a resource in the current project with a version from the historical archive.

Specified by:
restoreResource in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to restore from the archive
version - the version number of the resource to restore
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.restoreResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)

restoreResourceBackup

public void restoreResourceBackup(CmsObject cms,
                                  CmsSecurityManager securityManager,
                                  CmsResource resource,
                                  int version)
                           throws CmsException
Deprecated. Use restoreResource(CmsObject,CmsSecurityManager,CmsResource,int) instead

Description copied from interface: I_CmsResourceType
Restores a file in the current project with a version from the historical archive.

Specified by:
restoreResourceBackup in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to restore from the archive
version - the publish tag of the resource to restore
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.restoreResourceBackup(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, int)

setAdditionalModuleResourceType

public void setAdditionalModuleResourceType(boolean additionalType)
Description copied from interface: I_CmsResourceType
Sets the additional resource type flag.

Specified by:
setAdditionalModuleResourceType in interface I_CmsResourceType
Parameters:
additionalType - true or false
See Also:
I_CmsResourceType.setAdditionalModuleResourceType(boolean)

setDateExpired

public void setDateExpired(CmsObject cms,
                           CmsSecurityManager securityManager,
                           CmsResource resource,
                           long dateExpired,
                           boolean recursive)
                    throws CmsException
Description copied from interface: I_CmsResourceType
Changes the "expire" date of a resource.

Specified by:
setDateExpired in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to touch
dateExpired - the new expire date of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.setDateExpired(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, long, boolean)

setDateLastModified

public void setDateLastModified(CmsObject cms,
                                CmsSecurityManager securityManager,
                                CmsResource resource,
                                long dateLastModified,
                                boolean recursive)
                         throws CmsException
Description copied from interface: I_CmsResourceType
Changes the "last modified" date of a resource.

Specified by:
setDateLastModified in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to touch
dateLastModified - timestamp the new timestamp of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.setDateLastModified(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, long, boolean)

setDateReleased

public void setDateReleased(CmsObject cms,
                            CmsSecurityManager securityManager,
                            CmsResource resource,
                            long dateReleased,
                            boolean recursive)
                     throws CmsException
Description copied from interface: I_CmsResourceType
Changes the "release" date of a resource.

Specified by:
setDateReleased in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to touch
dateReleased - the new release date of the changed resource
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.setDateReleased(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, long, boolean)

toString

public java.lang.String toString()
See Also:
Object.toString()

undelete

public void undelete(CmsObject cms,
                     CmsSecurityManager securityManager,
                     CmsResource resource,
                     boolean recursive)
              throws CmsException
Description copied from interface: I_CmsResourceType
Undeletes a resource.

Only resources that have already been published once can be undeleted, if a "new" resource is deleted it can not be undeleted.

Specified by:
undelete in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to undelete
recursive - if this operation is to be applied recursivly to all resources in a folder
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.undelete(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, boolean)

undoChanges

public void undoChanges(CmsObject cms,
                        CmsSecurityManager securityManager,
                        CmsResource resource,
                        CmsResource.CmsResourceUndoMode mode)
                 throws CmsException
Description copied from interface: I_CmsResourceType
Undos all changes in the resource by restoring the version from the online project to the current offline project.

Specified by:
undoChanges in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to undo the changes for
mode - the undo mode, one of the CmsResource.CmsResourceUndoMode#UNDO_XXX constants
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.undoChanges(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource, CmsResource.CmsResourceUndoMode)

unlockResource

public void unlockResource(CmsObject cms,
                           CmsSecurityManager securityManager,
                           CmsResource resource)
                    throws CmsException
Description copied from interface: I_CmsResourceType
Unlocks a resource.

Specified by:
unlockResource in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to unlock
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.unlockResource(org.opencms.file.CmsObject, CmsSecurityManager, CmsResource)

writeFile

public CmsFile writeFile(CmsObject cms,
                         CmsSecurityManager securityManager,
                         CmsFile resource)
                  throws CmsException
Description copied from interface: I_CmsResourceType
Writes a resource, including it's content.

Applies only to resources of type CmsFile that have a binary content attached.

Specified by:
writeFile in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to apply this operation to
Returns:
the written resource
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.writeFile(org.opencms.file.CmsObject, CmsSecurityManager, CmsFile)

writePropertyObject

public void writePropertyObject(CmsObject cms,
                                CmsSecurityManager securityManager,
                                CmsResource resource,
                                CmsProperty property)
                         throws CmsException
Description copied from interface: I_CmsResourceType
Writes a property for a specified resource.

Specified by:
writePropertyObject in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to write the property for
property - the property to write
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.writePropertyObject(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, CmsResource, org.opencms.file.CmsProperty)

writePropertyObjects

public void writePropertyObjects(CmsObject cms,
                                 CmsSecurityManager securityManager,
                                 CmsResource resource,
                                 java.util.List properties)
                          throws CmsException
Description copied from interface: I_CmsResourceType
Writes a list of properties for a specified resource.

Code calling this method has to ensure that the no properties a, b are contained in the specified list so that a.equals(b), otherwise an exception is thrown.

Specified by:
writePropertyObjects in interface I_CmsResourceType
Parameters:
cms - the current cms context
securityManager - the initialized OpenCms security manager
resource - the resource to write the properties for
properties - the list of properties to write
Throws:
CmsException - if something goes wrong
See Also:
I_CmsResourceType.writePropertyObjects(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, CmsResource, java.util.List)

createRelations

protected CmsResource createRelations(CmsObject cms,
                                      CmsSecurityManager securityManager,
                                      java.lang.String resourceName)
                               throws CmsException
Creates the relation information for the resource with the given resource name.

Parameters:
cms - the cms context
securityManager - the security manager
resourceName - the resource name of the resource to update the relations for
Returns:
the fresh read resource
Throws:
CmsException - if something goes wrong

getMacroResolver

protected CmsMacroResolver getMacroResolver(CmsObject cms,
                                            java.lang.String resourcename)
Creates a macro resolver based on the current users OpenCms context and the provided resource name.

Parameters:
cms - the current OpenCms user context
resourcename - the resource name for macros like MACRO_RESOURCE_FOLDER_PATH
Returns:
a macro resolver based on the current users OpenCms context and the provided resource name

getResourceType

protected I_CmsResourceType getResourceType(CmsResource resource)
Convenience method to get the initialized resource type instance for the given resource, with a fall back to special "unknown" resource types in case the resource type is not configured.

Parameters:
resource - the resource to get the type for
Returns:
the initialized resource type instance for the given resource
See Also:
CmsResourceManager.getResourceType(int)

processCopyResources

protected void processCopyResources(CmsObject cms,
                                    java.lang.String resourcename,
                                    CmsMacroResolver resolver)
Processes the copy resources of this resource type.

Parameters:
cms - the current OpenCms user context
resourcename - the name of the base resource
resolver - the resolver used for resolving target macro names

processDefaultProperties

protected java.util.List processDefaultProperties(java.util.List properties,
                                                  CmsMacroResolver resolver)
Returns a list of property objects that are attached to the resource on creation.

It's possible to use OpenCms macros for the property values. Please see CmsMacroResolver for allowed macro values.

Parameters:
properties - the (optional) properties provided by the user
resolver - the resolver used to resolve the macro values
Returns:
a list of property objects that are attached to the resource on creation

updateRelationForUndo

protected void updateRelationForUndo(CmsObject cms,
                                     CmsSecurityManager securityManager,
                                     CmsResource resource)
                              throws CmsException
Update the relations after an undo changes operation.

Parameters:
cms - the cms context
securityManager - the security manager
resource - the resource that has been undone
Throws:
CmsException - if something goes wrong