Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.mimetype.ejb
Class MimetypeRegistryBean

java.lang.Object
  extended by org.nuxeo.ecm.platform.mimetype.ejb.MimetypeRegistryBean
All Implemented Interfaces:
MimetypeRegistryLocal, MimetypeRegistry

public class MimetypeRegistryBean
extends java.lang.Object
implements MimetypeRegistryLocal

MimetypeEntry registry bean.

EJB Facade on the mimetype registry service.

Author:
Julien Anguenot

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.platform.mimetype.interfaces.MimetypeRegistry
DEFAULT_MIMETYPE
 
Constructor Summary
MimetypeRegistryBean()
           
 
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)
          Deprecated. 
 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)
          Deprecated. 
 java.lang.String getMimetypeFromStreamWithDefault(java.io.InputStream is, java.lang.String defaultMimetype)
          Deprecated. 
 void registerFileExtension(ExtensionDescriptor extension)
           
 void registerMimetype(MimetypeEntry mimetype)
           
 void unregisterFileExtension(ExtensionDescriptor extension)
           
 void unregisterMimetype(java.lang.String mimetype)
           
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimetypeRegistryBean

public MimetypeRegistryBean()
Method Detail

getExtensionsFromMimetypeName

public java.util.List<java.lang.String> getExtensionsFromMimetypeName(java.lang.String mimetypeName)
Description copied from interface: MimetypeRegistry
Returns the extension for given mimetype.

Specified by:
getExtensionsFromMimetypeName in interface MimetypeRegistry
Parameters:
mimetypeName - the mimetype name.
Returns:
a list of strings containing the possible extensions.

getMimetypeFromFile

public java.lang.String getMimetypeFromFile(java.io.File file)
                                     throws MimetypeNotFoundException,
                                            MimetypeDetectionException
Description copied from interface: MimetypeRegistry
Returns the mime type given a file.

Specified by:
getMimetypeFromFile in interface MimetypeRegistry
Returns:
string containing the mime type
Throws:
MimetypeNotFoundException - if mimetype sniffing failed
MimetypeDetectionException - if unexpected problem prevent the detection to work as expected

getMimetypeFromStream

@Deprecated
public java.lang.String getMimetypeFromStream(java.io.InputStream stream)
                                       throws MimetypeNotFoundException,
                                              MimetypeDetectionException
Deprecated. 

Description copied from interface: MimetypeRegistry
Returns the mime type from a given stream.

Specified by:
getMimetypeFromStream in interface MimetypeRegistry
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

getMimetypeFromStreamWithDefault

@Deprecated
public java.lang.String getMimetypeFromStreamWithDefault(java.io.InputStream is,
                                                                    java.lang.String defaultMimetype)
                                                  throws MimetypeDetectionException
Deprecated. 

Description copied from interface: MimetypeRegistry
Returns the mime type from a given stream or provided default if not possible.

Specified by:
getMimetypeFromStreamWithDefault in interface MimetypeRegistry
Throws:
MimetypeDetectionException

getMimetypeFromBlob

public java.lang.String getMimetypeFromBlob(Blob blob)
                                     throws MimetypeNotFoundException,
                                            MimetypeDetectionException
Description copied from interface: MimetypeRegistry
Returns the mime type from a given stream.

Specified by:
getMimetypeFromBlob in interface MimetypeRegistry
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

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

Specified by:
getMimetypeFromBlobWithDefault in interface MimetypeRegistry
Throws:
MimetypeDetectionException

getMimetypeFromFilenameAndBlobWithDefault

public java.lang.String getMimetypeFromFilenameAndBlobWithDefault(java.lang.String filename,
                                                                  Blob blob,
                                                                  java.lang.String defaultMimetype)
                                                           throws MimetypeDetectionException
Description copied from interface: MimetypeRegistry
Finds the mimetype of some content according to its filename and / or binary content.

Specified by:
getMimetypeFromFilenameAndBlobWithDefault in interface MimetypeRegistry
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

getMimetypeEntryByName

@Deprecated
public MimetypeEntry getMimetypeEntryByName(java.lang.String name)
Deprecated. 

Description copied from interface: MimetypeRegistry
Gets a mimetype entry by name.

Specified by:
getMimetypeEntryByName in interface MimetypeRegistry
Parameters:
name - the mimetype name.
Returns:
mimetype instance

getMimetypeEntryByMimeType

public MimetypeEntry getMimetypeEntryByMimeType(java.lang.String mimetype)
Description copied from interface: MimetypeRegistry
Gets a mimetype entry given the normalized mimetype.

Specified by:
getMimetypeEntryByMimeType in interface MimetypeRegistry
Parameters:
mimetype - the normalized mimetype
Returns:
mimetype instance

registerMimetype

public void registerMimetype(MimetypeEntry mimetype)
Specified by:
registerMimetype in interface MimetypeRegistryLocal

unregisterMimetype

public void unregisterMimetype(java.lang.String mimetype)
Specified by:
unregisterMimetype in interface MimetypeRegistryLocal

registerFileExtension

public void registerFileExtension(ExtensionDescriptor extension)
Specified by:
registerFileExtension in interface MimetypeRegistryLocal

unregisterFileExtension

public void unregisterFileExtension(ExtensionDescriptor extension)
Specified by:
unregisterFileExtension in interface MimetypeRegistryLocal

updateMimetype

public Blob updateMimetype(Blob blob,
                           java.lang.String filename)
                    throws MimetypeDetectionException
Description copied from interface: MimetypeRegistry
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.

Specified by:
updateMimetype in interface MimetypeRegistry
Parameters:
blob - content to be analyzed if filename is ambiguous
filename - with extension to analyze
Returns:
updated blob (persisted if necessary)
Throws:
MimetypeDetectionException

updateMimetype

public Blob updateMimetype(Blob blob)
                    throws MimetypeDetectionException
Description copied from interface: MimetypeRegistry
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).

Specified by:
updateMimetype in interface MimetypeRegistry
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.