Class DefaultConvertedMediaCreationStrategy
- java.lang.Object
-
- de.hybris.platform.mediaconversion.conversion.DefaultConvertedMediaCreationStrategy
-
- All Implemented Interfaces:
ConvertedMediaCreationStrategy
public class DefaultConvertedMediaCreationStrategy extends java.lang.Object implements ConvertedMediaCreationStrategy
Default implementation of theConvertedMediaCreationStrategy
.
-
-
Constructor Summary
Constructors Constructor Description DefaultConvertedMediaCreationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createCode(MediaModel parent, MediaFormatModel format)
Assembles the code to use for the newly created media.protected java.lang.String
createFileName(MediaModel parent, ConversionMediaFormatModel format)
Assembles a file name for the newly created media.protected java.lang.String
createMime(MediaModel parent, ConversionMediaFormatModel format)
Assembles the mime type to be set on the newly created media.protected MediaModel
createModel()
Creates theMediaModel
of which all relevant attributes will be set.MediaModel
createOrUpdate(MediaModel parent, ConversionMediaFormatModel format, java.io.InputStream content)
Creates a new media which was converted from the givenparent
by successful conversion to the givenformat
or updates the corresponding media if it already exists.MediaService
getMediaService()
ModelService
getModelService()
Accesses theModelService
to use.protected void
loadContents(MediaModel dmm, MediaModel parent, ConversionMediaFormatModel format, java.io.InputStream inputStream)
Load the data from the givenInputStream
and stores them to theMediaModel
.void
setMediaService(MediaService mediaService)
void
setModelService(ModelService modelService)
Sets theModelService
to use (for Spring IoC).
-
-
-
Method Detail
-
createOrUpdate
public MediaModel createOrUpdate(MediaModel parent, ConversionMediaFormatModel format, java.io.InputStream content) throws MediaIOException
Creates a new media which was converted from the givenparent
by successful conversion to the givenformat
or updates the corresponding media if it already exists. The passedInputStream
content
must be used to load the media's data.The
MediaService
is passed to avoid circular dependencies.- Specified by:
createOrUpdate
in interfaceConvertedMediaCreationStrategy
- Parameters:
parent
- the media the to-be-created media was converted from. This model should be set as the newly created media's parent.format
- the format of the to-be-created media. This object should be set as the newly created media's format.content
-InputStream
holding the converted content.- Returns:
- a new
MediaModel
- Throws:
MediaIOException
- on any technical error when loading the contents- See Also:
ConvertedMediaCreationStrategy.createOrUpdate(MediaModel, ConversionMediaFormatModel, InputStream)
-
createModel
protected MediaModel createModel()
Creates theMediaModel
of which all relevant attributes will be set. This is a good method to override if you what- to have a different type to be created
- or if you want to set additional attributes
- Returns:
- a plain, boring, but fresh new
MediaModel
.
-
loadContents
protected void loadContents(MediaModel dmm, MediaModel parent, ConversionMediaFormatModel format, java.io.InputStream inputStream)
Load the data from the givenInputStream
and stores them to theMediaModel
.- Parameters:
dmm
- theMediaModel
to store the data to.parent
- the parentMediaModel
format
- the format of the newMediaModel
in
- theInputStream
containing the new medias data.- See Also:
MediaService.setStreamForMedia(MediaModel, InputStream)
-
createMime
protected java.lang.String createMime(MediaModel parent, ConversionMediaFormatModel format)
Assembles the mime type to be set on the newly created media.- Parameters:
parent
- the parentMediaModel
format
- the format of the newMediaModel
- Returns:
- the mime type to use.
-
createFileName
protected java.lang.String createFileName(MediaModel parent, ConversionMediaFormatModel format)
Assembles a file name for the newly created media.This implementation will simply use the code.
- Parameters:
parent
- the parentMediaModel
format
- the format of the newMediaModel
- Returns:
- the filename to use for the new media
- See Also:
createCode(MediaModel, MediaFormatModel)
,AbstractMediaModel.getRealFileName()
-
createCode
protected java.lang.String createCode(MediaModel parent, MediaFormatModel format)
Assembles the code to use for the newly created media.This implementation will return the concatenation of the parent's code and the format's qualifier (with a underscore between 'em).
- Parameters:
parent
- the parentMediaModel
format
- the format of the newMediaModel
- Returns:
- the code to use for the new media.
-
getModelService
public ModelService getModelService()
Accesses theModelService
to use.- Returns:
- the
ModelService
-
setModelService
public void setModelService(ModelService modelService)
Sets theModelService
to use (for Spring IoC).- Parameters:
modelService
- a niceModelService
to use.
-
getMediaService
public MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
-