Package de.hybris.platform.jalo.media
Class Media
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable
- Direct Known Subclasses:
GeneratedBarcodeMedia,GeneratedCatalogUnawareMedia,GeneratedCatalogVersionSyncScheduleMedia,GeneratedConfigurationMedia,GeneratedDocument,GeneratedDroolsKIEModuleMedia,GeneratedEmailAttachment,GeneratedFormatter,GeneratedImpExMedia,GeneratedImportCockpitMapping,GeneratedJasperMedia,GeneratedJobMedia,GeneratedLDIFMedia,GeneratedLogFile,MediaTest.TestMedia
public class Media extends GeneratedMedia
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImpl
-
Nested 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
Fields Modifier and Type Field Description static java.lang.StringFROM_JARDeprecated.since ages - useDefaultMediaService.FROM_JARinstead.static java.lang.StringHASDATAConstant identifier forhasdataattribute of Media type.static java.lang.StringISONSERVERConstant identifier forisonserverattribute of Media type.static java.lang.StringPICTUREDeprecated.since agesstatic java.lang.StringTHUMBNAILDeprecated.since agesstatic java.lang.StringURLstatic java.lang.StringURL2Constant 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, SUBFOLDERPATH
-
Fields inherited from class de.hybris.platform.jalo.media.GeneratedAbstractMedia
DATAPK, LOCATION, LOCATIONHASH, MIME, REALFILENAME, SIZE
-
Fields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLED
-
Fields 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, TYPE
-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description Media()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckRemovable(SessionContext ctx)Checks whether or not this it may be removed or not.protected java.io.FilecopyToTempFile(java.io.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.java.io.InputStreamgetDataFromInputStream()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadjava.io.InputStreamgetDataFromInputStreamSure()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadjava.io.DataInputStreamgetDataFromStream()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)insteadjava.io.DataInputStreamgetDataFromStreamSure()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getStreamFromMedia(de.hybris.platform.core.model .media.MediaModel)instead.java.util.Collection<Principal>getDeniedPrincipals()java.util.Collection<Principal>getDeniedPrincipals(SessionContext ctx)java.lang.StringgetDownloadURL()java.lang.StringgetDownloadURL(SessionContext ctx)The URL for use in jsp pages in order to download this medias raw data file (image etc).java.io.FilegetFile()protected java.lang.StringgetFileExtensionFromMime()java.lang.StringgetFileName()Gives name of uploaded file.java.lang.StringgetFileNameForFileBasedSoftware()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.java.util.CollectiongetFiles()Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#getFiles(de.hybris.platform.core.model.media .MediaModel)instead.MediaFoldergetFolder(SessionContext ctx)Generated method - Getter of theMedia.folderattribute.MediagetForContext(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.java.util.Collection<Media>getForeignDataOwners()java.util.Collection<Media>getForeignDataOwners(SessionContext ctx)Gets all medias excluding this one referencing data file of this media.MediagetInFormat(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.java.lang.StringgetLocation(SessionContext ctx)Generated method - Getter of theAbstractMedia.locationattribute.java.util.Collection<Principal>getPermittedPrincipals()java.util.Collection<Principal>getPermittedPrincipals(SessionContext ctx)java.lang.StringgetURL()java.lang.StringgetURL(SessionContext ctx)The URL for use in jsp pages in order to view this medias raw data file (image etc).java.lang.StringgetURL2()Deprecated.since ages - usegetURL()insteadjava.lang.StringgetURL2(SessionContext ctx)Deprecated.since ages - usegetURL(SessionContext)insteadjava.util.List<java.util.zip.ZipEntry>getZipEntries()Deprecated.since ages - don't use any more - usegetZipEntryNames()insteadjava.util.List<java.lang.String>getZipEntryNames()If 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.booleanhasForeignDataOwners()Tells if there are other medias referencing the data file of this media.booleanisOnServer()Deprecated.since ages - usehasData()insteadbooleanisRemovableAsPrimitive(SessionContext context)Checks whether the media can be removed or is locked by a job.voidmoveData(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.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.voidsetData(Media sourceMedia)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.voidsetData(java.io.DataInputStream stream)Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidsetData(java.io.DataInputStream stream, java.lang.String originalName, java.lang.String mimeType)Deprecated.since agesvoidsetData(java.io.DataInputStream stream, java.lang.String originalName, java.lang.String mimeType, MediaFolder folder)Deprecated.since agesvoidsetData(java.io.InputStream stream)Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidsetData(java.io.InputStream stream, java.lang.String originalName, java.lang.String mimeType)Sets given data to media by writing content of given stream to a new data file.voidsetData(java.io.InputStream stream, java.lang.String originalName, java.lang.String mimeType, MediaFolder folder)Sets given data to media by writing content of given stream to a new data file.voidsetDataByURL()Loads the data from the medias URL.voidsetDataFromStream(java.io.DataInputStream stream)Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidsetDataFromStream(java.io.InputStream stream)Deprecated.since ages - usede.hybris.platform.servicelayer.media.MediaService#setStreamForMedia(de.hybris.platform.core.model.media .MediaModel, InputStream)insteadvoidsetDataPK(java.lang.Long dataPK)Generated method - Setter of theAbstractMedia.dataPKattribute.voidsetDeniedPrincipals(SessionContext ctx, java.util.Collection<Principal> value)voidsetDeniedPrincipals(java.util.Collection<Principal> value)booleansetFile(java.io.File file)Uploads a file for this media.booleansetFile(java.io.File file, MediaFolder newFolder)Uploads a file for this media.voidsetPermittedPrincipals(SessionContext ctx, java.util.Collection<Principal> value)voidsetPermittedPrincipals(java.util.Collection<Principal> value)voidsetSize(java.lang.Long size)Generated method - Setter of theAbstractMedia.sizeattribute.voidsetURL(SessionContext ctx, java.lang.String url)Sets a custom URL for this media.voidsetURL(java.lang.String url)voidsetURL2(SessionContext ctx, java.lang.String url)Deprecated.since agesvoidsetURL2(java.lang.String url)Deprecated.since agesjava.lang.StringtoString()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, setSubFolderPath
-
Methods 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, setSize
-
Methods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getNonInitialAttributes, getRelatedItems, setRelatedItems
-
Methods 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, setLocalizedProperty
-
Methods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setProperty
-
Methods 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, 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, useTA, writeReplace
-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
Field Detail
-
URL
public static final java.lang.String URL
- See Also:
- Constant Field Values
-
FROM_JAR
@Deprecated public static final java.lang.String FROM_JAR
Deprecated.since ages - useDefaultMediaService.FROM_JARinstead.Constant for fromjar prefix in case data is located in classpath.- See Also:
- Constant Field Values
-
THUMBNAIL
@Deprecated public static final java.lang.String 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:
- Constant Field Values
-
PICTURE
@Deprecated public static final java.lang.String 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:
- Constant Field Values
-
URL2
public static final java.lang.String URL2
Constant identifier forurl2attribute of Media type.- See Also:
- Constant Field Values
-
HASDATA
public static final java.lang.String HASDATA
Constant identifier forhasdataattribute of Media type.- See Also:
- Constant Field Values
-
ISONSERVER
public static final java.lang.String ISONSERVER
Constant identifier forisonserverattribute of Media type.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public boolean setFile(java.io.File file) throws JaloBusinessExceptionUploads 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
public boolean setFile(java.io.File file, MediaFolder newFolder) throws JaloBusinessExceptionUploads 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
public java.lang.String getURL()
-
getURL
public java.lang.String getURL(SessionContext ctx)
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 public java.lang.String getURL2(SessionContext ctx)
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 public java.lang.String getURL2()
Deprecated.since ages - usegetURL()instead
-
setURL2
@Deprecated public void setURL2(SessionContext ctx, java.lang.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 public void setURL2(java.lang.String url) throws JaloBusinessExceptionDeprecated.since ages- Throws:
JaloBusinessException
-
getDownloadURL
public java.lang.String getDownloadURL(SessionContext ctx)
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
public java.lang.String getDownloadURL()
-
copyToTempFile
protected java.io.File copyToTempFile(java.io.InputStream inputStream) throws java.io.IOException- Throws:
java.io.IOException
-
relocateData
@Deprecated public boolean relocateData(MediaFolder folder)
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 public void setData(java.io.DataInputStream stream)
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 public final void setData(java.io.DataInputStream stream, java.lang.String originalName, java.lang.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
public final void setData(java.io.InputStream stream, java.lang.String originalName, java.lang.String mimeType)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 public void setData(java.io.DataInputStream stream, java.lang.String originalName, java.lang.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 public void setData(java.io.InputStream stream)
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
public void setData(java.io.InputStream stream, java.lang.String originalName, java.lang.String mimeType, MediaFolder folder)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
public void setURL(java.lang.String url) throws JaloBusinessException- Throws:
JaloBusinessException
-
setURL
public void setURL(SessionContext ctx, java.lang.String url) throws JaloBusinessException
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 public boolean isOnServer()
Deprecated.since ages - usehasData()insteadCheck if file of that media is uploaded.
-
setSize
public void setSize(java.lang.Long size)
Description copied from class:GeneratedAbstractMediaGenerated method - Setter of theAbstractMedia.sizeattribute.- Overrides:
setSizein classGeneratedAbstractMedia- Parameters:
size- the size - Size of referenced data file.
-
isRemovableAsPrimitive
public boolean isRemovableAsPrimitive(SessionContext context)
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
protected void checkRemovable(SessionContext ctx) throws ConsistencyCheckException
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
public void remove(SessionContext context) throws ConsistencyCheckException
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
public void setDataByURL() throws java.io.IOException, JaloBusinessExceptionLoads 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()).java.io.IOExceptionJaloBusinessException
-
removeData
public void removeData(boolean failOnError) throws JaloBusinessExceptionRemoves 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
public java.util.Collection<Media> getForeignDataOwners()
-
getForeignDataOwners
public java.util.Collection<Media> getForeignDataOwners(SessionContext ctx)
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 public java.io.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 public java.io.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 public java.io.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 public java.io.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 public void setDataFromStream(java.io.DataInputStream stream) throws JaloBusinessExceptionDeprecated.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 public void setDataFromStream(java.io.InputStream stream) throws JaloBusinessExceptionDeprecated.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 public byte[] getData() throws JaloBusinessExceptionDeprecated.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 public void setData(Media sourceMedia)
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 public void setData(byte[] data) throws JaloBusinessExceptionDeprecated.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 public java.util.Collection getFiles() throws JaloSystemExceptionDeprecated.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
public java.io.File getFile() throws JaloSystemException- Throws:
JaloSystemException
-
getFileName
public java.lang.String getFileName()
Gives name of uploaded file. It has name in following format: [DataPkString].[mime_extension]
-
getFileExtensionFromMime
protected java.lang.String getFileExtensionFromMime()
-
moveData
@Deprecated 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 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 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 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
public java.lang.String 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
public java.util.List<java.lang.String> getZipEntryNames() throws java.io.IOException, JaloBusinessExceptionIf 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-archivejava.io.IOException- error while reading entry names from archive
-
getZipEntries
@Deprecated public java.util.List<java.util.zip.ZipEntry> getZipEntries() throws java.io.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-archivejava.io.IOException- error while reading entries from archive
-
getInFormat
@Deprecated public 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.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 public Media 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.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
public java.lang.String toString()
Description copied from class:ItemReturns theStringrepresentation of this item. This is by default the representation of the primary key of this item.
-
setDataPK
public void setDataPK(java.lang.Long dataPK)
Description copied from class:GeneratedAbstractMediaGenerated method - Setter of theAbstractMedia.dataPKattribute.- Overrides:
setDataPKin classGeneratedAbstractMedia- Parameters:
dataPK- the dataPK - PK of the referenced data file.
-
getFolder
public MediaFolder getFolder(SessionContext ctx)
Description copied from class:GeneratedMediaGenerated method - Getter of theMedia.folderattribute.- Overrides:
getFolderin classGeneratedMedia- Returns:
- the folder - Sub folder where this media is stored.
-
getLocation
public java.lang.String getLocation(SessionContext ctx)
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
public java.util.Collection<Principal> getDeniedPrincipals()
-
setDeniedPrincipals
public void setDeniedPrincipals(java.util.Collection<Principal> value)
-
getDeniedPrincipals
public java.util.Collection<Principal> getDeniedPrincipals(SessionContext ctx)
-
setDeniedPrincipals
public void setDeniedPrincipals(SessionContext ctx, java.util.Collection<Principal> value)
-
getPermittedPrincipals
public java.util.Collection<Principal> getPermittedPrincipals()
-
getPermittedPrincipals
public java.util.Collection<Principal> getPermittedPrincipals(SessionContext ctx)
-
setPermittedPrincipals
public void setPermittedPrincipals(java.util.Collection<Principal> value)
-
setPermittedPrincipals
public void setPermittedPrincipals(SessionContext ctx, java.util.Collection<Principal> value)
-
-