Package de.hybris.platform.util
Class MediaUtil
java.lang.Object
de.hybris.platform.util.MediaUtil
Tools for medias
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringAdds the leading file separator to the path if it doesn't contain one already.static StringAdds the trailing file separator to the path if it doesn't contain one already.static StringappendFileNameToDirName(String dirname, String filename) static StringassemblePublicMediaURL(String rawUrl) static Stringstatic FilecomposeOrGetParent(File parent, String child) Builds the file from parent file and child pathname which can be directory or file.static FileconcatDirectoryWithFolder(File dir, MediaFolder subFolder) Concatenates given directory with given folder.static longcopy(InputStream is, OutputStream os) Copy the data from the Inputstream to the Outputstream.static longcopy(InputStream is, OutputStream os, boolean closeOutputStream) Copy the data from the Inputstream to the Outputstream.static longcopy(InputStream is, Collection<OutputStream> os) Copy the data from the Inputstream to a Collection of Outputstreams.static longcopy(InputStream is, Collection<OutputStream> outStreams, boolean closeOutputStreams) Copy the data from the InputStream to a Collection of OutputStreams.static voidcopyMediaData(Media src, Media tgt) Deprecated, for removal: This API element is subject to removal in a future version.static final StringgetFileExtension(String filename) Returns the file name extension (lowercase) or, if no '.' is found, the whole file name (without case change).static StringReturns local media web URL root URL.static FileReads directories defined in media.replication.dirs.static final FileReturns the media read directory.static Stringstatic final FileSame asgetMediaReadDir()but including the current tenant subdirectory.static booleanstatic booleanisFileNamePrettyURLCompatible(String realFileName) static booleanisZipRelatedMime(String mime) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useMimeService.isZipRelatedMime(String)instead.static StringnormalizeRealFileName(String realFileName) static StringremoveFileExtension(String fileName) static StringRemoves leading separator from the path if exists.static StringRemoves trailing separator from the path if it exists.static voidstatic voidsetCurrentRequestSSLModeEnabled(boolean enabled) static voidstatic voidstatic voidstatic void
-
Field Details
-
URL_IS_EMPTY
If the URL contains this string, the URL is empty. Use empty string or null. This string is put into URL, when the data is removed. BEWARE: Oracle converts empty strings to null. -
URL_HAS_DATA
- See Also:
-
MEDIA_DATA_DIRS
- See Also:
-
MEDIA_READ_DIR
- See Also:
-
DUMMY_FILE_NAME
- See Also:
-
FILE_SEP
- See Also:
-
-
Constructor Details
-
MediaUtil
public MediaUtil()
-
-
Method Details
-
isCurrentRequestSSLModeEnabled
public static boolean isCurrentRequestSSLModeEnabled() -
setCurrentRequestSSLModeEnabled
public static void setCurrentRequestSSLModeEnabled(boolean enabled) -
unsetCurrentRequestSSLModeEnabled
public static void unsetCurrentRequestSSLModeEnabled() -
setCurrentSecureMediaURLRenderer
-
unsetCurrentSecureMediaURLRenderer
public static void unsetCurrentSecureMediaURLRenderer() -
getCurrentSecureMediaURLRenderer
-
setCurrentPublicMediaURLRenderer
-
unsetCurrentPublicMediaURLRenderer
public static void unsetCurrentPublicMediaURLRenderer() -
getCurrentPublicMediaURLRenderer
-
isZipRelatedMime
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useMimeService.isZipRelatedMime(String)instead.Checks whether provided mime string is zip archive related. -
assembleSecureMediaURL
-
assemblePublicMediaURL
-
getMediaReadDir
Returns the media read directory. If not set in the configuration, a temporary directory will be returned.- Returns:
- media read directory
- See Also:
-
getTenantMediaReadDir
Same asgetMediaReadDir()but including the current tenant subdirectory.- Returns:
- media read directory including tenant subdirectory
- See Also:
-
getLocalStorageReplicationDirs
Reads directories defined in media.replication.dirs. This method is called from getDataDirs when FILE mode is set -
getLocalStorageDataDir
-
composeOrGetParent
Builds the file from parent file and child pathname which can be directory or file. If child is blank or null simply parent is returned. -
getSystemDir
-
copy
Copy the data from the Inputstream to the Outputstream. The Outputstream will always be closed after. Not the Inputstream- Parameters:
is- the Inputstreamos- the Outputstream- Returns:
- how many bytes where copied
- Throws:
IOException- when an error in the inputstream occurs; an error in the outputstream will be catched and printed to the commandline
-
copy
public static long copy(InputStream is, OutputStream os, boolean closeOutputStream) throws IOException Copy the data from the Inputstream to the Outputstream.- Parameters:
is- the Inputstreamos- the OutputstreamcloseOutputStream- set to false if the Outputstream should not be closed afterwards.- Returns:
- how many bytes where copied
- Throws:
IOException- when an error in the inputstream occurs; an error in the outputstream will be catched and printed to the commandline
-
copy
Copy the data from the Inputstream to a Collection of Outputstreams. The Outputstreams will always be closed after. Not the Inputstream- Parameters:
is- the Inputstreamos- a Collection of Outputstreams- Returns:
- how many bytes where copied
- Throws:
IOException- when an error in the inputstream occurs; an error in the outputstreams will be catched and printed to the commandline
-
copy
public static long copy(InputStream is, Collection<OutputStream> outStreams, boolean closeOutputStreams) throws IOException Copy the data from the InputStream to a Collection of OutputStreams. The OutputStreams will only be closed after if closeOutputStream is set to true. Not the InputStream- Parameters:
is- the InputStreamoutStreams- a Collection of OutputStreamscloseOutputStreams- set to false if the OutputStream should not be closed afterwards.- Returns:
- how many bytes where copied
- Throws:
IOException- when an error in the input stream occurs; an error in the output streams will be caught and printed to the command line
-
getLocalMediaWebRootUrl
Returns local media web URL root URL. By default: /medias. -
appendFileNameToDirName
-
getFileExtension
Returns the file name extension (lowercase) or, if no '.' is found, the whole file name (without case change).- Parameters:
filename- the file name to get extension from
-
normalizeRealFileName
-
isFileNamePrettyURLCompatible
-
concatDirectoryWithFolder
Concatenates given directory with given folder. Extracts the relative path from folder and adds it to the directory.- Parameters:
dir- directorysubFolder- folder whose path will be added to directory- Returns:
- new concatenated directory
- Since:
- 3.1-u4
-
addTrailingFileSepIfNeeded
Adds the trailing file separator to the path if it doesn't contain one already.- Parameters:
path- the path- Returns:
- modified path or empty string if path is null or empty
-
removeTrailingFileSepIfNeeded
Removes trailing separator from the path if it exists.- Parameters:
path- the path- Returns:
- modified path
-
removeLeadingFileSepIfNeeded
Removes leading separator from the path if exists.- Parameters:
path- the path- Returns:
- modified path
-
addLeadingFileSepIfNeeded
Adds the leading file separator to the path if it doesn't contain one already.- Parameters:
path- the path- Returns:
- modified path or empty string if path is null or empty
-
copyMediaData
Deprecated, for removal: This API element is subject to removal in a future version. -
removeFileExtension
-
DefaultMediaService.moveData(de.hybris.platform.core.model.media.MediaModel, de.hybris.platform.core.model.media.MediaModel)