Package de.hybris.platform.jalo.media
Class MediaManager
java.lang.Object
de.hybris.platform.jalo.Manager
de.hybris.platform.jalo.media.MediaManager
- All Implemented Interfaces:
ItemLifecycleListener,Serializable
The manager for media items.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMedia related input streamprotected static classNested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIdentifier of this manager used at core-spring.xml spring configuration.static final StringDeprecated.since ages - use CoreConstants.TC.MEDIACONTAINER insteadstatic final StringDeprecated.since ages - use CoreConstants.TC.MEDIACONTEXT insteadstatic final StringDeprecated.since ages - use CoreConstants.TC.MEDIAFOLDER insteadstatic final StringDeprecated.since ages - use CoreConstants.TC.MEDIAFORMAT insteadstatic final StringDeprecated.since ages - use CoreConstants.TC.MEDIAFORMATMAPPING insteadstatic final StringDeprecated.since ages - use CommonsConstants.TC.MEDIAFORMATTER insteadstatic final Stringstatic final StringIdentifier of the root media folder created at system initialization. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckBeforeItemRemoval(SessionContext ctx, Item item) Superclass method overridden to avoid call to EJB layer.createMedia(PK pk, String code) Creates a new media item.createMedia(PK pkBase, String code, ComposedType type) Creates a new media item with a specific type.createMedia(String code) Creates a new media item.createMedia(String code, MediaFormat format) Creates a new media with given code and format.createMedia(String code, ComposedType type) Creates a new media item with a specific type.createMediaContainer(SessionContext ctx, Map<String, Object> attributeValues) Creates a new container with given parameters.createMediaContainer(String qualifier) Creates a new container with given qualifier.createMediaContainer(Map<String, Object> attributeValues) Creates a new container with given parameters.createMediaContext(SessionContext ctx, Map<String, Object> attributeValues) Creates a new context with given parameters.createMediaContext(String qualifier) Creates a new context with given qualifier.createMediaContext(Map<String, Object> attributeValues) Creates a new context with given parameters.createMediaFolder(SessionContext ctx, Map<String, Object> attributeValues) Creates a new folder with given parameters.createMediaFolder(String qualifier, String path) Creates a new folder with given qualifier and path.createMediaFolder(Map<String, Object> attributeValues) Creates a new folder with given parameters.createMediaFormat(SessionContext ctx, Map<String, Object> attributeValues) Creates a new format with given parameters.createMediaFormat(String qualifier) Creates a new format with given qualifier.createMediaFormat(Map<String, Object> attributeValues) Creates a new format with given parameters.createMediaFormatMapping(MediaFormat source, MediaFormat target) Creates a new mapping with given source and target format.createMediaFormatMapping(SessionContext ctx, Map<String, Object> attributeValues) Creates a new mapping with given parameters.createMediaFormatMapping(Map<String, Object> attributeValues) Creates a new mapping with given parameters.protected MediaSourcecreateMediaSource(AbstractMedia media) voiddeleteMedia(String folderQualifier, String location) Delete media.voiddeleteMediaDataUnlessReferenced(PK mediaPk, Long dataPk, String folderQualifier, String location) This method deletes media data unless it is referenced by another media object.Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get ade.hybris.platform.core.model.media.MediaModels instances.Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get aMediaContexts instances.Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get aMediaFolderModels instances.Deprecated.since 'medias' is incorrect term.getBestMime(String filePath) Gets the best mime for provided media file path.getBestMime(String fileName, byte[] firstBytes, String overrideMime) Gets the best mime.getDownloadURLForMedia(String folderQualifier, MediaSource mediaSource) Gets the file extension from mime.static MediaManagerGets the instance of this manager.byte[]getMediaAsByteArray(String folderQualifier, String location) getMediaAsFile(String folderQualifier, String location) This method try to return media data asFile.getMediaAsStream(MediaSource mediaSource) Gets media as stream.getMediaAsStream(String folderQualifier, String location) Gets the media as stream.getMediaAsStreamWithSize(String folderQualifier, String location) Gets the media as stream with its size.getMediaByCode(String searchString) Finds all media which code matches the specified search pattern.getMediaByMimeType(String mimePattern) Finds all media whose mime type matches the given pattern.getMediaByURL(String urlPattern) Deprecated.since agesgetMediaByURLExact(String url) Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get ade.hybris.platform.core.model.media.MediaModels instances for a specifiedde.hybris.platform.core.model.media.MediaModel.CODE.getMediaFolderByQualifier(String searchString) Finds all folders whose qualifier matches the specified search pattern.getMediaFormatByQualifier(String qualifier) Gets first media format matching given qualifier.getMediasByCode(String searchString) Deprecated.since 'medias' is incorrect termgetMediasByMimeType(String mimePattern) Deprecated.since 'medias' is incorrect termprotected StringGets the code of the media type.getMimeTypeByExtension(String fileExtension) Returns the MimeType for the given fileextension.Gets the or create root media folder.Deprecated.since ages - useMediaService.getRootFolder()insteadgetURLForMedia(String folderQualifier, MediaSource mediaSource) booleanhasData(MediaSource mediaSource) booleanhasForeignDataOwners(PK mediaPk, Long dataPk) voidinitializeMediaStorage(boolean freshInit) Executes any configured media storage initializer on initialization process.booleanisFolderConfiguredAsSecured(String folderQualifier) booleanisPathTargetSecuredFolder(String folderQualifier, String location) booleanisSecuredFolder(String folderQualifier) booleanisZipRelatedMime(String mime) protected voidnotifyItemRemoval(SessionContext ctx, Item item) Superclass method overridden to avoid call to EJB layer.voidsetLocalMediaFileCache(LocalMediaFileCacheService localMediaFileCache) voidsetLocationHashService(MediaLocationHashService locationHashService) voidsetMediaHeadersRegistry(MediaHeadersRegistry mediaHeadersRegistry) voidsetMediaStorageConfigService(MediaStorageConfigService mediaStorageConfig) voidsetMediaStorageRegistry(MediaStorageRegistry mediaStorageRegistry) voidsetMimeService(MimeService mimeService) storeMedia(MediaDataStoreCommand command) Store media.byte[]Tries to get media from URL then turns media to an array of bytesverifyMediaHash(String folderQualifier, String location, String storedHash, long size, String mime) voidverifyMediaHashForLocation(String folderQualifier, String location, String storedHash) Deprecated, for removal: This API element is subject to removal in a future version.since 2011, useverifyMediaHash(String, String, String, long, String)Methods inherited from class de.hybris.platform.jalo.Manager
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, init, setAttribute, setTenant, setTransientObject, wrap
-
Field Details
-
BEAN_NAME
Identifier of this manager used at core-spring.xml spring configuration.- See Also:
-
MEDIAFOLDER
Deprecated.since ages - use CoreConstants.TC.MEDIAFOLDER insteadConstant identifier forMediaFoldertype. -
MEDIACONTAINER
Deprecated.since ages - use CoreConstants.TC.MEDIACONTAINER insteadConstant identifier forMediaContainertype. -
MEDIACONTEXT
Deprecated.since ages - use CoreConstants.TC.MEDIACONTEXT insteadConstant identifier forMediaContexttype. -
MEDIAFORMAT
Deprecated.since ages - use CoreConstants.TC.MEDIAFORMAT insteadConstant identifier forMediaFormattype. -
MEDIAFORMATMAPPING
Deprecated.since ages - use CoreConstants.TC.MEDIAFORMATMAPPING insteadConstant identifier forMediaFormatMappingtype. -
MEDIAFORMATTER
Deprecated.since ages - use CommonsConstants.TC.MEDIAFORMATTER insteadConstant identifier forMediaFormattertype. -
ROOT_FOLDER_QUALIFIER
Identifier of the root media folder created at system initialization.- See Also:
-
PREFERRED_URL_STRATEGY_ID
- See Also:
-
-
Constructor Details
-
MediaManager
public MediaManager()
-
-
Method Details
-
setMimeService
-
setMediaHeadersRegistry
-
setLocalMediaFileCache
-
setMediaStorageConfigService
-
setMediaStorageRegistry
-
setLocationHashService
-
getMediaStorageFactory
-
getFileExtensionFromMime
Gets the file extension from mime. -
getBestMime
Gets the best mime. -
getBestMime
Gets the best mime for provided media file path. -
hasForeignDataOwners
-
storeMedia
Store media.- Returns:
- the stored media data
-
deleteMedia
Delete media.- Parameters:
folderQualifier- the folder qualifierlocation- the location
-
deleteMediaDataUnlessReferenced
public void deleteMediaDataUnlessReferenced(PK mediaPk, Long dataPk, String folderQualifier, String location) This method deletes media data unless it is referenced by another media object. If current transaction is running deletion will be delayed just after success commit. If there is no running transaction delete operation will be executed immediately.- Parameters:
mediaPk- PK of the given media objectdataPk- Data PK of the given media objectfolderQualifier- Folder qualifier of the given media objectlocation- Location of media data in the storage
-
getMediaAsStreamWithSize
public MediaManager.InputStreamWithSize getMediaAsStreamWithSize(String folderQualifier, String location) Gets the media as stream with its size.- Parameters:
folderQualifier- the folder qualifierlocation- the location- Returns:
- the
MediaManager.InputStreamWithSizeobject containing a stream with its size
-
getMediaAsStream
Gets the media as stream.- Parameters:
folderQualifier- the folder qualifierlocation- the location- Returns:
- the media as stream
-
getMediaAsStream
Gets media as stream. This method returns stream for backed binary data if media has it or tries to get stream directly from its URL if it does not have real data.- Parameters:
mediaSource- Wrapper interface for the media object.- Returns:
- the media as stream
-
getMediaAsByteArray
- Throws:
IOException
-
tryToGetMediaAsByteArrayFromUrl
Tries to get media from URL then turns media to an array of bytes- Parameters:
media- media source- Returns:
- byte[]
- Throws:
IOException- IO Error
-
hasData
-
getMediaHeadersRegistry
-
isZipRelatedMime
-
verifyMediaHashForLocation
@Deprecated(since="2011", forRemoval=true) public void verifyMediaHashForLocation(String folderQualifier, String location, String storedHash) Deprecated, for removal: This API element is subject to removal in a future version.since 2011, useverifyMediaHash(String, String, String, long, String) -
verifyMediaHash
public MediaLocationHashService.HashType verifyMediaHash(String folderQualifier, String location, String storedHash, long size, String mime) -
isPathTargetSecuredFolder
-
isFolderConfiguredAsSecured
-
getMediaAsFile
This method try to return media data asFile. It may throwUnsupportedOperationExceptionwhen underlyingMediaStorageStrategydoes not support it.- Parameters:
folderQualifier- the folder qualifierlocation- the location- Returns:
- the media as file
-
getURLForMedia
-
getDownloadURLForMedia
-
createMediaSource
-
initializeMediaStorage
public void initializeMediaStorage(boolean freshInit) Executes any configured media storage initializer on initialization process.- Parameters:
freshInit- determines whether it is fresh init or update
-
isSecuredFolder
-
getInstance
Gets the instance of this manager.- Returns:
- instance of this manager
-
checkBeforeItemRemoval
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException Superclass method overridden to avoid call to EJB layer.- Overrides:
checkBeforeItemRemovalin classManager- Parameters:
ctx- the current session contextitem- the item which should be removed- Throws:
ConsistencyCheckException- thrown to abort removal due to consistency errors- Since:
- 2.10
-
notifyItemRemoval
Superclass method overridden to avoid call to EJB layer.- Overrides:
notifyItemRemovalin classManager- Parameters:
ctx- the currency session contextitem- the item which is going to be removed- Since:
- 2.10
-
getMediaTypeCode
Gets the code of the media type.- Returns:
- code of media type
-
createMedia
Creates a new media item. By this time no URL is set and no data is available.- Parameters:
code- code of new media
-
createMedia
Creates a new media item. By this time no URL is set and no data is available.- Parameters:
pk- the pk for the new item; it will be equipped with type code additionally (- ) code- code of new media
-
createMedia
Creates a new media item with a specific type. By this time no URL is set and no data is available. Please note that this does not set any attribute declared by this type! UseComposedType.newInstance(Map)to achieve attribute checks.- Parameters:
code- the code of the new mediatype- the type of the new media
-
createMedia
Creates a new media item with a specific type. By this time no URL is set and no data is available. Please note that this does not set any attribute declared by this type! UseComposedType.newInstance(Map)to achieve attribute checks.- Parameters:
pkBase- the pk for the new item; it will be equipped with type code additionally (- ) code- the code of the new mediatype- the type of the new media
-
getAllMedias
Deprecated.since 'medias' is incorrect term. Please usegetAllMedia()instead.Gets all media items. -
getAllMedia
Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get ade.hybris.platform.core.model.media.MediaModels instances. See more at loading by exemplary model.Gets all media items. -
getMediasByCode
Deprecated.since 'medias' is incorrect termFinds all media which code matches the specified search pattern. Wildcards are '%' and '_' ( as in SQL LIKE statements ).- Parameters:
searchString- pattern used for searching
-
getMediaByCode
Finds all media which code matches the specified search pattern. Wildcards are '%' and '_' ( as in SQL LIKE statements ).- Parameters:
searchString- pattern used for searching
-
getMediasByMimeType
@Deprecated(since="ages", forRemoval=false) public Collection getMediasByMimeType(String mimePattern) Deprecated.since 'medias' is incorrect termFinds all media whose mime type matches the given pattern.- Parameters:
mimePattern- a SQL pattern for the mime type- Returns:
- a collection of
Mediaobjects
-
getMediaByMimeType
Finds all media whose mime type matches the given pattern.- Parameters:
mimePattern- a SQL pattern for the mime type- Returns:
- a collection of
Mediaobjects
-
getMediaByURL
Deprecated.since agesFinds all media whose url matches the given pattern.- Parameters:
urlPattern- a SQL pattern for the url- Returns:
- a collection of
Mediaobjects
-
getMediaByURLExact
Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get ade.hybris.platform.core.model.media.MediaModels instances for a specifiedde.hybris.platform.core.model.media.MediaModel.CODE. See more at loading by exemplary model.Finds a media for a given url.- Parameters:
url- the url media will be needed- Returns:
- all media matching given url
-
getMimeTypeByExtension
Returns the MimeType for the given fileextension. If the Extension is unknown the Binary-Mimetype will be returned.- Parameters:
fileExtension- Fileextension, no dot, allowed are Lower- and Uppercases.- Returns:
- Mimetypestring
-
createMediaFolder
Creates a new folder with given qualifier and path.- Parameters:
qualifier- qualifier for new folderpath- path for new folder- Returns:
- created folder
- Since:
- 3.1-u4
-
createMediaFolder
Creates a new folder with given parameters.- Parameters:
attributeValues- parameters used for creation- Returns:
- created folder
- Since:
- 3.1-u4
-
createMediaFolder
Creates a new folder with given parameters.- Parameters:
attributeValues- parameters used for creationctx- session context- Returns:
- created folder
- Since:
- 3.1-u4
-
getMediaFolderByQualifier
Finds all folders whose qualifier matches the specified search pattern. Wildcards are '%' and '_' ( as in SQL LIKE statements ).- Parameters:
searchString- pattern used for searching the folders- Returns:
- list of found folders
- Since:
- 3.1-u4
-
getAllMediaFolders
Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get aMediaFolderModels instances. See more at loading by exemplary model.Gets allMediaFolder's in system.- Returns:
- all folders installed
- Since:
- 3.1-u4
-
getRootMediaFolder
Deprecated.since ages - useMediaService.getRootFolder()insteadGets the root folder.- Returns:
- root folder
- Throws:
JaloSystemException- when root media folder does not exist- Since:
- 3.1-u4
-
getOrCreateRootMediaFolder
Gets the or create root media folder.- Returns:
- the or create root media folder
-
createMediaContainer
Creates a new container with given qualifier.- Parameters:
qualifier- qualifier for new container- Returns:
- created container
-
createMediaContainer
Creates a new container with given parameters.- Parameters:
attributeValues- parameters used for creation- Returns:
- created container
-
createMediaContainer
Creates a new container with given parameters.- Parameters:
attributeValues- parameters used for creationctx- session context- Returns:
- created container
-
createMediaFormat
Creates a new format with given qualifier.- Parameters:
qualifier- qualifier for new format- Returns:
- created format
-
createMediaFormat
Creates a new format with given parameters.- Parameters:
attributeValues- parameters used for creation- Returns:
- created format
-
createMediaFormat
Creates a new format with given parameters.- Parameters:
attributeValues- parameters used for creationctx- session context- Returns:
- created format
-
createMediaContext
Creates a new context with given qualifier.- Parameters:
qualifier- qualifier for new context- Returns:
- created context
-
createMediaContext
Creates a new context with given parameters.- Parameters:
attributeValues- parameters used for creation- Returns:
- created context
-
createMediaContext
Creates a new context with given parameters.- Parameters:
attributeValues- parameters used for creationctx- session context- Returns:
- created context
-
createMediaFormatMapping
Creates a new mapping with given source and target format.- Parameters:
source- source formattarget- target format- Returns:
- created mapping
-
createMediaFormatMapping
Creates a new mapping with given parameters.- Parameters:
attributeValues- parameters used for creation- Returns:
- created mapping
-
createMediaFormatMapping
public MediaFormatMapping createMediaFormatMapping(SessionContext ctx, Map<String, Object> attributeValues) Creates a new mapping with given parameters.- Parameters:
attributeValues- parameters used for creationctx- session context- Returns:
- created mapping
-
createMedia
Creates a new media with given code and format.- Parameters:
code- code for new mediaformat- format for new media- Returns:
- created media
-
getAllMediaContexts
Deprecated.since ages - use plainFlexibleSearchService.getModelsByExample(Object)to get aMediaContexts instances. See more at loading by exemplary model.Gets all media contexts in system.- Returns:
- list of all contexts in system
-
getMediaFormatByQualifier
Gets first media format matching given qualifier.- Parameters:
qualifier- qualifier a format is needed for- Returns:
- media format with given qualifier
-
writeReplace
- Specified by:
writeReplacein classManager- Throws:
ObjectStreamException
-