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 Object
implements com.hybris.cockpitng.widgets.configurableflow.FlowActionHandler
Wizard handler which allows to crete single
MediaModel 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._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
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected Optional<MediaModel>createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) protected Optional<MediaModel>createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params, String suffix) protected StringgenerateMediaCode(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params, String suffix, long attempt) protected Optional<CatalogVersionModel>getCatalogVersion(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) com.hybris.cockpitng.core.expression.ExpressionResolverFactoryprotected Optional<MediaFolderModel>getFolder(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) protected Optional<MediaContainerModel>getMediaContainer(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) protected <T> Optional<T>getMediaContent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params, Class<T> clazz) protected Optional<MediaFormatModel>getMediaFormat(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) protected StringgetMediaProperty(Map<String, String> params) protected StringgetMediaType(Map<String, String> params) protected com.hybris.backoffice.widgets.notificationarea.NotificationServicecom.hybris.cockpitng.dataaccess.facades.object.ObjectFacadeprotected <T> Optional<T>getPropertyValue(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, String property, Class<T> clazz) getReferenceParent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, String mediaProperty) protected StringgetReferenceProperty(String mediaProperty) intprotected booleanisCatalogVersionRequired(String mediaType) protected booleanisSaveParentObjectEnabled(Map<String, String> params) protected voidnotifyCreateMediaFailed(String fileName) voidperform(com.hybris.cockpitng.config.jaxb.wizard.CustomType customType, com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) protected voidrethrowExceptionsIfEnabled(Exception ex, Map<String, String> params) protected voidprotected voidsaveReference(ItemModel referenceParent, String mediaProperty, Object reference, Map<String, 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 Optional<MediaModel>tryToCreateMedia(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params, String code)
-
Field Details
-
PARAM_MEDIA_CONTENT_PROPERTY
- See Also:
-
PARAM_MEDIA_PROPERTY
- See Also:
-
PARAM_MEDIA_CODE_EXP
- See Also:
-
PARAM_CATALOG_VERSION
- See Also:
-
PARAM_MEDIA_FOLDER
- See Also:
-
PARAM_MEDIA_CONTAINER
- See Also:
-
PARAM_MEDIA_FORMAT
- See Also:
-
PARAM_MEDIA_TYPE
- See Also:
-
PARAM_SAVE_PARENT_OBJECT
- See Also:
-
NOTIFICATION_SOURCE
- See Also:
-
EVENT_CREATE_MEDIA_REFERENCE
- See Also:
-
PARAM_THROW_EXCEPTIONS_ON_ERROR
- See Also:
-
-
Constructor Details
-
MediaReferenceCreateHandler
public MediaReferenceCreateHandler()
-
-
Method Details
-
perform
public void perform(com.hybris.cockpitng.config.jaxb.wizard.CustomType customType, com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) - Specified by:
performin interfacecom.hybris.cockpitng.widgets.configurableflow.FlowActionHandler
-
rethrowExceptionsIfEnabled
-
saveReference
protected void saveReference(ItemModel referenceParent, String mediaProperty, Object reference, Map<String, String> params) throws com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException- Throws:
com.hybris.cockpitng.dataaccess.facades.object.exceptions.ObjectSavingException
-
getReferenceProperty
-
createMediaReference
protected Optional<MediaModel> createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) -
createMediaReference
-
tryToCreateMedia
-
isCatalogVersionRequired
-
getMediaType
-
setMediaContent
protected void setMediaContent(com.hybris.cockpitng.editor.defaultfileupload.FileUploadResult content, MediaModel media) -
generateMediaCode
-
getMediaFormat
protected Optional<MediaFormatModel> getMediaFormat(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) -
getMediaContainer
protected Optional<MediaContainerModel> getMediaContainer(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) -
getFolder
protected Optional<MediaFolderModel> getFolder(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) -
getCatalogVersion
protected Optional<CatalogVersionModel> getCatalogVersion(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String, String> params) -
getPropertyValue
-
getReferenceParent
-
getMediaProperty
-
getMediaContent
-
notifyCreateMediaFailed
-
isSaveParentObjectEnabled
-
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
-
setMediaService
-
getObjectFacade
public com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade getObjectFacade() -
setObjectFacade
public void setObjectFacade(com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade objectFacade) -
getTypeService
-
setTypeService
-
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()
-