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 default MediaModel._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
In case media cannot be created or assigned operation will be rollback and user will be notified that media for uploaded content cannot be created.
  • Field Details

  • 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:
      perform in interface com.hybris.cockpitng.widgets.configurableflow.FlowActionHandler
    • rethrowExceptionsIfEnabled

      protected void rethrowExceptionsIfEnabled(Exception ex, Map<String,String> params)
    • 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

      protected String getReferenceProperty(String mediaProperty)
    • createMediaReference

      protected Optional<MediaModel> createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String,String> params)
    • createMediaReference

      protected Optional<MediaModel> createMediaReference(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String,String> params, String suffix)
    • tryToCreateMedia

      protected Optional<MediaModel> tryToCreateMedia(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String,String> params, String code)
    • isCatalogVersionRequired

      protected boolean isCatalogVersionRequired(String mediaType)
    • getMediaType

      protected String getMediaType(Map<String,String> params)
    • setMediaContent

      protected void setMediaContent(com.hybris.cockpitng.editor.defaultfileupload.FileUploadResult content, MediaModel media)
    • generateMediaCode

      protected String generateMediaCode(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String,String> params, String suffix, long attempt)
    • 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

      protected <T> Optional<T> getPropertyValue(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, String property, Class<T> clazz)
    • getReferenceParent

      protected <T extends ItemModel> Optional<T> getReferenceParent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, String mediaProperty)
    • getMediaProperty

      protected String getMediaProperty(Map<String,String> params)
    • getMediaContent

      protected <T> Optional<T> getMediaContent(com.hybris.cockpitng.widgets.configurableflow.FlowActionHandlerAdapter adapter, Map<String,String> params, Class<T> clazz)
    • notifyCreateMediaFailed

      protected void notifyCreateMediaFailed(String fileName)
    • isSaveParentObjectEnabled

      protected boolean isSaveParentObjectEnabled(Map<String,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()