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
DefaultMediaConversionService
implementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultMediaConversionService()
-
Method Summary
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- See Also:
InitializingBean.afterPropertiesSet()
-
deleteConvertedMedias
public int deleteConvertedMedias(MediaContainerModel container)
Removes all converted medias within the specifiedMediaContainerModel
.- Specified by:
deleteConvertedMedias
in interfaceMediaConversionService
- Parameters:
container
- theMediaContainerModel
to 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:
getConvertedMedias
in interfaceMediaConversionService
- Parameters:
container
- theMediaContainerModel
in 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:
convertMedias
in interfaceMediaConversionService
- Parameters:
container
- theMediaContainerModel
to 'fill up'.- See Also:
MediaConversionService.convertMedias(MediaContainerModel)
-
getAllConversionFormats
public java.util.Collection<ConversionMediaFormatModel> getAllConversionFormats()
Retrieves all configuredConversionMediaFormatModel
from database.- Specified by:
getAllConversionFormats
in interfaceMediaConversionService
- Returns:
- all currently configured
ConversionMediaFormatModel
s. - See Also:
MediaConversionService.getAllConversionFormats()
-
getConversionStatus
public ConversionStatus getConversionStatus(MediaContainerModel model)
Computes the currentConversionStatus
for 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
supportedFormat
of the assignedConversionGroupModel
or - all
ConversionMediaFormatModel
instances in the system, if noConversionGroupModel
is set on the givenMediaContainerModel
- Specified by:
getConversionStatus
in interfaceMediaConversionService
- Parameters:
model
- theMediaContainerModel
to compute the conversion status for- Returns:
- the current
ConversionStatus
for the givenMediaContainerModel
- See Also:
MediaConversionService.getConversionStatus(MediaContainerModel)
-
getMaster
public MediaModel getMaster(MediaContainerModel model)
Retrieves the current 'master'MediaModel
of the givenMediaContainerModel
. The master media is defined as theMediaModel
within theMediaContainerModel
which has no original and no original data pk set (attributesMediaModel.ORIGINAL
andMediaModel.ORIGINALDATAPK
).- Specified by:
getMaster
in interfaceMediaConversionService
- Parameters:
model
- theMediaContainerModel
in question- Returns:
- the current master media or
null
if 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
null
if none could be determined - See Also:
MediaConversionService.getMaster(MediaContainerModel)
-
getOrConvert
public MediaModel getOrConvert(MediaContainerModel container, MediaFormatModel format)
Description copied from interface:MediaConversionService
Retrieves theMediaModel
in the specifiedMediaFormatModel
associated 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:
getOrConvert
in interfaceMediaConversionService
- Parameters:
container
- theMediaContainerModel
to search.format
- theMediaFormatModel
to retrieve.- Returns:
- the
MediaModel
of the givenMediaContainerModel
in 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:
true
if the givenMediaModel
is 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:
setApplicationContext
in 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)
-
-