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 java.lang.Object implements MediaConversionService, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
DefaultMediaConversionServiceimplementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultMediaConversionService()
-
Method Summary
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- See Also:
InitializingBean.afterPropertiesSet()
-
deleteConvertedMedias
public int deleteConvertedMedias(MediaContainerModel container)
Removes all converted medias within the specifiedMediaContainerModel.- Specified by:
deleteConvertedMediasin interfaceMediaConversionService- Parameters:
container- theMediaContainerModelto clean up- Returns:
- the number of medias removed
- See Also:
MediaConversionService.deleteConvertedMedias(MediaContainerModel)
-
getConvertedMedias
public java.util.Collection<MediaModel> getConvertedMedias(MediaContainerModel container)
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:
MediaConversionService.getConvertedMedias(MediaContainerModel)
-
selectDerivedMedias
protected java.util.Collection<MediaModel> selectDerivedMedias(MediaContainerModel container)
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:
MediaConversionService.getConvertedMedias(MediaContainerModel)
-
convertMedias
public void convertMedias(MediaContainerModel container)
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:
MediaConversionService.convertMedias(MediaContainerModel)
-
getAllConversionFormats
public java.util.Collection<ConversionMediaFormatModel> getAllConversionFormats()
Retrieves all configuredConversionMediaFormatModelfrom database.- Specified by:
getAllConversionFormatsin interfaceMediaConversionService- Returns:
- all currently configured
ConversionMediaFormatModels. - See Also:
MediaConversionService.getAllConversionFormats()
-
getConversionStatus
public ConversionStatus getConversionStatus(MediaContainerModel model)
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:
MediaConversionService.getConversionStatus(MediaContainerModel)
-
getMaster
public MediaModel getMaster(MediaContainerModel model)
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:
MediaConversionService.getMaster(MediaContainerModel)
-
selectMasterFromUnsavedContainer
protected MediaModel selectMasterFromUnsavedContainer(MediaContainerModel model)
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:
MediaConversionService.getMaster(MediaContainerModel)
-
getOrConvert
public MediaModel getOrConvert(MediaContainerModel container, MediaFormatModel format)
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
protected boolean isUpToDate(MediaModel ret)
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
public MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
getModelService
public ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getDao
public MediaConversionServiceDao getDao()
-
setDao
public void setDao(MediaConversionServiceDao dao)
-
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
public LockRowInTransactionStrategy getLockRowInTransactionStrategy()
-
setLockRowInTransactionStrategy
public void setLockRowInTransactionStrategy(LockRowInTransactionStrategy strategy)
-
getConversionErrorLogStrategy
public ConversionErrorLogStrategy getConversionErrorLogStrategy()
-
setConversionErrorLogStrategy
public void setConversionErrorLogStrategy(ConversionErrorLogStrategy whoToDoIt)
-
-