Class DefaultMediaConversionService
java.lang.Object
de.hybris.platform.mediaconversion.conversion.DefaultMediaConversionService
- All Implemented Interfaces:
MediaConversionService,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware
public class DefaultMediaConversionService
extends Object
implements MediaConversionService, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Default
MediaConversionService implementation.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidconvertMedias(MediaContainerModel container) Converts theMediaContainerModel's master media to all formats which are currently not present in the givenMediaContainerModel.intdeleteConvertedMedias(MediaContainerModel container) Removes all converted medias within the specifiedMediaContainerModel.protected MediaModeldoConvert(MediaContainerModel container, ConversionMediaFormatModel format) Retrieves all configuredConversionMediaFormatModelfrom database.org.springframework.context.ApplicationContextComputes the currentConversionStatusfor the givenMediaContainerModel.getConvertedMedias(MediaContainerModel container) Retrieves all converted medias in the givenMediaContainerModel, i.e.getDao()getMaster(MediaContainerModel model) Retrieves the current 'master'MediaModelof the givenMediaContainerModel.protected MediaConversionStrategygetOrConvert(MediaContainerModel container, MediaFormatModel format) Retrieves theMediaModelin the specifiedMediaFormatModelassociated with the givenMediaContainerModel.protected MediaModelgetUpToDateMediaByFormat(MediaContainerModel container, MediaFormatModel format) Retrieves the media in the given format and checks whether it is up to date.protected booleanisUpToDate(MediaModel ret) Checks whether a media is up to date.protected Collection<MediaModel>selectDerivedMedias(MediaContainerModel container) Naive approach to determine the derived medias of anMediaContainerModel.protected MediaModelNaive approach to determine the master of anMediaContainerModel.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidvoidvoidvoidsetMediaService(MediaService mediaService) voidsetModelService(ModelService modelService)
-
Constructor Details
-
DefaultMediaConversionService
public DefaultMediaConversionService()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- See Also:
-
InitializingBean.afterPropertiesSet()
-
deleteConvertedMedias
Removes all converted medias within the specifiedMediaContainerModel.- Specified by:
deleteConvertedMediasin interfaceMediaConversionService- Parameters:
container- theMediaContainerModelto clean up- Returns:
- the number of medias removed
- See Also:
-
getConvertedMedias
Retrieves all converted medias in the givenMediaContainerModel, i.e. all medias within this container which have a parent and a format set.- Specified by:
getConvertedMediasin interfaceMediaConversionService- Parameters:
container- theMediaContainerModelin question.- Returns:
- A collection of all converted medias in the given
MediaContainerModel. - See Also:
-
selectDerivedMedias
Naive approach to determine the derived medias of anMediaContainerModel. This method is just used if the container is not persisted yet, otherwise a query on the database if used.- Parameters:
container- the container to determine the derived medias for- Returns:
- collection of derived medias of the given container
- See Also:
-
convertMedias
Converts theMediaContainerModel's master media to all formats which are currently not present in the givenMediaContainerModel.- Specified by:
convertMediasin interfaceMediaConversionService- Parameters:
container- theMediaContainerModelto 'fill up'.- See Also:
-
getAllConversionFormats
Retrieves all configuredConversionMediaFormatModelfrom database.- Specified by:
getAllConversionFormatsin interfaceMediaConversionService- Returns:
- all currently configured
ConversionMediaFormatModels. - See Also:
-
getConversionStatus
Computes the currentConversionStatusfor the givenMediaContainerModel. The conversion status isConversionStatus.EMPTY, if the container has no master, orConversionStatus.UNCONVERTED, if there are none of the target formats available,ConversionStatus.PARTIALLY_CONVERTED, if there are some of the target formats available, orConversionStatus.CONVERTED, if all of the target formats are available.
- the
supportedFormatof the assignedConversionGroupModelor - all
ConversionMediaFormatModelinstances in the system, if noConversionGroupModelis set on the givenMediaContainerModel
- Specified by:
getConversionStatusin interfaceMediaConversionService- Parameters:
model- theMediaContainerModelto compute the conversion status for- Returns:
- the current
ConversionStatusfor the givenMediaContainerModel - See Also:
-
getMaster
Retrieves the current 'master'MediaModelof the givenMediaContainerModel. The master media is defined as theMediaModelwithin theMediaContainerModelwhich has no original and no original data pk set (attributesMediaModel.ORIGINALandMediaModel.ORIGINALDATAPK).- Specified by:
getMasterin interfaceMediaConversionService- Parameters:
model- theMediaContainerModelin question- Returns:
- the current master media or
nullif no such media exists. - See Also:
-
selectMasterFromUnsavedContainer
Naive approach to determine the master of anMediaContainerModel. This method is just used if the container is not persisted yet, otherwise a query on the database if used.- Parameters:
model- the container to determine the master for- Returns:
- the master media of the given container or
nullif none could be determined - See Also:
-
getOrConvert
Description copied from interface:MediaConversionServiceRetrieves theMediaModelin the specifiedMediaFormatModelassociated with the givenMediaContainerModel. If no such media exists the service will try to convert the media to that format automatically (synchronous). The conversion will also be performed if the converted media is outdated, i.e. if the binary data of the converted media's original is not the same anymore.- Specified by:
getOrConvertin interfaceMediaConversionService- Parameters:
container- theMediaContainerModelto search.format- theMediaFormatModelto retrieve.- Returns:
- the
MediaModelof the givenMediaContainerModelin the givenMediaFormatModel.
-
getUpToDateMediaByFormat
protected MediaModel getUpToDateMediaByFormat(MediaContainerModel container, MediaFormatModel format) Retrieves the media in the given format and checks whether it is up to date.- Throws:
ModelNotFoundException- if the media does not exist or is not up to date.
-
isUpToDate
Checks whether a media is up to date.- Parameters:
ret- the media to check- Returns:
trueif the givenMediaModelis up to date and needs no conversion
-
doConvert
protected MediaModel doConvert(MediaContainerModel container, ConversionMediaFormatModel format) throws MediaConversionException - Throws:
MediaConversionException
-
getMediaConversionStrategy
protected MediaConversionStrategy getMediaConversionStrategy(ConversionMediaFormatModel format) throws org.springframework.beans.factory.NoSuchBeanDefinitionException - Throws:
org.springframework.beans.factory.NoSuchBeanDefinitionException
-
getMediaService
-
setMediaService
-
getModelService
-
setModelService
-
getDao
-
setDao
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext() -
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- See Also:
-
ApplicationContextAware.setApplicationContext(ApplicationContext)
-
getLockRowInTransactionStrategy
-
setLockRowInTransactionStrategy
-
getConversionErrorLogStrategy
-
setConversionErrorLogStrategy
-