|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.nuxeo.runtime.model.DefaultComponent org.nuxeo.ecm.platform.mimetype.service.MimetypeRegistryService
public class MimetypeRegistryService
MimetypeEntry registry service.
Singleton holding a registry of mimetype entries and exposes an API to grab information related to these mimetypes. As well, this is possible to ask for a mimetype magic detection from a stream or file using the API.
Field Summary | |
---|---|
static ComponentName |
NAME
|
Fields inherited from interface org.nuxeo.ecm.platform.mimetype.interfaces.MimetypeRegistry |
---|
DEFAULT_MIMETYPE |
Constructor Summary | |
---|---|
MimetypeRegistryService()
|
Method Summary | |
---|---|
void |
activate(ComponentContext context)
Activates the component. |
void |
deactivate(ComponentContext context)
Deactivates the component. |
RuntimeContext |
getContext()
|
List<String> |
getExtensionsFromMimetypeName(String mimetypeName)
Returns the extension for given mimetype. |
MimetypeEntry |
getMimetypeEntryByMimeType(String mimetype)
Gets a mimetype entry given the normalized mimetype. |
MimetypeEntry |
getMimetypeEntryByName(String name)
Gets a mimetype entry by name. |
String |
getMimetypeFromBlob(Blob blob)
Returns the mime type from a given stream. |
String |
getMimetypeFromBlobWithDefault(Blob blob,
String defaultMimetype)
Finds the mimetype of a Blob content and returns provided default if not possible. |
String |
getMimetypeFromExtension(String extension)
|
String |
getMimetypeFromFile(File file)
Returns the mime type given a file. |
String |
getMimetypeFromFilename(String filename)
|
String |
getMimetypeFromFilenameAndBlobWithDefault(String filename,
Blob blob,
String defaultMimetype)
Finds the mimetype of some content according to its filename and / or binary content. |
String |
getMimetypeFromStream(InputStream stream)
Deprecated. |
String |
getMimetypeFromStreamWithDefault(InputStream is,
String defaultMimetype)
Deprecated. |
void |
registerExtension(Extension extension)
Registers the given extension. |
void |
registerFileExtension(ExtensionDescriptor extensionDescriptor)
|
void |
registerMimetype(MimetypeEntry mimetype)
|
void |
unregisterExtension(Extension extension)
Unregisters the given extension. |
void |
unregisterFileExtension(ExtensionDescriptor extensionDescriptor)
|
void |
unregisterMimetype(String mimetypeName)
|
Blob |
updateMimetype(Blob blob)
Update the mimetype field of a Blob based on the embedded filename with fallback to binary sniffing. |
Blob |
updateMimetype(Blob blob,
String filename)
Update the mimetype field of a Blob based on the provided filename with fallback to binary sniffing. |
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent |
---|
applicationStarted, getAdapter, registerContribution, unregisterContribution |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ComponentName NAME
Constructor Detail |
---|
public MimetypeRegistryService()
Method Detail |
---|
public void activate(ComponentContext context)
Component
This method is called by the runtime when a component is activated.
activate
in interface Component
activate
in class DefaultComponent
context
- the runtime contextpublic void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void registerExtension(Extension extension)
Extensible
registerExtension
in interface Extensible
registerExtension
in class DefaultComponent
extension
- the extension to registerpublic void registerMimetype(MimetypeEntry mimetype)
public void registerFileExtension(ExtensionDescriptor extensionDescriptor)
public void unregisterExtension(Extension extension)
Extensible
unregisterExtension
in interface Extensible
unregisterExtension
in class DefaultComponent
extension
- the extension to unregisterpublic void unregisterMimetype(String mimetypeName)
public void unregisterFileExtension(ExtensionDescriptor extensionDescriptor)
public RuntimeContext getContext()
public List<String> getExtensionsFromMimetypeName(String mimetypeName)
MimetypeRegistry
getExtensionsFromMimetypeName
in interface MimetypeRegistry
mimetypeName
- the mimetype name.
public MimetypeEntry getMimetypeEntryByName(String name)
MimetypeRegistry
getMimetypeEntryByName
in interface MimetypeRegistry
name
- the mimetype name.
public String getMimetypeFromFile(File file) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeRegistry
getMimetypeFromFile
in interface MimetypeRegistry
MimetypeNotFoundException
- if mimetype sniffing failed
MimetypeDetectionException
- if unexpected problem prevent the
detection to work as expectedpublic String getMimetypeFromExtension(String extension) throws MimetypeNotFoundException
MimetypeNotFoundException
public String getMimetypeFromFilename(String filename) throws MimetypeNotFoundException
MimetypeNotFoundException
@Deprecated public String getMimetypeFromStream(InputStream stream) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeRegistry
getMimetypeFromStream
in interface MimetypeRegistry
MimetypeNotFoundException
- if mimetype sniffing failed to identify
a registered mime type
MimetypeDetectionException
- if unexpected problem prevent the
detection to work as expected@Deprecated public String getMimetypeFromStreamWithDefault(InputStream is, String defaultMimetype) throws MimetypeDetectionException
getMimetypeFromStreamWithDefault
in interface MimetypeRegistry
is
- content to be analyzeddefaultMimetype
- default mimetype to be used if no found
MimetypeDetectionException
public String getMimetypeFromBlob(Blob blob) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeRegistry
getMimetypeFromBlob
in interface MimetypeRegistry
MimetypeNotFoundException
- if mimetype sniffing failed to identify
a registered mime type
MimetypeDetectionException
- if unexpected problem prevent the
detection to work as expectedpublic MimetypeEntry getMimetypeEntryByMimeType(String mimetype)
MimetypeRegistry
getMimetypeEntryByMimeType
in interface MimetypeRegistry
mimetype
- the normalized mimetype
public String getMimetypeFromBlobWithDefault(Blob blob, String defaultMimetype) throws MimetypeDetectionException
getMimetypeFromBlobWithDefault
in interface MimetypeRegistry
blob
- content to be analyzeddefaultMimetype
- defaultMimeType to be used if no found
MimetypeDetectionException
public String getMimetypeFromFilenameAndBlobWithDefault(String filename, Blob blob, String defaultMimetype) throws MimetypeDetectionException
getMimetypeFromFilenameAndBlobWithDefault
in interface MimetypeRegistry
filename
- extension to analyzeblob
- content to be analyzed if filename is ambiguousdefaultMimetype
- defaultMimeType to be used if no found
MimetypeDetectionException
public Blob updateMimetype(Blob blob, String filename) throws MimetypeDetectionException
MimetypeRegistry
updateMimetype
in interface MimetypeRegistry
blob
- content to be analyzed if filename is ambiguousfilename
- with extension to analyze
MimetypeDetectionException
public Blob updateMimetype(Blob blob) throws MimetypeDetectionException
MimetypeRegistry
updateMimetype
in interface MimetypeRegistry
blob
- content to be analyzed if filename is ambiguous
MimetypeDetectionException
|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |