|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Defines resource type descriptors for all resources in the VFS.
Each file in the VFS must belong to an initialized resource type.
The available resource type are read during system startup ftom the configuration
file opencms-vfs.xml.
Certain resource types may require special handling for certain operations.
This is usually required for write operations, or other operations that
modify the VFS database.
Therefore, the CmsObject defers handling of this
operations to implementations of this interface.
If you implement a new resource type, it's a good idea to extend the
abstract class A_CmsResourceType.
Important: The CmsObject passes the CmsSecurityManager
object to implementations of this class. Using this object correctly is key to the
resource type operations. Mistakes made in the implementation of a resource type
can screw up the system security and the database structure, and make you unhappy.
| Field Summary | |
static String |
ADD_MAPPING_METHOD
The name of the addMapping() method. |
static String |
ADD_RESOURCE_TYPE_METHOD
Name of the addResourceType() method to add a resource type from the configuration. |
static String |
CONFIGURATION_PROPERTY_CREATE
Configuration key prefix for properties that are attached when creating a new resource. |
static String |
CONFIGURATION_RESOURCE_TYPE_ID
Configuration key for the resource type id. |
static String |
CONFIGURATION_RESOURCE_TYPE_NAME
Configuration key for the resource type name. |
static String |
PROPERTY_ON_RESOURCE
Store the property on resource record. |
static String |
PROPERTY_ON_STRUCTURE
Store the property on structure record. |
| Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler |
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD |
| Method Summary | |
void |
addMappingType(String mapping)
Maps a file extension to a resource type. |
void |
changeLastModifiedProjectId(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
Changes the project id of the resource to the current project, indicating that the resource was last modified in this project. |
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,
String destination,
int siblingMode)
Copies a resource. |
void |
copyResourceToProject(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
Copies a resource to the current project of the user. |
CmsResource |
createResource(CmsObject cms,
CmsSecurityManager securityManager,
String resourcename,
byte[] content,
List properties)
Creates a new resource of the given resource type with the provided content and properties. |
void |
createSibling(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource source,
String destination,
List properties)
Creates a new sibling of the source resource. |
void |
deleteResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int siblingMode)
Deletes a resource given its name. |
String |
getCachePropertyDefault()
Returns the default for the cache property setting of this resource type. |
List |
getConfiguredCopyResources()
Returns the configured copy resources for this resource type in an unmodifiable List. |
List |
getConfiguredDefaultProperties()
Returns the configured default properties for this resource type in an unmodifiable List. |
List |
getConfiguredMappings()
Returns the file extensions mappings for this resource type in an unmodifiable List. |
int |
getLoaderId()
Returns the loader type id of this resource type. |
int |
getTypeId()
Returns the type id of this resource type. |
String |
getTypeName()
Returns the name of this resource type. |
CmsResource |
importResource(CmsObject cms,
CmsSecurityManager securityManager,
String resourcename,
CmsResource resource,
byte[] content,
List properties)
Imports a resource to the OpenCms VFS. |
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. |
void |
lockResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int mode)
Locks a resource. |
void |
moveResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
String destination)
Moves a resource to the given destination. |
void |
replaceResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int type,
byte[] content,
List properties)
Replaces the content, type and properties of a resource. |
void |
restoreResourceBackup(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int tag)
Restores a file in the current project with a version from the backup archive. |
void |
setAdditionalModuleResourceType(boolean additionalType)
Sets the additional resource type flag. |
void |
touch(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
long dateLastModified,
long dateReleased,
long dateExpired,
boolean recursive)
Changes the timestamp information of a resource. |
void |
undoChanges(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
boolean recursive)
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. |
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,
List properties)
Writes a list of properties for a specified resource. |
| Methods inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler |
addConfigurationParameter, getConfiguration, initConfiguration |
| Field Detail |
public static final String ADD_MAPPING_METHOD
public static final String ADD_RESOURCE_TYPE_METHOD
public static final String CONFIGURATION_PROPERTY_CREATE
public static final String CONFIGURATION_RESOURCE_TYPE_ID
public static final String CONFIGURATION_RESOURCE_TYPE_NAME
public static final String PROPERTY_ON_RESOURCE
public static final String PROPERTY_ON_STRUCTURE
| Method Detail |
public void addMappingType(String mapping)
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.
mapping - the file extension mapped to the resource type
public void changeLastModifiedProjectId(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
throws CmsException
This information is used while publishing. Only resources inside the project folders that are new/modified/changed and that "belong" to the project (i.e. have the id of the project set) are published with the project.
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to apply this operation to
CmsException - if something goes wrongCmsObject.changeLastModifiedProjectId(String),
CmsSecurityManager.changeLastModifiedProjectId(org.opencms.file.CmsRequestContext, CmsResource)
public void changeLock(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
throws CmsException
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the name of the resource to change the lock with complete path
CmsException - if something goes wrongCmsObject.changeLock(String),
CmsSecurityManager.changeLock(org.opencms.file.CmsRequestContext, CmsResource)
public void chflags(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int flags)
throws CmsException
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.
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to change the flags forflags - the new resource flags for this resource
CmsException - if something goes wrongCmsObject.chflags(String, int),
CmsSecurityManager.chflags(org.opencms.file.CmsRequestContext, CmsResource, int)
public void chtype(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int type)
throws CmsException
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.
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to change the type fortype - the new resource type for this resource
CmsException - if something goes wrongCmsObject.chtype(String, int),
CmsSecurityManager.chtype(org.opencms.file.CmsRequestContext, CmsResource, int)
public void copyResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource source,
String destination,
int siblingMode)
throws CmsException,
CmsIllegalArgumentException
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:
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
CmsIllegalArgumentException - if the destination argument is null or of length 0
CmsException - if something goes wrongCmsObject.copyResource(String, String, int),
CmsSecurityManager.copyResource(org.opencms.file.CmsRequestContext, CmsResource, String, int)
public void copyResourceToProject(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
throws CmsException,
CmsIllegalArgumentException
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.
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to apply this operation to
CmsException - if something goes wrong
CmsIllegalArgumentException - if the resource argument is null or of length 0CmsObject.copyResourceToProject(String),
CmsSecurityManager.copyResourceToProject(org.opencms.file.CmsRequestContext, CmsResource)
public CmsResource createResource(CmsObject cms,
CmsSecurityManager securityManager,
String resourcename,
byte[] content,
List properties)
throws CmsException,
CmsIllegalArgumentException
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
CmsException - if something goes wrong
CmsIllegalArgumentException - if the source argument is null or of length 0CmsObject.createResource(String, int, byte[], List),
CmsObject.createResource(String, int),
CmsSecurityManager.createResource(org.opencms.file.CmsRequestContext, String, int, byte[], List)
public void createSibling(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource source,
String destination,
List properties)
throws CmsException
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
CmsException - if something goes wrongCmsObject.createSibling(String, String, List),
CmsSecurityManager.createSibling(org.opencms.file.CmsRequestContext, CmsResource, String, List)
public void deleteResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int siblingMode)
throws CmsException
The siblingMode parameter controls how to handle siblings
during the delete operation.
Possible values for this parameter are:
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to deletesiblingMode - indicates how to handle siblings of the deleted resource
CmsException - if something goes wrongCmsObject.deleteResource(String, int),
CmsSecurityManager.deleteResource(org.opencms.file.CmsRequestContext, CmsResource, int)public String getCachePropertyDefault()
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.
cache property setting of this resource typeCmsFlexCache,
CmsFlexCacheKeypublic List getConfiguredCopyResources()
public List getConfiguredDefaultProperties()
public List getConfiguredMappings()
public int getLoaderId()
public int getTypeId()
public String getTypeName()
public CmsResource importResource(CmsObject cms,
CmsSecurityManager securityManager,
String resourcename,
CmsResource resource,
byte[] content,
List properties)
throws CmsException
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.
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresourcename - 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
CmsException - if something goes wrongCmsSecurityManager.moveToLostAndFound(org.opencms.file.CmsRequestContext, String, boolean),
CmsObject.importResource(String, CmsResource, byte[], List),
CmsSecurityManager.importResource(org.opencms.file.CmsRequestContext, String, CmsResource, byte[], List, boolean)public void initialize(CmsObject cms)
This method will be called once during the OpenCms initialization processs. The VFS will already be available at the time the method is called.
cms - a OpenCms context initialized with "Admin" permissionspublic boolean isAdditionalModuleResourceType()
public boolean isDirectEditable()
true if this resource type is direct editable.
true if this resource type is direct editablepublic boolean isFolder()
true if this resource type is a folder.
true if this resource type is a folder
public void lockResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int mode)
throws CmsException
The mode parameter controls what kind of lock is used.
Possible values for this parameter are:
cms - the initialized CmsObjectsecurityManager - the initialized OpenCms security managerresource - the resource to lockmode - flag indicating the mode for the lock
CmsException - if something goes wrongCmsObject.lockResource(String, int),
CmsSecurityManager.lockResource(org.opencms.file.CmsRequestContext, CmsResource, int)
public void moveResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
String destination)
throws CmsException,
CmsIllegalArgumentException
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.
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to movedestination - the destination resource name
CmsException - if something goes wrong
CmsIllegalArgumentException - if the source argument is null or of length 0CmsObject.moveResource(String, String),
CmsObject.renameResource(String, String),
CmsSecurityManager.copyResource(org.opencms.file.CmsRequestContext, CmsResource, String, int),
CmsSecurityManager.deleteResource(org.opencms.file.CmsRequestContext, CmsResource, int)
public void replaceResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int type,
byte[] content,
List properties)
throws CmsException
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
CmsException - if something goes wrongCmsObject.replaceResource(String, int, byte[], List),
CmsSecurityManager.replaceResource(org.opencms.file.CmsRequestContext, CmsResource, int, byte[], List)
public void restoreResourceBackup(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
int tag)
throws CmsException
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to restore from the archivetag - the tag (version) id to resource form the archive
CmsException - if something goes wrongCmsObject.restoreResourceBackup(String, int),
CmsSecurityManager.restoreResource(org.opencms.file.CmsRequestContext, CmsResource, int)public void setAdditionalModuleResourceType(boolean additionalType)
additionalType - true or false
public void touch(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
long dateLastModified,
long dateReleased,
long dateExpired,
boolean recursive)
throws CmsException
This method is used to set the "last modified" date of a resource, the "release" date of a resource, and also the "expire" date of a resource.
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to touchdateLastModified - timestamp the new timestamp of the changed resourcedateReleased - the new release date of the changed resource,
set it to CmsResource.TOUCH_DATE_UNCHANGED to keep it unchanged.dateExpired - the new expire date of the changed resource,
set it to CmsResource.TOUCH_DATE_UNCHANGED to keep it unchanged.recursive - if this operation is to be applied recursivly to all resources in a folder
CmsException - if something goes wrongCmsObject.touch(String, long, long, long, boolean),
CmsSecurityManager.touch(org.opencms.file.CmsRequestContext, CmsResource, long, long, long)
public void undoChanges(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
boolean recursive)
throws CmsException
This is also used when doing an "undelete" operation.
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to undo the changes forrecursive - if this operation is to be applied recursivly to all resources in a folder
CmsException - if something goes wrongCmsObject.undoChanges(String, boolean),
CmsSecurityManager.undoChanges(org.opencms.file.CmsRequestContext, CmsResource)
public void unlockResource(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource)
throws CmsException
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to unlock
CmsException - if something goes wrongCmsObject.unlockResource(String),
CmsSecurityManager.unlockResource(org.opencms.file.CmsRequestContext, CmsResource)
public CmsFile writeFile(CmsObject cms,
CmsSecurityManager securityManager,
CmsFile resource)
throws CmsException
Applies only to resources of type
have a binary content attached.CmsFile
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to apply this operation to
CmsException - if something goes wrongCmsObject.writeFile(CmsFile),
CmsSecurityManager.writeFile(org.opencms.file.CmsRequestContext, CmsFile)
public void writePropertyObject(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
CmsProperty property)
throws CmsException
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to write the property forproperty - the property to write
CmsException - if something goes wrongCmsObject.writePropertyObject(String, CmsProperty),
CmsSecurityManager.writePropertyObject(org.opencms.file.CmsRequestContext, CmsResource, CmsProperty)
public void writePropertyObjects(CmsObject cms,
CmsSecurityManager securityManager,
CmsResource resource,
List properties)
throws CmsException
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.
cms - the current cms contextsecurityManager - the initialized OpenCms security managerresource - the resource to write the properties forproperties - the list of properties to write
CmsException - if something goes wrongCmsObject.writePropertyObjects(String, List),
CmsSecurityManager.writePropertyObjects(org.opencms.file.CmsRequestContext, CmsResource, List)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||