Package com.hybris.backoffice.wizard
Class MediaReferenceCreateHandler
- java.lang.Object
-
- com.hybris.backoffice.wizard.MediaReferenceCreateHandler
-
- All Implemented Interfaces:
com.hybris.cockpitng.widgets.configurableflow.FlowActionHandler
- Direct Known Subclasses:
MultiMediaReferenceCreateHandler
public class MediaReferenceCreateHandler extends java.lang.Object implements com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerWizard handler which allows to crete singleMediaModelfor uploaded content. It accepts following parameters- mediaContentProperty - defines where in model uploaded content is stored. Value is mandatory
- mediaProperty - defines property in the model where created media should be added. e.g. newProduct.picture. Value is mandatory
- saveParentObject - if defined parent object will be saved after the reference is set
- mediaType - defines type of media to be created. It has to be assignable to
MediaModel. By defaultMediaModel._TYPECODEis used - mediaCodeExpression - expression which will be used to create media code. It will be called on widget model. e.g. newProduct.code+'_picture'. If code is already used suffix with randomly generated alphanumeric will be added at the end
- catalogVersionProperty - defines where in model catalog version is stored. It will be used to create media. Value
is mandatory for type not assignable to
CatalogUnawareMediaModel - mediaFolderProperty - defines where in model
MediaFolderModelis stored. It will be used to create media - mediaContainerProperty - defines where in model
MediaContainerModelis stored. It will be used to create media - mediaFormatProperty - defines where in model
MediaFormatModelis stored. It will be used to create media - throwExceptionsOnError - defines if exceptions that may happen during execution should be re-thrown or if their propagation should be stopped and appropriate message should be logged
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringEVENT_CREATE_MEDIA_REFERENCEprotected static java.lang.StringNOTIFICATION_SOURCEprotected static java.lang.StringPARAM_CATALOG_VERSIONprotected static java.lang.StringPARAM_MEDIA_CODE_EXPprotected static java.lang.StringPARAM_MEDIA_CONTAINERprotected static java.lang.StringPARAM_MEDIA_CONTENT_PROPERTYprotected static java.lang.StringPARAM_MEDIA_FOLDERprotected static java.lang.StringPARAM_MEDIA_FORMATprotected static java.lang.StringPARAM_MEDIA_PROPERTYprotected static java.lang.StringPARAM_MEDIA_TYPEprotected static java.lang.StringPARAM_SAVE_PARENT_OBJECTprotected static java.lang.StringPARAM_THROW_EXCEPTIONS_ON_ERROR
-
Constructor Summary
Constructors Constructor Description MediaReferenceCreateHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeginTransaction()protected voidcommitTransaction()protected java.util.Optional<MediaModel>createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)protected java.util.Optional<MediaModel>createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String suffix)protected java.lang.StringgenerateMediaCode(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String suffix, long attempt)protected java.util.Optional<CatalogVersionModel>getCatalogVersion(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)com.hybris.cockpitng.core.expression.ExpressionResolverFactorygetExpressionResolverFactory()protected java.util.Optional<MediaFolderModel>getFolder(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)protected java.util.Optional<MediaContainerModel>getMediaContainer(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)protected <T> java.util.Optional<T>getMediaContent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Class<T> clazz)protected java.util.Optional<MediaFormatModel>getMediaFormat(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)protected java.lang.StringgetMediaProperty(java.util.Map<java.lang.String,java.lang.String> params)MediaServicegetMediaService()protected java.lang.StringgetMediaType(java.util.Map<java.lang.String,java.lang.String> params)protected com.hybris.backoffice.widgets.notificationarea.NotificationServicegetNotificationService()com.hybris.cockpitng.dataaccess.facades.object.ObjectFacadegetObjectFacade()protected <T> java.util.Optional<T>getPropertyValue(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.lang.String property, java.lang.Class<T> clazz)protected <T extends ItemModel>
java.util.Optional<T>getReferenceParent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.lang.String mediaProperty)protected java.lang.StringgetReferenceProperty(java.lang.String mediaProperty)intgetRetryCount()TypeServicegetTypeService()protected booleanisCatalogVersionRequired(java.lang.String mediaType)protected booleanisSaveParentObjectEnabled(java.util.Map<java.lang.String,java.lang.String> params)protected voidnotifyCreateMediaFailed(java.lang.String fileName)voidperform(com.hybris.cockpitng.config.jaxb.wizard.CustomType customType, com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)protected voidrethrowExceptionsIfEnabled(java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.String> params)protected voidrollbackTransaction()protected voidsaveReference(ItemModel referenceParent, java.lang.String mediaProperty, java.lang.Object reference, java.util.Map<java.lang.String,java.lang.String> params)voidsetExpressionResolverFactory(com.hybris.cockpitng.core.expression.ExpressionResolverFactory expressionResolverFactory)protected voidsetMediaContent(com.hybris.cockpitng.editor.defaultfileupload.FileUploadResult content, MediaModel media)voidsetMediaService(MediaService mediaService)voidsetNotificationService(com.hybris.backoffice.widgets.notificationarea.NotificationService notificationService)voidsetObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade)voidsetRetryCount(int retryCount)voidsetTypeService(TypeService typeService)protected java.util.Optional<MediaModel>tryToCreateMedia(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String code)
-
-
-
Field Detail
-
PARAM_MEDIA_CONTENT_PROPERTY
protected static final java.lang.String PARAM_MEDIA_CONTENT_PROPERTY
- See Also:
- Constant Field Values
-
PARAM_MEDIA_PROPERTY
protected static final java.lang.String PARAM_MEDIA_PROPERTY
- See Also:
- Constant Field Values
-
PARAM_MEDIA_CODE_EXP
protected static final java.lang.String PARAM_MEDIA_CODE_EXP
- See Also:
- Constant Field Values
-
PARAM_CATALOG_VERSION
protected static final java.lang.String PARAM_CATALOG_VERSION
- See Also:
- Constant Field Values
-
PARAM_MEDIA_FOLDER
protected static final java.lang.String PARAM_MEDIA_FOLDER
- See Also:
- Constant Field Values
-
PARAM_MEDIA_CONTAINER
protected static final java.lang.String PARAM_MEDIA_CONTAINER
- See Also:
- Constant Field Values
-
PARAM_MEDIA_FORMAT
protected static final java.lang.String PARAM_MEDIA_FORMAT
- See Also:
- Constant Field Values
-
PARAM_MEDIA_TYPE
protected static final java.lang.String PARAM_MEDIA_TYPE
- See Also:
- Constant Field Values
-
PARAM_SAVE_PARENT_OBJECT
protected static final java.lang.String PARAM_SAVE_PARENT_OBJECT
- See Also:
- Constant Field Values
-
NOTIFICATION_SOURCE
protected static final java.lang.String NOTIFICATION_SOURCE
- See Also:
- Constant Field Values
-
EVENT_CREATE_MEDIA_REFERENCE
protected static final java.lang.String EVENT_CREATE_MEDIA_REFERENCE
- See Also:
- Constant Field Values
-
PARAM_THROW_EXCEPTIONS_ON_ERROR
protected static final java.lang.String PARAM_THROW_EXCEPTIONS_ON_ERROR
- See Also:
- Constant Field Values
-
-
Method Detail
-
perform
public void perform(com.hybris.cockpitng.config.jaxb.wizard.CustomType customType, com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)- Specified by:
performin interfacecom.hybris.cockpitng.widgets.configurableflow.FlowActionHandler
-
rethrowExceptionsIfEnabled
protected void rethrowExceptionsIfEnabled(java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.String> params)
-
saveReference
protected void saveReference(ItemModel referenceParent, java.lang.String mediaProperty, java.lang.Object reference, java.util.Map<java.lang.String,java.lang.String> params) throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException
- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException
-
getReferenceProperty
protected java.lang.String getReferenceProperty(java.lang.String mediaProperty)
-
createMediaReference
protected java.util.Optional<MediaModel> createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)
-
createMediaReference
protected java.util.Optional<MediaModel> createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String suffix)
-
tryToCreateMedia
protected java.util.Optional<MediaModel> tryToCreateMedia(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String code)
-
isCatalogVersionRequired
protected boolean isCatalogVersionRequired(java.lang.String mediaType)
-
getMediaType
protected java.lang.String getMediaType(java.util.Map<java.lang.String,java.lang.String> params)
-
setMediaContent
protected void setMediaContent(com.hybris.cockpitng.editor.defaultfileupload.FileUploadResult content, MediaModel media)
-
generateMediaCode
protected java.lang.String generateMediaCode(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String suffix, long attempt)
-
getMediaFormat
protected java.util.Optional<MediaFormatModel> getMediaFormat(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)
-
getMediaContainer
protected java.util.Optional<MediaContainerModel> getMediaContainer(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)
-
getFolder
protected java.util.Optional<MediaFolderModel> getFolder(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)
-
getCatalogVersion
protected java.util.Optional<CatalogVersionModel> getCatalogVersion(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params)
-
getPropertyValue
protected <T> java.util.Optional<T> getPropertyValue(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.lang.String property, java.lang.Class<T> clazz)
-
getReferenceParent
protected <T extends ItemModel> java.util.Optional<T> getReferenceParent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.lang.String mediaProperty)
-
getMediaProperty
protected java.lang.String getMediaProperty(java.util.Map<java.lang.String,java.lang.String> params)
-
getMediaContent
protected <T> java.util.Optional<T> getMediaContent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Class<T> clazz)
-
notifyCreateMediaFailed
protected void notifyCreateMediaFailed(java.lang.String fileName)
-
isSaveParentObjectEnabled
protected boolean isSaveParentObjectEnabled(java.util.Map<java.lang.String,java.lang.String> params)
-
rollbackTransaction
protected void rollbackTransaction()
-
commitTransaction
protected void commitTransaction()
-
beginTransaction
protected void beginTransaction()
-
getExpressionResolverFactory
public com.hybris.cockpitng.core.expression.ExpressionResolverFactory getExpressionResolverFactory()
-
setExpressionResolverFactory
public void setExpressionResolverFactory(com.hybris.cockpitng.core.expression.ExpressionResolverFactory expressionResolverFactory)
-
getMediaService
public MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
getObjectFacade
public com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade getObjectFacade()
-
setObjectFacade
public void setObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade)
-
getTypeService
public TypeService getTypeService()
-
setTypeService
public void setTypeService(TypeService typeService)
-
getNotificationService
protected com.hybris.backoffice.widgets.notificationarea.NotificationService getNotificationService()
-
setNotificationService
public void setNotificationService(com.hybris.backoffice.widgets.notificationarea.NotificationService notificationService)
-
setRetryCount
public void setRetryCount(int retryCount)
-
getRetryCount
public int getRetryCount()
-
-