Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.mimetype.interfaces
Interface MimetypeRegistry

All Known Subinterfaces:
MimetypeRegistryLocal
All Known Implementing Classes:
MimetypeRegistryBean, MimetypeRegistryService

public interface MimetypeRegistry

MimetypeEntry registry.

Flexible registry of mimetypes.

Author:
Julien Anguenot

Field Summary
static java.lang.String DEFAULT_MIMETYPE
           
 
Method Summary
 java.util.List<java.lang.String> getExtensionsFromMimetypeName(java.lang.String mimetypeName)
          Returns the extension for given mimetype.
 MimetypeEntry getMimetypeEntryByMimeType(java.lang.String mimetype)
          Gets a mimetype entry given the normalized mimetype.
 MimetypeEntry getMimetypeEntryByName(java.lang.String name)
          Gets a mimetype entry by name.
 java.lang.String getMimetypeFromBlob(Blob blob)
          Returns the mime type from a given stream.
 java.lang.String getMimetypeFromBlobWithDefault(Blob blob, java.lang.String defaultMimetype)
          Returns the mime type from a given blob or provided default if not possible.
 java.lang.String getMimetypeFromFile(java.io.File file)
          Returns the mime type given a file.
 java.lang.String getMimetypeFromFilenameAndBlobWithDefault(java.lang.String filename, Blob blob, java.lang.String defaultMimetype)
          Finds the mimetype of some content according to its filename and / or binary content.
 java.lang.String getMimetypeFromStream(java.io.InputStream stream)
          Returns the mime type from a given stream.
 java.lang.String getMimetypeFromStreamWithDefault(java.io.InputStream is, java.lang.String defaultMimetype)
          Returns the mime type from a given stream or provided default if not possible.
 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, java.lang.String filename)
          Update the mimetype field of a Blob based on the provided filename with fallback to binary sniffing.
 

Field Detail

DEFAULT_MIMETYPE

static final java.lang.String DEFAULT_MIMETYPE
See Also:
Constant Field Values
Method Detail

getMimetypeFromStream

java.lang.String getMimetypeFromStream(java.io.InputStream stream)
                                       throws MimetypeNotFoundException,
                                              MimetypeDetectionException
Returns the mime type from a given stream.

Returns:
String mimetype name.
Throws:
MimetypeNotFoundException - if mimetype sniffing failed to identify a registered mime type
MimetypeDetectionException - if unexpected problem prevent the detection to work as expected

getMimetypeFromBlob

java.lang.String getMimetypeFromBlob(Blob blob)
                                     throws MimetypeNotFoundException,
                                            MimetypeDetectionException
Returns the mime type from a given stream.

Returns:
String mimetype name.
Throws:
MimetypeNotFoundException - if mimetype sniffing failed to identify a registered mime type
MimetypeDetectionException - if unexpected problem prevent the detection to work as expected

getMimetypeFromBlobWithDefault

java.lang.String getMimetypeFromBlobWithDefault(Blob blob,
                                                java.lang.String defaultMimetype)
                                                throws MimetypeDetectionException
Returns the mime type from a given blob or provided default if not possible.

Throws:
MimetypeDetectionException

getMimetypeFromStreamWithDefault

java.lang.String getMimetypeFromStreamWithDefault(java.io.InputStream is,
                                                  java.lang.String defaultMimetype)
                                                  throws MimetypeDetectionException
Returns the mime type from a given stream or provided default if not possible.

Throws:
MimetypeDetectionException

getMimetypeFromFile

java.lang.String getMimetypeFromFile(java.io.File file)
                                     throws MimetypeNotFoundException,
                                            MimetypeDetectionException
Returns the mime type given a file.

Returns:
string containing the mime type
Throws:
MimetypeNotFoundException - if mimetype sniffing failed
MimetypeDetectionException - if unexpected problem prevent the detection to work as expected

getExtensionsFromMimetypeName

java.util.List<java.lang.String> getExtensionsFromMimetypeName(java.lang.String mimetypeName)
Returns the extension for given mimetype.

Parameters:
mimetypeName - the mimetype name.
Returns:
a list of strings containing the possible extensions.

getMimetypeEntryByName

MimetypeEntry getMimetypeEntryByName(java.lang.String name)
Gets a mimetype entry by name.

Parameters:
name - the mimetype name.
Returns:
mimetype instance

getMimetypeEntryByMimeType

MimetypeEntry getMimetypeEntryByMimeType(java.lang.String mimetype)
Gets a mimetype entry given the normalized mimetype.

Parameters:
mimetype - the normalized mimetype
Returns:
mimetype instance

getMimetypeFromFilenameAndBlobWithDefault

java.lang.String getMimetypeFromFilenameAndBlobWithDefault(java.lang.String filename,
                                                           Blob blob,
                                                           java.lang.String defaultMimetype)
                                                           throws MimetypeDetectionException
Finds the mimetype of some content according to its filename and / or binary content.

Parameters:
filename - extension to analyze
blob - content to be analyzed if filename is ambiguous
defaultMimetype - defaultMimeType to be used if no found
Returns:
the string mimetype
Throws:
MimetypeDetectionException

updateMimetype

Blob updateMimetype(Blob blob,
                    java.lang.String filename)
                    throws MimetypeDetectionException
Update the mimetype field of a Blob based on the provided filename with fallback to binary sniffing. If the embedded filename is null, the provided filename is embedded into the blob as well.

Parameters:
blob - content to be analyzed if filename is ambiguous
filename - with extension to analyze
Returns:
updated blob (persisted if necessary)
Throws:
MimetypeDetectionException

updateMimetype

Blob updateMimetype(Blob blob)
                    throws MimetypeDetectionException
Update the mimetype field of a Blob based on the embedded filename with fallback to binary sniffing. This method should not be called if the embedded filename is null for performance reasons (+ the fact that binary sniffing is no very reliable).

Parameters:
blob - content to be analyzed if filename is ambiguous
Returns:
updated blob (persisted if necessary)
Throws:
MimetypeDetectionException

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.