Class DefaultConvertedMediaCreationStrategy
java.lang.Object
de.hybris.platform.mediaconversion.conversion.DefaultConvertedMediaCreationStrategy
- All Implemented Interfaces:
ConvertedMediaCreationStrategy
public class DefaultConvertedMediaCreationStrategy
extends Object
implements ConvertedMediaCreationStrategy
Default implementation of the
ConvertedMediaCreationStrategy.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcreateCode(MediaModel parent, MediaFormatModel format) Assembles the code to use for the newly created media.protected StringcreateFileName(MediaModel parent, ConversionMediaFormatModel format) Assembles a file name for the newly created media.protected StringcreateMime(MediaModel parent, ConversionMediaFormatModel format) Assembles the mime type to be set on the newly created media.protected MediaModelCreates theMediaModelof which all relevant attributes will be set.createOrUpdate(MediaModel parent, ConversionMediaFormatModel format, InputStream content) Creates a new media which was converted from the givenparentby successful conversion to the givenformator updates the corresponding media if it already exists.Accesses theModelServiceto use.protected voidloadContents(MediaModel dmm, MediaModel parent, ConversionMediaFormatModel format, InputStream inputStream) Load the data from the givenInputStreamand stores them to theMediaModel.voidsetMediaService(MediaService mediaService) voidsetModelService(ModelService modelService) Sets theModelServiceto use (for Spring IoC).
-
Constructor Details
-
DefaultConvertedMediaCreationStrategy
public DefaultConvertedMediaCreationStrategy()
-
-
Method Details
-
createOrUpdate
public MediaModel createOrUpdate(MediaModel parent, ConversionMediaFormatModel format, InputStream content) throws MediaIOException Creates a new media which was converted from the givenparentby successful conversion to the givenformator updates the corresponding media if it already exists. The passedInputStreamcontentmust be used to load the media's data.The
MediaServiceis passed to avoid circular dependencies.- Specified by:
createOrUpdatein 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-InputStreamholding the converted content.- Returns:
- a new
MediaModel - Throws:
MediaIOException- on any technical error when loading the contents- See Also:
-
createModel
Creates theMediaModelof 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, InputStream inputStream) Load the data from the givenInputStreamand stores them to theMediaModel.- Parameters:
dmm- theMediaModelto store the data to.parent- the parentMediaModelformat- the format of the newMediaModelin- theInputStreamcontaining the new medias data.- See Also:
-
createMime
Assembles the mime type to be set on the newly created media.- Parameters:
parent- the parentMediaModelformat- the format of the newMediaModel- Returns:
- the mime type to use.
-
createFileName
Assembles a file name for the newly created media.This implementation will simply use the code.
- Parameters:
parent- the parentMediaModelformat- the format of the newMediaModel- Returns:
- the filename to use for the new media
- See Also:
-
createCode
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 parentMediaModelformat- the format of the newMediaModel- Returns:
- the code to use for the new media.
-
getModelService
Accesses theModelServiceto use.- Returns:
- the
ModelService
-
setModelService
Sets theModelServiceto use (for Spring IoC).- Parameters:
modelService- a niceModelServiceto use.
-
getMediaService
-
setMediaService
-