Class CmsResourceTypeImage
- java.lang.Object
-
- org.opencms.file.types.A_CmsResourceType
-
- org.opencms.file.types.CmsResourceTypeImage
-
- All Implemented Interfaces:
java.io.Serializable
,I_CmsConfigurationParameterHandler
,I_CmsResourceType
public class CmsResourceTypeImage extends A_CmsResourceType
Resource type descriptor for the type "image".- Since:
- 6.0.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CmsResourceTypeImage.CmsImageAdjuster
A data container for image size and scale operations.-
Nested classes/interfaces inherited from interface org.opencms.file.types.I_CmsResourceType
I_CmsResourceType.Formatter
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.commons.logging.Log
LOG
The log object for this class.static java.lang.String
PROPERTY_VALUE_UNLIMITED
The value for theCmsPropertyDefinition.PROPERTY_IMAGE_SIZE
property if resources in a folder should never be downscaled.-
Fields inherited from class org.opencms.file.types.A_CmsResourceType
CONFIGURATION_GALLERY_JAVASCRIPT_PATH, CONFIGURATION_GALLERY_PREVIEW_PROVIDER, CONFIGURATION_GALLERY_TYPE_NAMES, CONFIGURATION_INTERNAL, DEFAULT_GALLERY_PREVIEW_PROVIDER, m_addititionalModuleResourceType, m_className, m_configuration, m_copyResources, m_defaultProperties, m_frozen, m_galleryPreviewProvider, m_mappings, m_moduleName, m_typeId, m_typeName, MACRO_RESOURCE_FOLDER_PATH, MACRO_RESOURCE_FOLDER_PATH_TOUCH, MACRO_RESOURCE_NAME, MACRO_RESOURCE_PARENT_PATH, MACRO_RESOURCE_ROOT_PATH, MACRO_RESOURCE_SITE_PATH
-
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
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
-
-
Constructor Summary
Constructors Constructor Description CmsResourceTypeImage()
Default constructor, used to initialize member variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsResource
createResource(CmsObject cms, CmsSecurityManager securityManager, java.lang.String resourcename, byte[] content, java.util.List<CmsProperty> properties)
Creates a new resource of the given resource type with the provided content and properties.static CmsImageScaler
getDownScaler(CmsObject cms, java.lang.String rootPath)
Returns the image downscaler to use when writing an image resource to the given root path.java.lang.String
getGalleryPreviewProvider()
Returns the gallery preview provider class name.int
getLoaderId()
Returns the loader type id of this resource type.static int
getStaticTypeId()
Returns the static type id of this (default) resource type.static java.lang.String
getStaticTypeName()
Returns the static type name of this (default) resource type.CmsResource
importResource(CmsObject cms, CmsSecurityManager securityManager, I_CmsReport report, java.lang.String resourcename, CmsResource resource, byte[] content, java.util.List<CmsProperty> properties)
Imports a resource to the OpenCms VFS.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
replaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type, byte[] content, java.util.List<CmsProperty> properties)
Replaces the content, type and properties of a resource.protected java.util.List<CmsProperty>
tryAddImageSizeFromSvg(byte[] content, java.util.List<CmsProperty> properties)
Tries to use the viewbox from the SVG data to determine the image size and add it to the list of properties.CmsFile
writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource)
Writes a resource, including it's content.-
Methods inherited from class org.opencms.file.types.A_CmsResourceType
addConfigurationParameter, addCopyResource, addDefaultProperty, addMappingType, changeLock, chflags, chtype, chtype, copyResource, copyResourceToProject, createRelations, createSibling, deleteResource, equals, getAdjustLinksFolder, getCachePropertyDefault, getClassName, getConfiguration, getConfiguredCopyResources, getConfiguredDefaultProperties, getConfiguredMappings, getCopyResources, getFormattersForResource, getGalleryTypes, getMacroResolver, getModuleName, getResourceType, getTypeId, getTypeName, hashCode, initConfiguration, initialize, isAdditionalModuleResourceType, isDirectEditable, isFolder, isIdentical, lockResource, moveResource, processCopyResources, processDefaultProperties, removeResourceFromProject, replaceResource, restoreResource, setAdditionalModuleResourceType, setAdjustLinksFolder, setDateExpired, setDateLastModified, setDateReleased, setModuleName, toString, undelete, undoChanges, unlockResource, updateRelationForUndo, writePropertyObject, writePropertyObjects
-
-
-
-
Field Detail
-
LOG
public static final org.apache.commons.logging.Log LOG
The log object for this class.
-
PROPERTY_VALUE_UNLIMITED
public static final java.lang.String PROPERTY_VALUE_UNLIMITED
The value for theCmsPropertyDefinition.PROPERTY_IMAGE_SIZE
property if resources in a folder should never be downscaled.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsResourceTypeImage
public CmsResourceTypeImage()
Default constructor, used to initialize member variables.
-
-
Method Detail
-
getDownScaler
public static CmsImageScaler getDownScaler(CmsObject cms, java.lang.String rootPath)
Returns the image downscaler to use when writing an image resource to the given root path.If
null
is returned, image downscaling must not be used for the resource with the given path. This may be the case if image downscaling is not configured at all, or if image downscaling has been disabled for the parent folder by setting the folders propertyCmsPropertyDefinition.PROPERTY_IMAGE_SIZE
to the valuePROPERTY_VALUE_UNLIMITED
.- Parameters:
cms
- the current OpenCms user contextrootPath
- the root path of the resource to write- Returns:
- the downscaler to use, or
null
if no downscaling is required for the resource
-
getStaticTypeId
public static int getStaticTypeId()
Returns the static type id of this (default) resource type.- Returns:
- the static type id of this (default) resource type
-
getStaticTypeName
public static java.lang.String getStaticTypeName()
Returns the static type name of this (default) resource type.- Returns:
- the static type name of this (default) resource type
-
createResource
public CmsResource createResource(CmsObject cms, CmsSecurityManager securityManager, java.lang.String resourcename, byte[] content, java.util.List<CmsProperty> 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 interfaceI_CmsResourceType
- Overrides:
createResource
in classA_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:
I_CmsResourceType.createResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, java.lang.String, byte[], java.util.List)
-
getGalleryPreviewProvider
public java.lang.String getGalleryPreviewProvider()
Description copied from interface:I_CmsResourceType
Returns the gallery preview provider class name.- Specified by:
getGalleryPreviewProvider
in interfaceI_CmsResourceType
- Overrides:
getGalleryPreviewProvider
in classA_CmsResourceType
- Returns:
- the gallery preview provider class name
- See Also:
I_CmsResourceType.getGalleryPreviewProvider()
-
getLoaderId
public int getLoaderId()
Description copied from interface:I_CmsResourceType
Returns the loader type id of this resource type.- Specified by:
getLoaderId
in interfaceI_CmsResourceType
- Specified by:
getLoaderId
in classA_CmsResourceType
- Returns:
- the loader type id of this resource type
- See Also:
I_CmsResourceType.getLoaderId()
-
importResource
public CmsResource importResource(CmsObject cms, CmsSecurityManager securityManager, I_CmsReport report, java.lang.String resourcename, CmsResource resource, byte[] content, java.util.List<CmsProperty> 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 interfaceI_CmsResourceType
- Overrides:
importResource
in classA_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:
A_CmsResourceType.importResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.report.I_CmsReport, java.lang.String, org.opencms.file.CmsResource, byte[], java.util.List)
-
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 (
). 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_CmsResourceType
is used for the resource type instance.CmsResourceTypeUnknown
- Specified by:
initConfiguration
in interfaceI_CmsResourceType
- Overrides:
initConfiguration
in classA_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:
A_CmsResourceType.initConfiguration(java.lang.String, java.lang.String, String)
-
replaceResource
public void replaceResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type, byte[] content, java.util.List<CmsProperty> properties) throws CmsException
Description copied from interface:I_CmsResourceType
Replaces the content, type and properties of a resource.- Specified by:
replaceResource
in interfaceI_CmsResourceType
- Overrides:
replaceResource
in classA_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:
I_CmsResourceType.replaceResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, int, byte[], java.util.List)
-
writeFile
public CmsFile writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource) throws CmsException, CmsVfsException, CmsSecurityException
Description copied from interface:I_CmsResourceType
Writes a resource, including it's content.Applies only to resources of type
that have a binary content attached.CmsFile
- Specified by:
writeFile
in interfaceI_CmsResourceType
- Overrides:
writeFile
in classA_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 wrongCmsVfsException
CmsSecurityException
- See Also:
I_CmsResourceType.writeFile(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsFile)
-
tryAddImageSizeFromSvg
protected java.util.List<CmsProperty> tryAddImageSizeFromSvg(byte[] content, java.util.List<CmsProperty> properties)
Tries to use the viewbox from the SVG data to determine the image size and add it to the list of properties.- Parameters:
content
- the content bytes of an SVG fileproperties
- the original properties (this object will not be modified)- Returns:
- the amended properties
-
-