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.FlowActionHandler
Wizard handler which allows to crete singleMediaModel
for 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._TYPECODE
is 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
MediaFolderModel
is stored. It will be used to create media - mediaContainerProperty - defines where in model
MediaContainerModel
is stored. It will be used to create media - mediaFormatProperty - defines where in model
MediaFormatModel
is 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.String
EVENT_CREATE_MEDIA_REFERENCE
protected static java.lang.String
NOTIFICATION_SOURCE
protected static java.lang.String
PARAM_CATALOG_VERSION
protected static java.lang.String
PARAM_MEDIA_CODE_EXP
protected static java.lang.String
PARAM_MEDIA_CONTAINER
protected static java.lang.String
PARAM_MEDIA_CONTENT_PROPERTY
protected static java.lang.String
PARAM_MEDIA_FOLDER
protected static java.lang.String
PARAM_MEDIA_FORMAT
protected static java.lang.String
PARAM_MEDIA_PROPERTY
protected static java.lang.String
PARAM_MEDIA_TYPE
protected static java.lang.String
PARAM_SAVE_PARENT_OBJECT
protected static java.lang.String
PARAM_THROW_EXCEPTIONS_ON_ERROR
-
Constructor Summary
Constructors Constructor Description MediaReferenceCreateHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beginTransaction()
protected void
commitTransaction()
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.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)
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.ExpressionResolverFactory
getExpressionResolverFactory()
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.String
getMediaProperty(java.util.Map<java.lang.String,java.lang.String> params)
MediaService
getMediaService()
protected java.lang.String
getMediaType(java.util.Map<java.lang.String,java.lang.String> params)
protected com.hybris.backoffice.widgets.notificationarea.NotificationService
getNotificationService()
com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade
getObjectFacade()
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.String
getReferenceProperty(java.lang.String mediaProperty)
int
getRetryCount()
TypeService
getTypeService()
protected boolean
isCatalogVersionRequired(java.lang.String mediaType)
protected boolean
isSaveParentObjectEnabled(java.util.Map<java.lang.String,java.lang.String> params)
protected void
notifyCreateMediaFailed(java.lang.String fileName)
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)
protected void
rethrowExceptionsIfEnabled(java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.String> params)
protected void
rollbackTransaction()
protected void
saveReference(ItemModel referenceParent, java.lang.String mediaProperty, java.lang.Object reference, java.util.Map<java.lang.String,java.lang.String> params)
void
setExpressionResolverFactory(com.hybris.cockpitng.core.expression.ExpressionResolverFactory expressionResolverFactory)
protected void
setMediaContent(com.hybris.cockpitng.editor.defaultfileupload.FileUploadResult content, MediaModel media)
void
setMediaService(MediaService mediaService)
void
setNotificationService(com.hybris.backoffice.widgets.notificationarea.NotificationService notificationService)
void
setObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade)
void
setRetryCount(int retryCount)
void
setTypeService(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:
perform
in 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()
-
-