|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.ma2.support.AbstractMediaHandler magoffin.matt.ma2.support.BasicIconBasedMediaHandler
public class BasicIconBasedMediaHandler
Base handler for media types that are icon-based.
This handler provides support for metadata-based images if available,
otherwise an icon is used. For icon resolution, the item's MIME type will
be used to search for a PNG image icon using the getIconResourcePathPrefix()
path as the prefix, .png
as a suffix, and the following
search paths will be tried:
For example, for an item with a file name my-video.mpg
and with a
MIME type of video/mpeg
and the default
iconResourcePathPrefix
, the following paths will be tried:
The configurable properties of this class are:
MediaHandler
implementation to handle the embedded image
of the metadata, if available.ResourceLoader
to use for loading icon resources. Defaults
to a DefaultResourceLoader
instance.DEFAULT_FALLBACK_ICON_NAME
.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_FALLBACK_ICON_NAME
The default value for the fallbackIconName property. |
static java.lang.String |
DEFAULT_ICON_RESOURCE_PATH_PREFIX
The default value for the iconResourcePathPrefix property. |
static java.lang.String |
EMBEDDED_IMAGE_MIME_TYPE_METADATA_KEY
The MediaMetadata key for the embedded image MIME type. |
Fields inherited from class magoffin.matt.ma2.support.AbstractMediaHandler |
---|
log, METADATA_PARAMETER_KEY |
Constructor Summary | |
---|---|
BasicIconBasedMediaHandler(java.lang.String mime,
java.lang.String preferredFileExtension)
Construct with a MIME type. |
Method Summary | |
---|---|
MediaItem |
createNewMediaItem(java.io.File inputFile)
Create a new instance of MediaItem from a File. |
protected void |
defaultHandleIconResponse(MediaItem item,
MediaRequest request,
MediaResponse response)
Default handler for returning an icon response. |
protected void |
defaultHandleRequest(MediaItem item,
MediaRequest request,
MediaResponse response)
Default handler for media requests. |
MediaEffect |
getEffect(java.lang.String key,
java.util.Map<java.lang.String,?> effectParameters)
Get a MediaEffect instance for a specific key. |
java.lang.String |
getFallbackIconName()
|
java.lang.String |
getFileExtension(MediaItem item,
MediaRequest request)
Get the file extension. |
java.lang.String |
getIconResourcePathPrefix()
|
MediaHandlerDelegate |
getImageMediaRequestDelegate()
|
org.springframework.core.io.ResourceLoader |
getResourceLoader()
|
void |
handleMediaRequest(MediaItem item,
MediaRequest request,
MediaResponse response)
Basic JMagick implementation of handleMediaRequest. |
void |
setFallbackIconName(java.lang.String fallbackIconName)
|
void |
setIconResourcePathPrefix(java.lang.String iconResourcePathPrefix)
|
void |
setImageMediaRequestDelegate(MediaHandlerDelegate imageMediaRequestDelegate)
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
|
Methods inherited from class magoffin.matt.ma2.support.AbstractMediaHandler |
---|
applyEffects, createMetadataList, defaultHandleRequestOriginal, getDomainObjectFactory, getMediaBiz, getMediaMetadataInstance, getMime, getNoWatermarkSizes, getPreferredFileExtension, getRequestEffects, getSmetaPropertyMap, getUserBiz, handleMetadata, needToAlter, needToRotate, setDomainObjectFactory, setMediaBiz, setMime, setNoWatermarkSizes, setPreferredFileExtension, setSmetaPropertyMap, setUserBiz |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String EMBEDDED_IMAGE_MIME_TYPE_METADATA_KEY
MediaMetadata
key for the embedded image MIME type.
public static final java.lang.String DEFAULT_ICON_RESOURCE_PATH_PREFIX
iconResourcePathPrefix
property.
public static final java.lang.String DEFAULT_FALLBACK_ICON_NAME
fallbackIconName
property.
Constructor Detail |
---|
public BasicIconBasedMediaHandler(java.lang.String mime, java.lang.String preferredFileExtension)
mime
- the MIMEpreferredFileExtension
- the preferred file extensionMethod Detail |
---|
public MediaItem createNewMediaItem(java.io.File inputFile)
MediaHandler
This method will be called when a new media item is to be
added into Matte. This method should populate as much information
as it can extract from the file into a MediaItem
instance,
including populating any Metadata
it can extract from the file.
This method does not need to persist the MediaItem
instance,
just populate it and return it.
inputFile
- the file to create the media item from
public void handleMediaRequest(MediaItem item, MediaRequest request, MediaResponse response)
This implementation simply calls
defaultHandleRequest(MediaItem, MediaRequest, MediaResponse)
.
item
- the media item to processrequest
- the requestresponse
- the responsepublic java.lang.String getFileExtension(MediaItem item, MediaRequest request)
AbstractMediaHandler
This method simply returns AbstractMediaHandler.getPreferredFileExtension()
.
Extending class may override this for request-specific handling.
getFileExtension
in interface MediaHandler
getFileExtension
in class AbstractMediaHandler
item
- the media item to processrequest
- the request
public MediaEffect getEffect(java.lang.String key, java.util.Map<java.lang.String,?> effectParameters)
MediaHandler
Implementaions must define the keys they support, and define the parameters that go with it.
getEffect
in interface MediaHandler
getEffect
in class AbstractMediaHandler
key
- the key of the desired effecteffectParameters
- a Map of parameters (optional)
protected void defaultHandleRequest(MediaItem item, MediaRequest request, MediaResponse response)
item
- the itemrequest
- the requestresponse
- the responseprotected void defaultHandleIconResponse(MediaItem item, MediaRequest request, MediaResponse response)
item
- the itemrequest
- the requestresponse
- the responsepublic MediaHandlerDelegate getImageMediaRequestDelegate()
public void setImageMediaRequestDelegate(MediaHandlerDelegate imageMediaRequestDelegate)
imageMediaRequestDelegate
- the imageMediaRequestDelegate to setpublic java.lang.String getIconResourcePathPrefix()
public void setIconResourcePathPrefix(java.lang.String iconResourcePathPrefix)
iconResourcePathPrefix
- the iconResourcePathPrefix to setpublic java.lang.String getFallbackIconName()
public void setFallbackIconName(java.lang.String fallbackIconName)
fallbackIconName
- the fallbackIconName to setpublic org.springframework.core.io.ResourceLoader getResourceLoader()
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
resourceLoader
- the resourceLoader to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |