Nuxeo ECM Projects 5.4.3-SNAPSHOT

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

All Known Implementing Classes:
MimetypeRegistryService

public interface MimetypeRegistry

MimetypeEntry registry.

Flexible registry of mimetypes.

Author:
Julien Anguenot

Field Summary
static String DEFAULT_MIMETYPE
           
 
Method Summary
 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)
          Returns the mime type from a given blob or provided default if not possible.
 String getMimetypeFromFile(File file)
          Returns the mime type given a file.
 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)
          Returns the mime type from a given stream.
 String getMimetypeFromStreamWithDefault(InputStream is, 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, 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 String DEFAULT_MIMETYPE
See Also:
Constant Field Values
Method Detail

getMimetypeFromStream

String getMimetypeFromStream(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

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

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

Throws:
MimetypeDetectionException

getMimetypeFromStreamWithDefault

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

Throws:
MimetypeDetectionException

getMimetypeFromFile

String getMimetypeFromFile(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

List<String> getExtensionsFromMimetypeName(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(String name)
Gets a mimetype entry by name.

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

getMimetypeEntryByMimeType

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

Parameters:
mimetype - the normalized mimetype
Returns:
mimetype instance

getMimetypeFromFilenameAndBlobWithDefault

String getMimetypeFromFilenameAndBlobWithDefault(String filename,
                                                 Blob blob,
                                                 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,
                    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 ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.