Package de.hybris.platform.jalo.media
Class Media
- All Implemented Interfaces:
Serializable,Comparable
- Direct Known Subclasses:
GeneratedBarcodeMedia,GeneratedCatalogUnawareMedia,GeneratedCatalogVersionSyncScheduleMedia,GeneratedConfigurationMedia,GeneratedDocument,GeneratedEmailAttachment,GeneratedFormatter,GeneratedImpExMedia,GeneratedJasperMedia,GeneratedJobMedia,GeneratedLDIFMedia,GeneratedLogFile,MediaTest.TestMedia
The media item in the hybris platform.
These items should be used for managing data actually stored outside hybris platform (like images, archives,
documents etc ). Media items can be linked with any other hybris platform item. This way the application programmer
can access either the raw media data or their URL to display it at the right place.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.static final StringConstant identifier forhasdataattribute of Media type.static final StringConstant identifier forisonserverattribute of Media type.static final StringDeprecated.since agesstatic final StringDeprecated.since agesstatic final Stringstatic final StringConstant identifier forurl2attribute of Media type.Fields inherited from class de.hybris.platform.jalo.media.GeneratedMedia
ALTTEXT, CODE, DEFAULT_INITIAL_ATTRIBUTES, DERIVEDMEDIAS, DERIVEDMEDIASHANDLER, DESCRIPTION, FOLDER, INTERNALURL, MEDIACONTAINER, MEDIACONTAINERHANDLER, MEDIAFORMAT, REMOVABLE, SUBFOLDERPATHFields inherited from class de.hybris.platform.jalo.media.GeneratedAbstractMedia
DATAPK, LOCATION, LOCATIONHASH, MIME, REALFILENAME, SIZEFields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLEDFields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEFields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks whether or not this it may be removed or not.protected FilecopyToTempFile(InputStream inputStream) protected ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) Has to be implemented for each concrete subtype of item.byte[]getData()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getDataFromMedia(de.hybris.platform.core.model.media .MediaModel)instead.Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)instead.The URL for use in jsp pages in order to download this medias raw data file (image etc).getFile()protected StringGives name of uploaded file.Returns <dataPk>.<mime> if the media has data, else it returns the url part without server/port (and without the 'fromjar/' which is used when loading files from jars), e.g.getFiles()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getFiles(de.hybris.platform.core.model.media .MediaModel)instead.getFolder(SessionContext ctx) Generated method - Getter of theMedia.folderattribute.getForContext(MediaContext context) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getMediaByContext(de.hybris.platform.core.model .media.MediaModel, de.hybris.platform.core.model.media.MediaContextModel)instead.Gets all medias excluding this one referencing data file of this media.getInFormat(MediaFormat format) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getMediaByFormat(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaFormatModel)instead.Generated method - Getter of theAbstractMedia.locationattribute.getURL()getURL(SessionContext ctx) The URL for use in jsp pages in order to view this medias raw data file (image etc).getURL2()Deprecated.since ages - usegetURL()insteadgetURL2(SessionContext ctx) Deprecated.since ages - usegetURL(SessionContext)insteadDeprecated.since ages - don't use any more - usegetZipEntryNames()insteadIf the media is of type ZIP-archive, then it gets all entry names of the archive.booleanhasData()Checks whether a data file is assigned to this media.booleanTells if there are other medias referencing the data file of this media.booleanDeprecated.since ages - usehasData()insteadbooleanisRemovableAsPrimitive(SessionContext context) Checks whether the media can be removed or is locked by a job.voidDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#moveData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.voidmoveDataTo(Media destin) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#moveData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.booleanmoveMedia(MediaFolder newFolder) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setFolderForMedia(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaFolderModel)instead.protected booleanmoveMedia(MediaFolder newFolder, boolean forOverwriting) Deprecated.booleanrelocateData(MediaFolder folder) Deprecated.since agesvoidremove(SessionContext context) Removes this item.voidremoveData(boolean failOnError) Removes related data and clears all metadata informations.voidsetData(byte[] data) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setDataForMedia(de.hybris.platform.core.model.media .MediaModel, byte[])instead.voidDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#copyData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.voidsetData(DataInputStream stream) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadfinal voidsetData(DataInputStream stream, String originalName, String mimeType) Deprecated.since agesvoidsetData(DataInputStream stream, String originalName, String mimeType, MediaFolder folder) Deprecated.since agesvoidsetData(InputStream stream) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadfinal voidsetData(InputStream stream, String originalName, String mimeType) Sets given data to media by writing content of given stream to a new data file.voidsetData(InputStream stream, String originalName, String mimeType, MediaFolder folder) Sets given data to media by writing content of given stream to a new data file.voidLoads the data from the medias URL.voidsetDataFromStream(DataInputStream stream) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidsetDataFromStream(InputStream stream) Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidGenerated method - Setter of theAbstractMedia.dataPKattribute.voidsetDeniedPrincipals(SessionContext ctx, Collection<Principal> value) voidsetDeniedPrincipals(Collection<Principal> value) booleanUploads a file for this media.booleansetFile(File file, MediaFolder newFolder) Uploads a file for this media.voidsetPermittedPrincipals(SessionContext ctx, Collection<Principal> value) voidvoidGenerated method - Setter of theAbstractMedia.sizeattribute.voidsetURL(SessionContext ctx, String url) Sets a custom URL for this media.voidvoidsetURL2(SessionContext ctx, String url) Deprecated.since agesvoidDeprecated.since agestoString()Returns theStringrepresentation of this item.Methods inherited from class de.hybris.platform.jalo.media.GeneratedMedia
addToDerivedMedias, addToDerivedMedias, getAltText, getAltText, getCode, getCode, getDefaultAttributeModes, getDerivedMedias, getDerivedMedias, getDescription, getDescription, getFolder, getInternalURL, getInternalURL, getMediaContainer, getMediaContainer, getMediaFormat, getMediaFormat, getSubFolderPath, getSubFolderPath, isRemovable, isRemovable, isRemovableAsPrimitive, removeFromDerivedMedias, removeFromDerivedMedias, setAltText, setAltText, setCode, setCode, setDerivedMedias, setDerivedMedias, setDescription, setDescription, setFolder, setFolder, setInternalURL, setInternalURL, setMediaContainer, setMediaContainer, setMediaFormat, setMediaFormat, setRemovable, setRemovable, setRemovable, setRemovable, setSubFolderPath, setSubFolderPathMethods inherited from class de.hybris.platform.jalo.media.GeneratedAbstractMedia
getDataPK, getDataPK, getDataPKAsPrimitive, getDataPKAsPrimitive, getLocation, getLocationHash, getLocationHash, getMime, getMime, getRealFileName, getRealFileName, getSize, getSize, getSizeAsPrimitive, getSizeAsPrimitive, setDataPK, setDataPK, setDataPK, setLocation, setLocation, setLocationHash, setLocationHash, setMime, setMime, setRealFileName, setRealFileName, setSize, setSize, setSizeMethods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getNonInitialAttributes, getRelatedItems, getRelatedItems, setRelatedItemsMethods inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertyMethods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyMethods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPartOfRemovedSessionMarker, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isMarkModifiedDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setTransientObject, setUseTA, suppressRelation, useTA, writeReplaceMethods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
Field Details
-
URL
- See Also:
-
FROM_JAR
Deprecated.since ages - useDefaultMediaService.FROM_JARinstead.Constant for fromjar prefix in case data is located in classpath.- See Also:
-
THUMBNAIL
Deprecated.since agesSample qualifier which can be used to get a product-media-link.
This constant is a qualifier which can be used by LinkManager methods. Use LinkManager.getLink( Media.THUMBNAIL, prod, ... ) to get the thumbnail to a product.- See Also:
-
PICTURE
Deprecated.since agesSample qualifier which can be used to get a product-media-link.
This constant is a qualifier which can be used by LinkManager methods. Use LinkManager.getLink( Media.PICTURE, prod, ... ) to get the picture to a product.- See Also:
-
URL2
Constant identifier forurl2attribute of Media type.- See Also:
-
HASDATA
Constant identifier forhasdataattribute of Media type.- See Also:
-
ISONSERVER
Constant identifier forisonserverattribute of Media type.- See Also:
-
-
Constructor Details
-
Media
public Media()
-
-
Method Details
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException Description copied from class:ItemHas to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) duringComposedType.newInstance(Map).In case this method uses any of the attribute values during creation it is required to override
Item.getNonInitialAttributes(SessionContext, ItemAttributeMap)too.
Sn example:public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) ); // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes( SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret = super.getNonInitialAttributes( ctx, allAttributes ); // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }- Overrides:
createItemin classGeneratedMedia- Parameters:
ctx- the current session context which this item is created withintype- the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )- Returns:
- the new item instance
- Throws:
JaloBusinessException- indicates an error during creation - any changes will be rollbacked
-
setFile
Uploads a file for this media. This includes uploading its actual data, setting the real filename to its filename.- Parameters:
file- the file to upload (must be readable!)- Returns:
- true if the upload was successful
- Throws:
JaloBusinessException
-
setFile
Uploads a file for this media. This includes uploading its actual data, setting the real filename to its filename.- Parameters:
file- the file to upload (must be readable!)newFolder- the new folder for this media where the new file will be located at- Returns:
- true if the upload was successful
- Throws:
JaloBusinessException- Since:
- 3.1-u7
-
getURL
-
getURL
The URL for use in jsp pages in order to view this medias raw data file (image etc). Once setURL(String) was called this medias rely upon this URL has been correct. AftersetData(byte[])was called an automatically generated URL will be returned which points to the uploaded file -
getURL2
Deprecated.since ages - usegetURL(SessionContext)insteadJaloOnly methods which are only used to display the preview and the url in the hybris Management Console- Returns:
- the URL of the media, same as getURL()
-
getURL2
Deprecated.since ages - usegetURL()instead -
setURL2
@Deprecated(since="ages", forRemoval=false) public void setURL2(SessionContext ctx, String url) throws JaloBusinessException Deprecated.since agesJaloOnly method which is only used to workaround a hmc problem. This method does absolutely the same as setURL ( url ).- Throws:
JaloBusinessException
-
setURL2
@Deprecated(since="ages", forRemoval=false) public void setURL2(String url) throws JaloBusinessException Deprecated.since ages- Throws:
JaloBusinessException
-
getDownloadURL
The URL for use in jsp pages in order to download this medias raw data file (image etc). The value ofGeneratedMedia.getInternalURL()URL()} will expanded by:- If mime and realfilename are set: ?mime=[return value of
GeneratedAbstractMedia.getMime()]&realname=[return value ofGeneratedAbstractMedia.getRealFileName()] - If mime is not set: ?realname=[return value of
GeneratedAbstractMedia.getRealFileName()] - If realfilename is not set: ?mime=[return value of
GeneratedAbstractMedia.getMime()] - If both mime and relafilename are not set the url will not be expanded, so the
GeneratedMedia.getInternalURL()call will be returned directly
- If mime and realfilename are set: ?mime=[return value of
-
getDownloadURL
-
copyToTempFile
- Throws:
IOException
-
relocateData
Deprecated.since agesRelocates data to another location. If data is also used by other media objects these objects metadata will be update accordingly.- Parameters:
folder- the folder to which move data file- Returns:
- true, if successful
-
setData
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadSets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to media
-
setData
@Deprecated(since="ages", forRemoval=false) public final void setData(DataInputStream stream, String originalName, String mimeType) Deprecated.since agesSets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to mediaoriginalName- original name of the datamimeType- mime type of data
-
setData
Sets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to mediaoriginalName- original name of the datamimeType- mime type of data
-
setData
@Deprecated(since="ages", forRemoval=false) public void setData(DataInputStream stream, String originalName, String mimeType, MediaFolder folder) Deprecated.since agesSets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to mediaoriginalName- original name of the datamimeType- mime type of datafolder- folder where the data will be written to- Since:
- 3.1-u4
-
setData
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadSets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to media
-
setData
Sets given data to media by writing content of given stream to a new data file.- Parameters:
stream- stream whose content will be set as data to mediaoriginalName- original name of the datamimeType- mime type of datafolder- folder where the data will be written to- Since:
- 3.1-u4
-
setURL
- Throws:
JaloBusinessException
-
setURL
Sets a custom URL for this media. Any previously stored raw data file will be deleted.- Throws:
JaloBusinessException
-
hasData
public boolean hasData()Checks whether a data file is assigned to this media. Will return false in case data is assigned by URL only. -
isOnServer
Deprecated.since ages - usehasData()insteadCheck if file of that media is uploaded. -
setSize
Description copied from class:GeneratedAbstractMediaGenerated method - Setter of theAbstractMedia.sizeattribute.- Overrides:
setSizein classGeneratedAbstractMedia- Parameters:
size- the size - Size of referenced data file.
-
isRemovableAsPrimitive
Checks whether the media can be removed or is locked by a job. If it is not removable and you try to remove it, aConsistencyCheckExceptionwill be raised while call ofremove. Change default null handling- Overrides:
isRemovableAsPrimitivein classGeneratedMedia- Returns:
- is the media removable?
-
checkRemovable
Description copied from class:ItemChecks whether or not this it may be removed or not. Called before the actual removal process.- Overrides:
checkRemovablein classItem- Throws:
ConsistencyCheckException- to indicate that the item cannot be removed
-
remove
Description copied from class:ItemRemoves this item.This method is using the following attributes of the given SessionContext:
CacheUsage Language StagingMethod n/a (this is a setter method) no, language doesn't matter for removal yes if called on a StageableItem, no otherwise
- Overrides:
removein classItem- Parameters:
context- A SessionContext object- Throws:
ConsistencyCheckException- if this item could not be removed for some reason
-
setDataByURL
Loads the data from the medias URL. Loads the file specified by getURL(), and puts it into the media by setDataFromStream(). If the media has no mime type, the mime type is tried to be guessed, first by the extension of the URL, and secondly by the content of the data.- Throws:
JaloSystemException- if the media has already data (hasData()).IOExceptionJaloBusinessException
-
removeData
Removes related data and clears all metadata informations. Keep in mind that data will be removed physically only when there is no other media sharing same binary data.- Throws:
JaloBusinessException- if exception occurs and failOnError flag is set
-
getForeignDataOwners
-
getForeignDataOwners
Gets all medias excluding this one referencing data file of this media.- Returns:
- other medias referencing same data file
- Since:
- 3.1-u6
-
hasForeignDataOwners
public boolean hasForeignDataOwners()Tells if there are other medias referencing the data file of this media.- Since:
- 3.1-u8
-
getDataFromStream
@Deprecated(since="ages", forRemoval=false) public DataInputStream getDataFromStream() throws JaloBusinessExceptionDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadReturns a stream object which makes this medias raw data file available. This can only succeed if once setData(byte[]) or setDataFromStream(DataInputStream) has been called. BEWARE: clients that call this method have to close the returned stream, or they will block further operations on this Media object !- Returns:
- the media's data as stream
- Throws:
JaloBusinessException- if no actual data was uploaded
-
getDataFromInputStream
@Deprecated(since="ages", forRemoval=false) public InputStream getDataFromInputStream() throws JaloBusinessExceptionDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadReturns a stream object which makes this medias raw data file available. This can only succeed if once setData(byte[]) or setDataFromStream(DataInputStream) has been called. BEWARE: clients that call this method have to close the returned stream, or they will block further operations on this Media object !- Returns:
- the media's data as stream
- Throws:
JaloBusinessException- if no actual data was uploaded
-
getDataFromStreamSure
@Deprecated(since="ages", forRemoval=false) public DataInputStream getDataFromStreamSure() throws JaloBusinessExceptionDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)instead.Gets a stream of related data asgetDataFromStream()method but additionally for medias having data set by fromjar notation (reading directly from classpath file).- Throws:
JaloBusinessException
-
getDataFromInputStreamSure
@Deprecated(since="ages", forRemoval=false) public InputStream getDataFromInputStreamSure() throws JaloBusinessExceptionDeprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadGets a stream of related data asgetDataFromStream()method but additionally for medias having data set by fromjar notation (reading directly from classpath file).- Throws:
JaloBusinessException
-
setDataFromStream
@Deprecated(since="ages", forRemoval=false) public void setDataFromStream(DataInputStream stream) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadSets given data to media by writing content of given stream to a new data file. Sets mime type and realfilename tonull.- Throws:
JaloBusinessException
-
setDataFromStream
@Deprecated(since="ages", forRemoval=false) public void setDataFromStream(InputStream stream) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadSets given data to media by writing content of given stream to a new data file. Sets mime type and realfilename tonull.- Throws:
JaloBusinessException
-
getData
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getDataFromMedia(de.hybris.platform.core.model.media .MediaModel)instead.Returns the stored file as raw data array. This can only succeed if once setData(byte[]) or setDataFromStream(DataInputStream) has been called once before.- Throws:
JaloBusinessException- if no actual data was uploaded
-
setData
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#copyData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.Copies data from given media to this media. This method is optimized for reusing data files without actually copying them so it should be preferred to stream based methods likesetData(InputStream)! In case the source media does not hold own data but points to a URL this media simply takes the URL - no real data is copied.- Parameters:
sourceMedia- media which hold source data- Throws:
JaloInvalidParameterException- if given media is null or does not provide any data (either by file or URL)- Since:
- 3.1-u6
-
setData
@Deprecated(since="ages", forRemoval=false) public void setData(byte[] data) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setDataForMedia(de.hybris.platform.core.model.media .MediaModel, byte[])instead.Sets given data into uploaded files- Throws:
JaloBusinessException
-
getFiles
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getFiles(de.hybris.platform.core.model.media .MediaModel)instead.Gets file of given media (from all media replication directories) as collection ofFile's.- Throws:
JaloSystemException- if no file was found
-
getFile
- Throws:
JaloSystemException
-
getFileName
Gives name of uploaded file. It has name in following format: [DataPkString].[mime_extension] -
getFileExtensionFromMime
-
moveData
@Deprecated(since="ages", forRemoval=false) public void moveData(Media destin) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#moveData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.Moves the medias data to another media. After this method, this media has no data anymore.- Parameters:
destin- target media to move data to- Throws:
JaloBusinessException- if this media has no data
-
moveDataTo
@Deprecated(since="ages", forRemoval=false) public void moveDataTo(Media destin) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#moveData(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaModel)instead.Moves the medias data to another media. After this method, this media has no data anymore.- Parameters:
destin- target media to move data to- Throws:
JaloSystemException- if source media has no dataJaloBusinessException
-
moveMedia
@Deprecated(since="ages", forRemoval=false) public boolean moveMedia(MediaFolder newFolder) throws JaloBusinessException Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setFolderForMedia(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaFolderModel)instead.Moves the data of media to given folder.- Parameters:
newFolder- folder where the data has to be moved to- Returns:
- true if the data was moved, false otherwise (f.e. in case the old folder is the same as the new one)
- Throws:
JaloBusinessException- in case an IOException is thrown while move- Since:
- 3.1-u4
-
moveMedia
@Deprecated(since="ages", forRemoval=false) protected boolean moveMedia(MediaFolder newFolder, boolean forOverwriting) throws JaloBusinessException Deprecated.Moves the data of media to given folder.- Parameters:
newFolder- folder where the data has to be moved toforOverwriting- special case: if data is going to be overwritten anyway we can optimize moving data a bit- Returns:
- true if the data was moved, false otherwise (f.e. in case the old folder is the same as the new one)
- Throws:
JaloBusinessException- in case an IOException is thrown while move- Since:
- 3.1-u8
-
getFileNameForFileBasedSoftware
Returns <dataPk>.<mime> if the media has data, else it returns the url part without server/port (and without the 'fromjar/' which is used when loading files from jars), e.g. <dir>/<realname>.<mime>. This method can be used e.g. when using Indesign and must provide a String which should be converted to an image.- Returns:
- the file name for file based software
- Since:
- 3.0
-
getZipEntryNames
If the media is of type ZIP-archive, then it gets all entry names of the archive.- Returns:
- name of all archive entries, if media has mime
application/zip - Throws:
JaloBusinessException- media is not an zip-archiveIOException- error while reading entry names from archive
-
getZipEntries
@Deprecated(since="ages", forRemoval=false) public List<ZipEntry> getZipEntries() throws IOException, JaloBusinessExceptionDeprecated.since ages - don't use any more - usegetZipEntryNames()insteadIf the media is of type ZIP-archive, then it gets all entries of the archive.- Returns:
- all archive entries, if media has mime
application/zip - Throws:
JaloBusinessException- media is not an zip-archiveIOException- error while reading entries from archive
-
getInFormat
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getMediaByFormat(de.hybris.platform.core.model.media .MediaModel, de.hybris.platform.core.model.media.MediaFormatModel)instead.Returns the media in the specified format using theMediaContainer.getMedia(MediaFormat)method of relatedMediaContainer. Returnsnullif noMediaContaineris assigned (GeneratedMedia.getMediaContainer()returnsnull) or the assignedMediaContainerdoes not provide a media in given format.- Parameters:
format- format the desired media has to have- Returns:
- media in specified format or
nullif no corresponding media in specified format is available - Since:
- 3.0-u5
-
getForContext
Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getMediaByContext(de.hybris.platform.core.model .media.MediaModel, de.hybris.platform.core.model.media.MediaContextModel)instead.Determines the format of the specified media and uses the specified MediaContext to determine the target format. Than it simply returns the specified media in this target format.- Parameters:
context- context which defines the target format- Returns:
- media in specified target format
- Since:
- 3.0-u5
-
toString
Description copied from class:ItemReturns theStringrepresentation of this item. This is by default the representation of the primary key of this item. -
setDataPK
Description copied from class:GeneratedAbstractMediaGenerated method - Setter of theAbstractMedia.dataPKattribute.- Overrides:
setDataPKin classGeneratedAbstractMedia- Parameters:
dataPK- the dataPK - PK of the referenced data file.
-
getFolder
Description copied from class:GeneratedMediaGenerated method - Getter of theMedia.folderattribute.- Overrides:
getFolderin classGeneratedMedia- Returns:
- the folder - Sub folder where this media is stored.
-
getLocation
Description copied from class:GeneratedAbstractMediaGenerated method - Getter of theAbstractMedia.locationattribute.- Overrides:
getLocationin classGeneratedAbstractMedia- Returns:
- the location - Generated location (by one of Storage Strategies) to media within storage.
-
getDeniedPrincipals
-
setDeniedPrincipals
-
getDeniedPrincipals
-
setDeniedPrincipals
-
getPermittedPrincipals
-
getPermittedPrincipals
-
setPermittedPrincipals
-
setPermittedPrincipals
-
DefaultMediaService.FROM_JARinstead.