Class A_CmsResourceType
- All Implemented Interfaces:
Serializable,I_CmsConfigurationParameterHandler,I_CmsResourceType
- Direct Known Subclasses:
A_CmsResourceTypeFolderBase,A_CmsResourceTypeLinkParseable,CmsResourceTypeBinary,CmsResourceTypeImage,CmsResourceTypePlain,CmsResourceTypePointer,CmsResourceTypeUnknown,CmsResourceTypeUnknownFile
- Since:
- 6.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opencms.file.types.I_CmsResourceType
I_CmsResourceType.Formatter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConfiguration key for optional javascript in galleries.static final StringConfiguration key for optional preview provider in galleries.static final StringConfiguration key for the optional folder class name.static final StringConfiguration key for the (optional) internal flag.static final StringThe default gallery preview provider.protected booleanFlag for showing that this is an additional resource type which is defined in a module.protected StringThe configured class name of this resource type.protected CmsParameterConfigurationConfiguration parameters.protected List<CmsConfigurationCopyResource> The list of resources to copy.protected List<CmsProperty> The list of configured default properties.protected booleanIndicates that the configuration of the resource type has been frozen.protected StringThe gallery preview provider.Contains the file extensions mapped to this resource type.protected StringThe module name if this is an additional resource type which is defined in a module.protected intThe configured id of this resource type.protected StringThe configured name of this resource type.static final StringMacro for the folder path of the current resource.static final StringMacro for the folder path of the current resource, with touch enabled for the copied resources.static final StringMacro for the name of the current resource.static final StringMacro for the parent folder path of the current resource.static final StringMacro for the root path of the current resource.static final StringMacro for the site path of the current resource.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHODFields 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, PARAM_IGNORE_MISSING_SCHEMA, PROPERTY_ON_RESOURCE, PROPERTY_ON_STRUCTURE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, used to initialize some member variables. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfigurationParameter(String paramName, String paramValue) Adds a configuration parameter to this parameter configurable class instance.voidaddCopyResource(String source, String target, String type) Adds a new "copy resource" to this resource type, allowed only during the configuration phase.voidaddDefaultProperty(CmsProperty property) Adds a default property to this resource type, allowed only during the configuration phase.voidaddMappingType(String mapping) Maps a file extension to a resource type.voidchangeLock(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) Changes the lock of a resource to the current user, that is "steals" the lock from another user.voidchflags(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int flags) Changes the resource flags of a resource.voidchtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type) Deprecated.voidchtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, I_CmsResourceType type) Changes the resource type of a resource.voidcopyResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, String destination, CmsResource.CmsResourceCopyMode siblingMode) Copies a resource.voidcopyResourceToProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) Copies a resource to the current project of the user.protected CmsResourcecreateRelations(CmsObject cms, CmsSecurityManager securityManager, String resourceName, boolean updateSiblingState) Creates the relation information for the resource with the given resource name.createResource(CmsObject cms, CmsSecurityManager securityManager, String resourcename, byte[] content, List<CmsProperty> properties) Creates a new resource of the given resource type with the provided content and properties.createSibling(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, String destination, List<CmsProperty> properties) Creates a new sibling of the source resource.voiddeleteResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsResource.CmsResourceDeleteMode siblingMode) Deletes a resource given its name.booleanReturnstrue, if this resource type is equal to the given Object.Gets the folder for which the links should be adjusted after processing the copy resources.Returns the default for thecacheproperty setting of this resource type.Returns the configured class name of this resource type.Returns the parameters of this configurable class instance, ornullif the class does not need any parameters.Returns the (unmodifiable) list of copy resources.Returns the default properties for this resource type in an unmodifiable List.Returns the file extensions mappings for this resource type in an unmodifiable List.protected List<CmsConfigurationCopyResource> getCopyResources(CmsObject cms, String resourcename, CmsMacroResolver resolver) Gets the actual copy resources to use when creating a resource.getFormattersForResource(CmsObject cms, CmsResource res) Returns the formatter configuration for the given resource.Returns the gallery preview provider class name.Returns the gallery types for this resource type.abstract intReturns the loader type id of this resource type.protected CmsMacroResolvergetMacroResolver(CmsObject cms, String resourcename) Creates a macro resolver based on the current users OpenCms context and the provided resource name.Returns the module name if this is an additional resource type which is defined in a module, ornull.protected I_CmsResourceTypegetResourceType(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.intDeprecated.Use this class orgetTypeName()instead.Returns the name of this resource type.inthashCode()The hash code implementation uses the type name to generate a hash code.importResource(CmsObject cms, CmsSecurityManager securityManager, I_CmsReport report, String resourcename, CmsResource resource, byte[] content, List<CmsProperty> properties) Imports a resource to the OpenCms VFS.final voidInitializes a configuration after all parameters have been added.voidinitConfiguration(String name, String id, 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.voidinitialize(CmsObject cms) Initializes this resource type.booleanIndicates that this is an additional resource type which is defined in a module.booleanReturnstrueif this resource type is direct editable.booleanisFolder()Returnstrueif this resource type is a folder.booleanisIdentical(I_CmsResourceType type) Tests if the given resource type definition is identical to this resource type definition.voidlockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsLockType type) Locks a resource.voidmoveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination) Moves a resource to the given destination.protected voidprocessCopyResources(CmsObject cms, String resourcename, CmsMacroResolver resolver) Processes the copy resources of this resource type.protected List<CmsProperty> processDefaultProperties(List<CmsProperty> properties, CmsMacroResolver resolver) Returns a list of property objects that are attached to the resource on creation.voidremoveResourceFromProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) Removes a resource from the current project of the user.voidreplaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type, byte[] content, List<CmsProperty> properties) Deprecated.voidreplaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) Replaces the content, type and properties of a resource.voidrestoreResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version) Restores a resource in the current project with a version from the historical archive.voidsetAdditionalModuleResourceType(boolean additionalType) Sets the additional resource type flag.voidsetAdjustLinksFolder(String adjustLinksFolder) Sets the folder for adjusting links after copying the copy-resources.voidsetDateExpired(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateExpired, boolean recursive) Changes the "expire" date of a resource.voidsetDateLastModified(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateLastModified, boolean recursive) Changes the "last modified" date of a resource.voidsetDateReleased(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateReleased, boolean recursive) Changes the "release" date of a resource.voidsetModuleName(String moduleName) Sets the module name if this is an additional resource type which is defined in a module, ornull.toString()voidundelete(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, boolean recursive) Undeletes a resource.voidundoChanges(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.voidunlockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) Unlocks a resource.protected voidupdateRelationForUndo(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) Update the relations after an undo changes operation.writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource) Writes a resource, including it's content.voidwritePropertyObject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsProperty property) Writes a property for a specified resource.voidwritePropertyObjects(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, List<CmsProperty> properties) Writes a list of properties for a specified resource.
-
Field Details
-
CONFIGURATION_GALLERY_JAVASCRIPT_PATH
Configuration key for optional javascript in galleries.- See Also:
-
CONFIGURATION_GALLERY_PREVIEW_PROVIDER
Configuration key for optional preview provider in galleries.- See Also:
-
CONFIGURATION_GALLERY_TYPE_NAMES
Configuration key for the optional folder class name.- See Also:
-
CONFIGURATION_INTERNAL
Configuration key for the (optional) internal flag.- See Also:
-
DEFAULT_GALLERY_PREVIEW_PROVIDER
The default gallery preview provider.- See Also:
-
MACRO_RESOURCE_FOLDER_PATH
Macro for the folder path of the current resource.- See Also:
-
MACRO_RESOURCE_FOLDER_PATH_TOUCH
Macro for the folder path of the current resource, with touch enabled for the copied resources.- See Also:
-
MACRO_RESOURCE_NAME
Macro for the name of the current resource.- See Also:
-
MACRO_RESOURCE_PARENT_PATH
Macro for the parent folder path of the current resource.- See Also:
-
MACRO_RESOURCE_ROOT_PATH
Macro for the root path of the current resource.- See Also:
-
MACRO_RESOURCE_SITE_PATH
Macro for the site path of the current resource.- See Also:
-
m_addititionalModuleResourceType
Flag for showing that this is an additional resource type which is defined in a module. -
m_className
The configured class name of this resource type. -
m_configuration
Configuration parameters. -
m_copyResources
The list of resources to copy. -
m_defaultProperties
The list of configured default properties. -
m_frozen
Indicates that the configuration of the resource type has been frozen. -
m_galleryPreviewProvider
The gallery preview provider. -
m_mappings
Contains the file extensions mapped to this resource type. -
m_moduleName
The module name if this is an additional resource type which is defined in a module. -
m_typeId
The configured id of this resource type. -
m_typeName
The configured name of this resource type.
-
-
Constructor Details
-
A_CmsResourceType
public A_CmsResourceType()Default constructor, used to initialize some member variables.
-
-
Method Details
-
addConfigurationParameter
Description copied from interface:I_CmsConfigurationParameterHandlerAdds a configuration parameter to this parameter configurable class instance.- Specified by:
addConfigurationParameterin interfaceI_CmsConfigurationParameterHandler- Parameters:
paramName- the name of the parameterparamValue- the value for the parameter- See Also:
-
addCopyResource
public void addCopyResource(String source, String target, 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 macroMACRO_RESOURCE_FOLDER_PATHis used as default. If type isnull, the copy typeCmsResource.COPY_AS_NEWis used as default.- Parameters:
source- the source resourcetarget- 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
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
Description copied from interface:I_CmsResourceTypeMaps 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:
addMappingTypein interfaceI_CmsResourceType- Parameters:
mapping- the file extension mapped to the resource type- See Also:
-
changeLock
public void changeLock(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException Description copied from interface:I_CmsResourceTypeChanges the lock of a resource to the current user, that is "steals" the lock from another user.- Specified by:
changeLockin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the name of the resource to change the lock with complete path- Throws:
CmsException- if something goes wrong- See Also:
-
chflags
public void chflags(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int flags) throws CmsException Description copied from interface:I_CmsResourceTypeChanges 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:
chflagsin interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to change the flags forflags- the new resource flags for this resource- Throws:
CmsException- if something goes wrong- See Also:
-
chtype
public void chtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, I_CmsResourceType type) throws CmsException Description copied from interface:I_CmsResourceTypeChanges 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:
chtypein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to change the type fortype- the new resource type for this resource- Throws:
CmsException- if something goes wrong- See Also:
-
chtype
@Deprecated public void chtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type) throws CmsException Deprecated.Usechtype(CmsObject, CmsSecurityManager, CmsResource, I_CmsResourceType)instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Description copied from interface:I_CmsResourceTypeChanges 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:
chtypein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to change the type fortype- the new resource type for this resource- Throws:
CmsException- if something goes wrong- See Also:
-
copyResource
public void copyResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, String destination, CmsResource.CmsResourceCopyMode siblingMode) throws CmsException Description copied from interface:I_CmsResourceTypeCopies 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
siblingModeparameter controls how to handle siblings during the copy operation.
Possible values for this parameter are:
- Specified by:
copyResourcein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managersource- the resource to copydestination- the name of the copy destination with complete pathsiblingMode- indicates how to handle siblings during copy- Throws:
CmsException- if something goes wrong- See Also:
-
copyResourceToProject
public void copyResourceToProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException Description copied from interface:I_CmsResourceTypeCopies 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:
copyResourceToProjectin interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to apply this operation to- Throws:
CmsException- if something goes wrong- See Also:
-
createResource
public CmsResource createResource(CmsObject cms, CmsSecurityManager securityManager, String resourcename, byte[] content, List<CmsProperty> properties) throws CmsException Description copied from interface:I_CmsResourceTypeCreates a new resource of the given resource type with the provided content and properties.- Specified by:
createResourcein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresourcename- the name of the resource to create (full path)content- the content for the new resourceproperties- the properties for the new resource- Returns:
- the created resource
- Throws:
CmsException- if something goes wrong- See Also:
-
createSibling
public CmsResource createSibling(CmsObject cms, CmsSecurityManager securityManager, CmsResource source, String destination, List<CmsProperty> properties) throws CmsException Description copied from interface:I_CmsResourceTypeCreates a new sibling of the source resource.- Specified by:
createSiblingin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managersource- the resource to create a sibling fordestination- the name of the sibling to create with complete pathproperties- the individual properties for the new sibling- Returns:
- the new created sibling
- Throws:
CmsException- if something goes wrong- See Also:
-
deleteResource
public void deleteResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsResource.CmsResourceDeleteMode siblingMode) throws CmsException Description copied from interface:I_CmsResourceTypeDeletes a resource given its name.The
siblingModeparameter controls how to handle siblings during the delete operation.
Possible values for this parameter are:
- Specified by:
deleteResourcein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to deletesiblingMode- indicates how to handle siblings of the deleted resource- Throws:
CmsException- if something goes wrong- See Also:
-
equals
Returnstrue, 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 namegetTypeName(). 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. -
getAdjustLinksFolder
Description copied from interface:I_CmsResourceTypeGets the folder for which the links should be adjusted after processing the copy resources.- Specified by:
getAdjustLinksFolderin interfaceI_CmsResourceType- Returns:
- the path of the folder for which the links should be adjusted
- See Also:
-
getCachePropertyDefault
Description copied from interface:I_CmsResourceTypeReturns the default for thecacheproperty setting of this resource type.The
cacheproperty is used by the Flex cache implementation to build the cache key that controls the caching behaviour of a resource.If
nullis returnd, this is the same as turning the cache off by default for this resource type.- Specified by:
getCachePropertyDefaultin interfaceI_CmsResourceType- Returns:
- the default for the
cacheproperty setting of this resource type - See Also:
-
getClassName
Returns the configured class name of this resource type.- Specified by:
getClassNamein interfaceI_CmsResourceType- Returns:
- the class name configured for this resource type
- See Also:
-
getConfiguration
Description copied from interface:I_CmsConfigurationParameterHandlerReturns the parameters of this configurable class instance, ornullif the class does not need any parameters.- Specified by:
getConfigurationin interfaceI_CmsConfigurationParameterHandler- Returns:
- the parameters of this configurable class instance,
or
nullif the class does not need any parameters - See Also:
-
getConfiguredCopyResources
Returns the (unmodifiable) list of copy resources.- Specified by:
getConfiguredCopyResourcesin interfaceI_CmsResourceType- Returns:
- the (unmodifiable) list of copy resources
-
getConfiguredDefaultProperties
Returns the default properties for this resource type in an unmodifiable List.- Specified by:
getConfiguredDefaultPropertiesin interfaceI_CmsResourceType- Returns:
- the default properties for this resource type in an unmodifiable List
-
getConfiguredMappings
Description copied from interface:I_CmsResourceTypeReturns the file extensions mappings for this resource type in an unmodifiable List.- Specified by:
getConfiguredMappingsin interfaceI_CmsResourceType- Returns:
- a list of file extensions mappings for this resource type in an unmodifiable List
- See Also:
-
getFormattersForResource
Description copied from interface:I_CmsResourceTypeReturns the formatter configuration for the given resource.- Specified by:
getFormattersForResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextres- the resource to get the formatter configuration for- Returns:
- the formatter configuration for the given resource
- See Also:
-
getGalleryPreviewProvider
Description copied from interface:I_CmsResourceTypeReturns the gallery preview provider class name.- Specified by:
getGalleryPreviewProviderin interfaceI_CmsResourceType- Returns:
- the gallery preview provider class name
- See Also:
-
getGalleryTypes
Description copied from interface:I_CmsResourceTypeReturns the gallery types for this resource type.- Specified by:
getGalleryTypesin interfaceI_CmsResourceType- Returns:
- the gallery types, if no gallery is configured
nullwill be returned - See Also:
-
getLoaderId
Description copied from interface:I_CmsResourceTypeReturns the loader type id of this resource type.- Specified by:
getLoaderIdin interfaceI_CmsResourceType- Returns:
- the loader type id of this resource type
- See Also:
-
getModuleName
Description copied from interface:I_CmsResourceTypeReturns the module name if this is an additional resource type which is defined in a module, ornull.- Specified by:
getModuleNamein interfaceI_CmsResourceType- Returns:
- the module name if this is an additional resource type which is defined in a module, or
null - See Also:
-
getTypeId
Deprecated.Use this class orgetTypeName()instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Description copied from interface:I_CmsResourceTypeReturns the type id of this resource type.- Specified by:
getTypeIdin interfaceI_CmsResourceType- Returns:
- the type id of this resource type
- See Also:
-
getTypeName
Description copied from interface:I_CmsResourceTypeReturns the name of this resource type.- Specified by:
getTypeNamein interfaceI_CmsResourceType- Returns:
- the name of this resource type
- See Also:
-
hashCode
The hash code implementation uses the type name to generate a hash code. -
importResource
public CmsResource importResource(CmsObject cms, CmsSecurityManager securityManager, I_CmsReport report, String resourcename, CmsResource resource, byte[] content, List<CmsProperty> properties) throws CmsException Description copied from interface:I_CmsResourceTypeImports 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:
importResourcein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerreport- optional report to write non-critical import problems toresourcename- the target name (with full path) for the resource after importresource- the resource to be importedcontent- the content of the resourceproperties- the properties of the resource- Returns:
- the imported resource
- Throws:
CmsException- if something goes wrong- See Also:
-
initConfiguration
Description copied from interface:I_CmsConfigurationParameterHandlerInitializes a configuration after all parameters have been added.- Specified by:
initConfigurationin interfaceI_CmsConfigurationParameterHandler- See Also:
-
initConfiguration
public void initConfiguration(String name, String id, String className) throws CmsConfigurationException Description copied from interface:I_CmsResourceTypeSpecial 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 (
). 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 implementingI_CmsResourceType, thenI_CmsResourceTypeis used for the resource type instance.CmsResourceTypeUnknown- Specified by:
initConfigurationin interfaceI_CmsResourceType- Parameters:
name- the resource type nameid- the resource type idclassName- the class name of the resource type (read from the XML configuration)- Throws:
CmsConfigurationException- if the configuration is invalid- See Also:
-
initialize
Description copied from interface:I_CmsResourceTypeInitializes 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:
initializein interfaceI_CmsResourceType- Parameters:
cms- a OpenCms context initialized with "Admin" permissions- See Also:
-
isAdditionalModuleResourceType
Description copied from interface:I_CmsResourceTypeIndicates that this is an additional resource type which is defined in a module.- Specified by:
isAdditionalModuleResourceTypein interfaceI_CmsResourceType- Returns:
- true or false
- See Also:
-
isDirectEditable
Description copied from interface:I_CmsResourceTypeReturnstrueif this resource type is direct editable.- Specified by:
isDirectEditablein interfaceI_CmsResourceType- Returns:
trueif this resource type is direct editable- See Also:
-
isFolder
Description copied from interface:I_CmsResourceTypeReturnstrueif this resource type is a folder.- Specified by:
isFolderin interfaceI_CmsResourceType- Returns:
trueif this resource type is a folder- See Also:
-
isIdentical
Description copied from interface:I_CmsResourceTypeTests 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 idsI_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 namesI_CmsResourceType.getTypeName()or their idsI_CmsResourceType.getTypeId()are equal.- Specified by:
isIdenticalin interfaceI_CmsResourceType- Parameters:
type- another resource type- Returns:
- true, if the specified resource type is identical to this resource type
- See Also:
-
lockResource
public void lockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsLockType type) throws CmsException Description copied from interface:I_CmsResourceTypeLocks a resource.The
typeparameter controls what kind of lock is used.
Possible values for this parameter are:
- Specified by:
lockResourcein interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to locktype- type of the lock- Throws:
CmsException- if something goes wrong- See Also:
-
moveResource
public void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination) throws CmsException, CmsIllegalArgumentException Description copied from interface:I_CmsResourceTypeMoves 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:
moveResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to movedestination- the destination resource name- Throws:
CmsException- if something goes wrongCmsIllegalArgumentException- if thesourceargument is null or of length 0- See Also:
-
removeResourceFromProject
public void removeResourceFromProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException Description copied from interface:I_CmsResourceTypeRemoves 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:
removeResourceFromProjectin interfaceI_CmsResourceType- Parameters:
cms- the initialized CmsObjectsecurityManager- the initialized OpenCms security managerresource- the resource to apply this operation to- Throws:
CmsException- if something goes wrong- See Also:
-
replaceResource
public void replaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, I_CmsResourceType type, byte[] content, List<CmsProperty> properties) throws CmsException Description copied from interface:I_CmsResourceTypeReplaces the content, type and properties of a resource.- Specified by:
replaceResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the name of the resource to replacetype- the new type of the resourcecontent- the new content of the resourceproperties- the new properties of the resource- Throws:
CmsException- if something goes wrong- See Also:
-
replaceResource
@Deprecated public void replaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type, byte[] content, List<CmsProperty> properties) throws CmsException Deprecated.UsereplaceResource(CmsObject, CmsSecurityManager, CmsResource, I_CmsResourceType, byte[], List)instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Description copied from interface:I_CmsResourceTypeReplaces the content, type and properties of a resource.- Specified by:
replaceResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the name of the resource to replacetype- the new type of the resourcecontent- the new content of the resourceproperties- the new properties of the resource- Throws:
CmsException- if something goes wrong- See Also:
-
restoreResource
public void restoreResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version) throws CmsException Description copied from interface:I_CmsResourceTypeRestores a resource in the current project with a version from the historical archive.- Specified by:
restoreResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to restore from the archiveversion- the version number of the resource to restore- Throws:
CmsException- if something goes wrong- See Also:
-
setAdditionalModuleResourceType
Description copied from interface:I_CmsResourceTypeSets the additional resource type flag.- Specified by:
setAdditionalModuleResourceTypein interfaceI_CmsResourceType- Parameters:
additionalType- true or false- See Also:
-
setAdjustLinksFolder
Description copied from interface:I_CmsResourceTypeSets the folder for adjusting links after copying the copy-resources.- Specified by:
setAdjustLinksFolderin interfaceI_CmsResourceType- Parameters:
adjustLinksFolder- the folder for which links should be adjusted- See Also:
-
setDateExpired
public void setDateExpired(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateExpired, boolean recursive) throws CmsException Description copied from interface:I_CmsResourceTypeChanges the "expire" date of a resource.- Specified by:
setDateExpiredin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to touchdateExpired- the new expire date of the changed resourcerecursive- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException- if something goes wrong- See Also:
-
setDateLastModified
public void setDateLastModified(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateLastModified, boolean recursive) throws CmsException Description copied from interface:I_CmsResourceTypeChanges the "last modified" date of a resource.- Specified by:
setDateLastModifiedin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to touchdateLastModified- timestamp the new timestamp of the changed resourcerecursive- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException- if something goes wrong- See Also:
-
setDateReleased
public void setDateReleased(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, long dateReleased, boolean recursive) throws CmsException Description copied from interface:I_CmsResourceTypeChanges the "release" date of a resource.- Specified by:
setDateReleasedin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to touchdateReleased- the new release date of the changed resourcerecursive- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException- if something goes wrong- See Also:
-
setModuleName
Description copied from interface:I_CmsResourceTypeSets the module name if this is an additional resource type which is defined in a module, ornull.- Specified by:
setModuleNamein interfaceI_CmsResourceType- Parameters:
moduleName- the module name if this is an additional resource type which is defined in a module, ornull- See Also:
-
toString
-
undelete
public void undelete(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, boolean recursive) throws CmsException Description copied from interface:I_CmsResourceTypeUndeletes 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:
undeletein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to undeleterecursive- if this operation is to be applied recursively to all resources in a folder- Throws:
CmsException- if something goes wrong- See Also:
-
undoChanges
public void undoChanges(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsResource.CmsResourceUndoMode mode) throws CmsException Description copied from interface:I_CmsResourceTypeUndos all changes in the resource by restoring the version from the online project to the current offline project.- Specified by:
undoChangesin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to undo the changes formode- the undo mode, one of theconstantsCmsResource.CmsResourceUndoMode#UNDO_XXX- Throws:
CmsException- if something goes wrong- See Also:
-
unlockResource
public void unlockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException Description copied from interface:I_CmsResourceTypeUnlocks a resource.- Specified by:
unlockResourcein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to unlock- Throws:
CmsException- if something goes wrong- See Also:
-
writeFile
public CmsFile writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource) throws CmsException Description copied from interface:I_CmsResourceTypeWrites a resource, including it's content.Applies only to resources of type
that have a binary content attached.CmsFile- Specified by:
writeFilein interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to apply this operation to- Returns:
- the written resource
- Throws:
CmsException- if something goes wrong- See Also:
-
writePropertyObject
public void writePropertyObject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsProperty property) throws CmsException Description copied from interface:I_CmsResourceTypeWrites a property for a specified resource.- Specified by:
writePropertyObjectin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to write the property forproperty- the property to write- Throws:
CmsException- if something goes wrong- See Also:
-
writePropertyObjects
public void writePropertyObjects(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, List<CmsProperty> properties) throws CmsException Description copied from interface:I_CmsResourceTypeWrites a list of properties for a specified resource.Code calling this method has to ensure that the no properties
a, bare contained in the specified list so thata.equals(b), otherwise an exception is thrown.- Specified by:
writePropertyObjectsin interfaceI_CmsResourceType- Parameters:
cms- the current cms contextsecurityManager- the initialized OpenCms security managerresource- the resource to write the properties forproperties- the list of properties to write- Throws:
CmsException- if something goes wrong- See Also:
-
createRelations
protected CmsResource createRelations(CmsObject cms, CmsSecurityManager securityManager, String resourceName, boolean updateSiblingState) throws CmsException Creates the relation information for the resource with the given resource name.- Parameters:
cms- the cms contextsecurityManager- the security managerresourceName- the resource name of the resource to update the relations forupdateSiblingState- if true, sets the state of siblings with changed relations to 'changed' (unless they are new or deleted)- Returns:
- the fresh read resource
- Throws:
CmsException- if something goes wrong
-
getCopyResources
protected List<CmsConfigurationCopyResource> getCopyResources(CmsObject cms, String resourcename, CmsMacroResolver resolver) Gets the actual copy resources to use when creating a resource.- Parameters:
cms- the CMS contextresourcename- the path of the resource to createresolver- the macro resolver to use- Returns:
- the copy resources to use
-
getMacroResolver
Creates a macro resolver based on the current users OpenCms context and the provided resource name.- Parameters:
cms- the current OpenCms user contextresourcename- the resource name for macros likeMACRO_RESOURCE_FOLDER_PATH- Returns:
- a macro resolver based on the current users OpenCms context and the provided resource name
-
getResourceType
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:
-
processCopyResources
Processes the copy resources of this resource type.- Parameters:
cms- the current OpenCms user contextresourcename- the name of the base resourceresolver- the resolver used for resolving target macro names
-
processDefaultProperties
protected List<CmsProperty> processDefaultProperties(List<CmsProperty> 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
CmsMacroResolverfor allowed macro values.- Parameters:
properties- the (optional) properties provided by the userresolver- 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 contextsecurityManager- the security managerresource- the resource that has been undone- Throws:
CmsException- if something goes wrong
-
chtype(CmsObject, CmsSecurityManager, CmsResource, I_CmsResourceType)instead.