Package org.alfresco.repo.content
Class MimetypeMap
java.lang.Object
org.alfresco.repo.content.MimetypeMap
- All Implemented Interfaces:
MimetypeService
Provides a bidirectional mapping between well-known mimetypes and the
registered file extensions. All mimetypes and extensions are stored and
handled as lowercase.
- Author:
- Derek Hulley
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorMimetypeMap
(org.springframework.extensions.config.ConfigService configService) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionorg.alfresco.repo.content.MimetypeMap.Data
org.springframework.extensions.config.ConfigService
Provides the system default charset finder.org.alfresco.repo.content.MimetypeMap.Data
getData()
Get all human readable mimetype descriptions indexed by mimetype extensionGet all human readable mimetype descriptions indexed by mimetypegetExtension
(String mimetype) Get the file extension associated with the mimetype.Get all mimetype extensions indexed by mimetypegetMimetype
(String extension) Get the mimetype for the specified extensiongetMimetypeIfNotMatches
(ContentReader reader) Use Apache Tika to check if the mime type of the document really matches what it claims to be.Get all mimetypesgetMimetypes
(String extension) Returns a collection of mimetypes ordered by extension.Get all mimetypes indexed by extensionguessMimetype
(String filename) Takes a guess at the mimetype based exclusively on the file extension, which can (and often is) wrong...guessMimetype
(String filename, InputStream input) Uses Tika to try to identify the mimetype of the file, falling back onguessMimetype(String)
for an extension based one if Tika can't help.guessMimetype
(String filename, ContentReader reader) Uses Tika to try to identify the mimetype of the file, falling back onguessMimetype(String)
for an extension based one if Tika can't help.void
init()
Initialises the map using the configuration service providedboolean
Check if a given mimetype represents a text format.boolean
void
setConfigService
(org.springframework.extensions.config.ConfigService configService) void
setContentCharsetFinder
(ContentCharsetFinder contentCharsetFinder) Set the system default content characterset decodervoid
setCronExpression
(org.quartz.CronExpression cronExpression) void
setInitialAndOnErrorCronExpression
(org.quartz.CronExpression initialAndOnErrorCronExpression) void
setJsonObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper) void
setMimetypeJsonConfigDir
(String mimetypeJsonConfigDir) void
setShutdownIndicator
(ShutdownIndicator shutdownIndicator) void
setTikaConfig
(org.apache.tika.config.TikaConfig tikaConfig) Injects the TikaConfig to use
-
Field Details
-
PREFIX_APPLICATION
- See Also:
-
PREFIX_AUDIO
- See Also:
-
PREFIX_IMAGE
- See Also:
-
PREFIX_MESSAGE
- See Also:
-
PREFIX_MODEL
- See Also:
-
PREFIX_MULTIPART
- See Also:
-
PREFIX_TEXT
- See Also:
-
PREFIX_VIDEO
- See Also:
-
EXTENSION_BINARY
- See Also:
-
MACOS_RESOURCE_FORK_FILE_NAME_PREFIX
- See Also:
-
MIMETYPE_MULTIPART_ALTERNATIVE
- See Also:
-
MIMETYPE_TEXT_PLAIN
- See Also:
-
MIMETYPE_TEXT_MEDIAWIKI
- See Also:
-
MIMETYPE_TEXT_CSS
- See Also:
-
MIMETYPE_TEXT_CSV
- See Also:
-
MIMETYPE_TEXT_JAVASCRIPT
- See Also:
-
MIMETYPE_XML
- See Also:
-
MIMETYPE_HTML
- See Also:
-
MIMETYPE_XHTML
- See Also:
-
MIMETYPE_PDF
- See Also:
-
MIMETYPE_JSON
- See Also:
-
MIMETYPE_WORD
- See Also:
-
MIMETYPE_EXCEL
- See Also:
-
MIMETYPE_BINARY
- See Also:
-
MIMETYPE_PPT
- See Also:
-
MIMETYPE_APP_DWG
- See Also:
-
MIMETYPE_IMG_DWG
- See Also:
-
MIMETYPE_VIDEO_AVI
- See Also:
-
MIMETYPE_VIDEO_QUICKTIME
- See Also:
-
MIMETYPE_VIDEO_WMV
- See Also:
-
MIMETYPE_VIDEO_3GP
- See Also:
-
MIMETYPE_VIDEO_3GP2
- See Also:
-
MIMETYPE_DITA
- See Also:
-
MIMETYPE_FLASH
- See Also:
-
MIMETYPE_VIDEO_FLV
- See Also:
-
MIMETYPE_APPLICATION_FLA
- See Also:
-
MIMETYPE_VIDEO_MPG
- See Also:
-
MIMETYPE_VIDEO_MP4
- See Also:
-
MIMETYPE_IMAGE_GIF
- See Also:
-
MIMETYPE_IMAGE_JPEG
- See Also:
-
MIMETYPE_IMAGE_RGB
- See Also:
-
MIMETYPE_IMAGE_SVG
- See Also:
-
MIMETYPE_IMAGE_PNG
- See Also:
-
MIMETYPE_IMAGE_TIFF
- See Also:
-
MIMETYPE_IMAGE_RAW_DNG
- See Also:
-
MIMETYPE_IMAGE_RAW_3FR
- See Also:
-
MIMETYPE_IMAGE_RAW_RAF
- See Also:
-
MIMETYPE_IMAGE_RAW_CR2
- See Also:
-
MIMETYPE_IMAGE_RAW_K25
- See Also:
-
MIMETYPE_IMAGE_RAW_MRW
- See Also:
-
MIMETYPE_IMAGE_RAW_NEF
- See Also:
-
MIMETYPE_IMAGE_RAW_ORF
- See Also:
-
MIMETYPE_IMAGE_RAW_PEF
- See Also:
-
MIMETYPE_IMAGE_RAW_ARW
- See Also:
-
MIMETYPE_IMAGE_RAW_X3F
- See Also:
-
MIMETYPE_IMAGE_RAW_RW2
- See Also:
-
MIMETYPE_IMAGE_RAW_RWL
- See Also:
-
MIMETYPE_IMAGE_RAW_R3D
- See Also:
-
MIMETYPE_IMAGE_DWT
- See Also:
-
MIMETYPE_IMAGE_ICNS
- See Also:
-
MIMETYPE_APPLICATION_EPS
- See Also:
-
MIMETYPE_APPLICATION_PS
- See Also:
-
MIMETYPE_JAVASCRIPT
- See Also:
-
MIMETYPE_ZIP
- See Also:
-
MIMETYPE_OPENSEARCH_DESCRIPTION
- See Also:
-
MIMETYPE_ATOM
- See Also:
-
MIMETYPE_RSS
- See Also:
-
MIMETYPE_RFC822
- See Also:
-
MIMETYPE_OUTLOOK_MSG
- See Also:
-
MIMETYPE_VISIO
- See Also:
-
MIMETYPE_VISIO_2013
- See Also:
-
MIMETYPE_APPLICATION_ILLUSTRATOR
- See Also:
-
MIMETYPE_APPLICATION_PHOTOSHOP
- See Also:
-
MIMETYPE_ENCRYPTED_OFFICE
- See Also:
-
MIMETYPE_OPENDOCUMENT_TEXT
- See Also:
-
MIMETYPE_OPENDOCUMENT_TEXT_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_GRAPHICS
- See Also:
-
MIMETYPE_OPENDOCUMENT_GRAPHICS_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_PRESENTATION
- See Also:
-
MIMETYPE_OPENDOCUMENT_PRESENTATION_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_SPREADSHEET
- See Also:
-
MIMETYPE_OPENDOCUMENT_SPREADSHEET_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_CHART
- See Also:
-
MIMETYPE_OPENDOCUMENT_CHART_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_IMAGE
- See Also:
-
MIMETYPE_OPENDOCUMENT_IMAGE_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_FORMULA
- See Also:
-
MIMETYPE_OPENDOCUMENT_FORMULA_TEMPLATE
- See Also:
-
MIMETYPE_OPENDOCUMENT_TEXT_MASTER
- See Also:
-
MIMETYPE_OPENDOCUMENT_TEXT_WEB
- See Also:
-
MIMETYPE_OPENDOCUMENT_DATABASE
- See Also:
-
MIMETYPE_OPENOFFICE1_WRITER
- See Also:
-
MIMETYPE_OPENOFFICE1_CALC
- See Also:
-
MIMETYPE_OPENOFFICE1_DRAW
- See Also:
-
MIMETYPE_OPENOFFICE1_IMPRESS
- See Also:
-
MIMETYPE_OPENXML_WORDPROCESSING
- See Also:
-
MIMETYPE_OPENXML_WORDPROCESSING_MACRO
- See Also:
-
MIMETYPE_OPENXML_WORD_TEMPLATE
- See Also:
-
MIMETYPE_OPENXML_WORD_TEMPLATE_MACRO
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET_MACRO
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE_MACRO
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET_ADDIN_MACRO
- See Also:
-
MIMETYPE_OPENXML_SPREADSHEET_BINARY_MACRO
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_MACRO
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW_MACRO
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_TEMPLATE
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_TEMPLATE_MACRO
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_ADDIN
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_SLIDE
- See Also:
-
MIMETYPE_OPENXML_PRESENTATION_SLIDE_MACRO
- See Also:
-
MIMETYPE_STAROFFICE5_DRAW
- See Also:
-
MIMETYPE_STAROFFICE5_CALC
- See Also:
-
MIMETYPE_STAROFFICE5_IMPRESS
- See Also:
-
MIMETYPE_STAROFFICE5_IMPRESS_PACKED
- See Also:
-
MIMETYPE_STAROFFICE5_CHART
- See Also:
-
MIMETYPE_STAROFFICE5_WRITER
- See Also:
-
MIMETYPE_STAROFFICE5_WRITER_GLOBAL
- See Also:
-
MIMETYPE_STAROFFICE5_MATH
- See Also:
-
MIMETYPE_IWORK_KEYNOTE
- See Also:
-
MIMETYPE_IWORK_NUMBERS
- See Also:
-
MIMETYPE_IWORK_PAGES
- See Also:
-
MIMETYPE_APPLEFILE
- See Also:
-
MIMETYPE_WORDPERFECT
- See Also:
-
MIMETYPE_MP3
- See Also:
-
MIMETYPE_AUDIO_MP4
- See Also:
-
MIMETYPE_VORBIS
- See Also:
-
MIMETYPE_FLAC
- See Also:
-
MIMETYPE_ACP
- See Also:
-
-
Constructor Details
-
MimetypeMap
public MimetypeMap()Default constructor- Since:
- 2.1
-
MimetypeMap
Deprecated.
-
-
Method Details
-
createData
public org.alfresco.repo.content.MimetypeMap.Data createData() -
getData
public org.alfresco.repo.content.MimetypeMap.Data getData() -
getConfigService
public org.springframework.extensions.config.ConfigService getConfigService() -
setConfigService
public void setConfigService(org.springframework.extensions.config.ConfigService configService) - Parameters:
configService
- the config service to use to read mimetypes from
-
getContentCharsetFinder
Provides the system default charset finder.- Specified by:
getContentCharsetFinder
in interfaceMimetypeService
- Returns:
- Returns a character set finder that can be used to decode streams in order to get the encoding.
-
setContentCharsetFinder
Set the system default content characterset decoder -
setTikaConfig
public void setTikaConfig(org.apache.tika.config.TikaConfig tikaConfig) Injects the TikaConfig to use- Parameters:
tikaConfig
- The Tika Config to use
-
setJsonObjectMapper
public void setJsonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper) -
setMimetypeJsonConfigDir
-
setCronExpression
public void setCronExpression(org.quartz.CronExpression cronExpression) -
setInitialAndOnErrorCronExpression
public void setInitialAndOnErrorCronExpression(org.quartz.CronExpression initialAndOnErrorCronExpression) -
setShutdownIndicator
-
init
public void init()Initialises the map using the configuration service provided -
readConfig
public boolean readConfig() -
getExtension
Get the file extension associated with the mimetype.- Specified by:
getExtension
in interfaceMimetypeService
- Parameters:
mimetype
- a valid mimetype- Returns:
- Returns the default extension for the mimetype. Returns the
binary
mimetype extension. - See Also:
-
getMimetype
Get the mimetype for the specified extension- Specified by:
getMimetype
in interfaceMimetypeService
- Parameters:
extension
- a valid file extension- Returns:
- Returns a valid mimetype if found, or
binary
as default.
-
getDisplaysByExtension
Description copied from interface:MimetypeService
Get all human readable mimetype descriptions indexed by mimetype extension- Specified by:
getDisplaysByExtension
in interfaceMimetypeService
- Returns:
- the map of displays indexed by extension
-
getDisplaysByMimetype
Description copied from interface:MimetypeService
Get all human readable mimetype descriptions indexed by mimetype- Specified by:
getDisplaysByMimetype
in interfaceMimetypeService
- Returns:
- the map of displays indexed by mimetype
-
getExtensionsByMimetype
Description copied from interface:MimetypeService
Get all mimetype extensions indexed by mimetype- Specified by:
getExtensionsByMimetype
in interfaceMimetypeService
- Returns:
- the map of extension indexed by mimetype
-
getMimetypes
Description copied from interface:MimetypeService
Get all mimetypes- Specified by:
getMimetypes
in interfaceMimetypeService
- Returns:
- all mimetypes
-
getMimetypesByExtension
Description copied from interface:MimetypeService
Get all mimetypes indexed by extension- Specified by:
getMimetypesByExtension
in interfaceMimetypeService
- Returns:
- the map of mimetypes indexed by extension
-
isText
Description copied from interface:MimetypeService
Check if a given mimetype represents a text format.- Specified by:
isText
in interfaceMimetypeService
- Parameters:
mimetype
- the mimetype to check- Returns:
- Returns true if it is text
-
getMimetypeIfNotMatches
Use Apache Tika to check if the mime type of the document really matches what it claims to be. This is typically used when a transformation or metadata extractions fails, and you want to know if someone has renamed a file and consequently it has the wrong mime type.- Specified by:
getMimetypeIfNotMatches
in interfaceMimetypeService
- Returns:
- Null if the mime type seems ok, otherwise the mime type it probably is
-
guessMimetype
Takes a guess at the mimetype based exclusively on the file extension, which can (and often is) wrong...- Specified by:
guessMimetype
in interfaceMimetypeService
- Parameters:
filename
- the name of the file with an optional file extension- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
- See Also:
-
guessMimetype
Uses Tika to try to identify the mimetype of the file, falling back onguessMimetype(String)
for an extension based one if Tika can't help.- Specified by:
guessMimetype
in interfaceMimetypeService
- Parameters:
filename
- the name of the file with an optional file extensionreader
- a reader for the content of the file- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
-
guessMimetype
Uses Tika to try to identify the mimetype of the file, falling back onguessMimetype(String)
for an extension based one if Tika can't help.- Specified by:
guessMimetype
in interfaceMimetypeService
- Parameters:
filename
- the name of the file with an optional file extensioninput
- an input stream for the content- Returns:
- Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.
-
getMimetypes
Returns a collection of mimetypes ordered by extension.- Specified by:
getMimetypes
in interfaceMimetypeService
- Parameters:
extension
- to restrict the collection to one entry
-