Class DefaultBackofficeConfigurationMediaHelper
- java.lang.Object
-
- com.hybris.backoffice.config.impl.DefaultBackofficeConfigurationMediaHelper
-
- All Implemented Interfaces:
BackofficeConfigurationMediaHelper
public class DefaultBackofficeConfigurationMediaHelper extends java.lang.Object implements BackofficeConfigurationMediaHelper
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringPROPERTY_BACKOFFICE_CONFIGURATION_SECURE_MEDIA_FOLDER
-
Constructor Summary
Constructors Constructor Description DefaultBackofficeConfigurationMediaHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassureSecureFolderAssignment(MediaModel mediaModel)The method assures secure media folder assignment of the given media.protected MediaFolderModelcreateSecureFolder()MediaModelcreateWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime)Creates Backoffice configuration media and in case media cannot be created
returns existing media with given codeprotected voidfailOnInsecureFolderAssignment(java.lang.String folderQualifier)protected CatalogVersionModelfindBackofficeMediaCatalog()protected MediaModelfindMediaByCode(java.lang.String mediaCode)MediaModelfindOrCreateWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime)Searches for Backoffice configuration media and creates one in case media is not found.MediaModelfindOrCreateWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime, java.util.function.Consumer<MediaModel> newMediaInitializer)Searches for Backoffice configuration media and creates one in case media is not found.MediaModelfindWidgetsConfigMedia(java.lang.String mediaCode)Searches for Backoffice configuration media and removes all configurations if given mediaCode
is ambiguous.protected CatalogVersionServicegetCatalogVersionService()protected BackofficeConfigurationDaogetConfigurationDao()java.lang.StringgetMediaCatalogId()java.lang.StringgetMediaCatalogVersion()protected MediaServicegetMediaService()MediaStorageConfigServicegetMediaStorageConfigService()protected ModelServicegetModelService()protected SearchRestrictionServicegetSearchRestrictionService()MediaFolderModelgetSecureFolder()The method tries to load the Media Folder of'backofficeconfiguration'qualifier.protected SessionServicegetSessionService()protected UserServicegetUserService()protected MediaFolderModelloadSecureFolder()protected voidremoveAmbiguousConfiguration(java.lang.String mediaCode)voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetConfigurationDao(BackofficeConfigurationDao configurationDao)voidsetMediaCatalogId(java.lang.String mediaCatalogId)voidsetMediaCatalogVersion(java.lang.String mediaCatalogVersion)voidsetMediaService(MediaService mediaService)voidsetMediaStorageConfigService(MediaStorageConfigService mediaStorageConfigService)voidsetModelService(ModelService modelService)voidsetSearchRestrictionService(SearchRestrictionService searchRestrictionService)voidsetSessionService(SessionService sessionService)voidsetUserService(UserService userService)
-
-
-
Field Detail
-
PROPERTY_BACKOFFICE_CONFIGURATION_SECURE_MEDIA_FOLDER
protected static final java.lang.String PROPERTY_BACKOFFICE_CONFIGURATION_SECURE_MEDIA_FOLDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
findOrCreateWidgetsConfigMedia
public MediaModel findOrCreateWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime, java.util.function.Consumer<MediaModel> newMediaInitializer)
Description copied from interface:BackofficeConfigurationMediaHelperSearches for Backoffice configuration media and creates one in case media is not found.- Specified by:
findOrCreateWidgetsConfigMediain interfaceBackofficeConfigurationMediaHelper- Parameters:
mediaCode- code ofMediaModelto be searched formediaMime- mime type used when newMediaModelis creatednewMediaInitializer- initializer callback to call for new media created by this method- Returns:
MediaModelcorresponding with given mediaCode
-
findOrCreateWidgetsConfigMedia
public MediaModel findOrCreateWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime)
Description copied from interface:BackofficeConfigurationMediaHelperSearches for Backoffice configuration media and creates one in case media is not found.- Specified by:
findOrCreateWidgetsConfigMediain interfaceBackofficeConfigurationMediaHelper- Parameters:
mediaCode- code ofMediaModelto be searched formediaMime- mime type used when newMediaModelis created- Returns:
MediaModelcorresponding with given mediaCode
-
findWidgetsConfigMedia
public MediaModel findWidgetsConfigMedia(java.lang.String mediaCode)
Description copied from interface:BackofficeConfigurationMediaHelperSearches for Backoffice configuration media and removes all configurations if given mediaCode
is ambiguous.- Specified by:
findWidgetsConfigMediain interfaceBackofficeConfigurationMediaHelper- Parameters:
mediaCode- code ofMediaModelto be searched for- Returns:
MediaModelcorresponding with given mediaCode
-
findMediaByCode
protected MediaModel findMediaByCode(java.lang.String mediaCode)
-
createWidgetsConfigMedia
public MediaModel createWidgetsConfigMedia(java.lang.String mediaCode, java.lang.String mediaMime)
Description copied from interface:BackofficeConfigurationMediaHelperCreates Backoffice configuration media and in case media cannot be created
returns existing media with given code- Specified by:
createWidgetsConfigMediain interfaceBackofficeConfigurationMediaHelper- Parameters:
mediaCode- code ofMediaModelto be createdmediaMime- mime type used when newMediaModelis created- Returns:
MediaModelcorresponding with given mediaCode
-
findBackofficeMediaCatalog
protected CatalogVersionModel findBackofficeMediaCatalog()
-
removeAmbiguousConfiguration
protected void removeAmbiguousConfiguration(java.lang.String mediaCode)
-
getSecureFolder
public MediaFolderModel getSecureFolder()
Description copied from interface:BackofficeConfigurationMediaHelperThe method tries to load the Media Folder of'backofficeconfiguration'qualifier. If the folder is found it is returned. Otherwise the method tries to create it and return. In case of a race condition, where two subsequent saves happen and the method fails to save the folder, it re-tries the fetch and return before it finally fails.- Specified by:
getSecureFolderin interfaceBackofficeConfigurationMediaHelper- Returns:
- the standard secure media folder for backoffice configurations
- See Also:
MediaFolderModel
-
loadSecureFolder
protected MediaFolderModel loadSecureFolder()
-
createSecureFolder
protected MediaFolderModel createSecureFolder()
-
assureSecureFolderAssignment
protected void assureSecureFolderAssignment(MediaModel mediaModel)
The method assures secure media folder assignment of the given media. The following scenarios are covered:- if the media is not assigned to a folder or it is assigned to the root folder it will be assigned to the standard
one and persisted if the
persistChangedargument is set to true - if the media is assigned to a folder which is secure (see
MediaStorageConfigService) nothing will be done - if the media is assigned to a folder which is not secure (see
MediaStorageConfigService)IllegalStateExceptionwill be thrown
- Parameters:
mediaModel- media to checked for secure folder assignment- Throws:
java.lang.IllegalStateException- if the media is assigned to a non-secure folderjava.lang.IllegalArgumentException- if the passed media isnull- See Also:
MediaStorageConfigService,assureSecureFolderAssignment(MediaModel),MediaManager.ROOT_FOLDER_QUALIFIER
- if the media is not assigned to a folder or it is assigned to the root folder it will be assigned to the standard
one and persisted if the
-
failOnInsecureFolderAssignment
protected void failOnInsecureFolderAssignment(java.lang.String folderQualifier)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getSearchRestrictionService
protected SearchRestrictionService getSearchRestrictionService()
-
setSearchRestrictionService
public void setSearchRestrictionService(SearchRestrictionService searchRestrictionService)
-
getMediaService
protected MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getConfigurationDao
protected BackofficeConfigurationDao getConfigurationDao()
-
setConfigurationDao
public void setConfigurationDao(BackofficeConfigurationDao configurationDao)
-
getMediaStorageConfigService
public MediaStorageConfigService getMediaStorageConfigService()
-
setMediaStorageConfigService
public void setMediaStorageConfigService(MediaStorageConfigService mediaStorageConfigService)
-
getUserService
protected UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getCatalogVersionService
protected CatalogVersionService getCatalogVersionService()
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
getMediaCatalogId
public java.lang.String getMediaCatalogId()
-
setMediaCatalogId
public void setMediaCatalogId(java.lang.String mediaCatalogId)
-
getMediaCatalogVersion
public java.lang.String getMediaCatalogVersion()
-
setMediaCatalogVersion
public void setMediaCatalogVersion(java.lang.String mediaCatalogVersion)
-
-