Class MediaUtil

java.lang.Object
de.hybris.platform.util.MediaUtil

public class MediaUtil extends Object
Tools for medias
  • Field Details

  • 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

      public static void setCurrentSecureMediaURLRenderer(MediaUtil.SecureMediaURLRenderer renderer)
    • unsetCurrentSecureMediaURLRenderer

      public static void unsetCurrentSecureMediaURLRenderer()
    • getCurrentSecureMediaURLRenderer

      public static MediaUtil.SecureMediaURLRenderer getCurrentSecureMediaURLRenderer()
    • setCurrentPublicMediaURLRenderer

      public static void setCurrentPublicMediaURLRenderer(MediaUtil.PublicMediaURLRenderer renderer)
    • unsetCurrentPublicMediaURLRenderer

      public static void unsetCurrentPublicMediaURLRenderer()
    • getCurrentPublicMediaURLRenderer

      public static MediaUtil.PublicMediaURLRenderer getCurrentPublicMediaURLRenderer()
    • isZipRelatedMime

      @Deprecated(since="ages", forRemoval=true) public static boolean isZipRelatedMime(String mime)
      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

      @Nullable public static String assembleSecureMediaURL(MediaSource media)
    • assemblePublicMediaURL

      @Nullable public static String assemblePublicMediaURL(String rawUrl)
    • getMediaReadDir

      public static final File 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

      public static final File getTenantMediaReadDir()
      Same as getMediaReadDir() but including the current tenant subdirectory.
      Returns:
      media read directory including tenant subdirectory
      See Also:
    • getLocalStorageReplicationDirs

      public static List<File> getLocalStorageReplicationDirs()
      Reads directories defined in media.replication.dirs. This method is called from getDataDirs when FILE mode is set
    • getLocalStorageDataDir

      public static File getLocalStorageDataDir()
    • composeOrGetParent

      public static File composeOrGetParent(File parent, String child)
      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

      public static String getSystemDir()
    • copy

      public static long copy(InputStream is, OutputStream os) throws IOException
      Copy the data from the Inputstream to the Outputstream. The Outputstream will always be closed after. Not the Inputstream
      Parameters:
      is - the Inputstream
      os - 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 Inputstream
      os - the Outputstream
      closeOutputStream - 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

      public static long copy(InputStream is, Collection<OutputStream> os) throws IOException
      Copy the data from the Inputstream to a Collection of Outputstreams. The Outputstreams will always be closed after. Not the Inputstream
      Parameters:
      is - the Inputstream
      os - 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 InputStream
      outStreams - a Collection of OutputStreams
      closeOutputStreams - 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

      public static String getLocalMediaWebRootUrl()
      Returns local media web URL root URL. By default: /medias.
    • appendFileNameToDirName

      public static String appendFileNameToDirName(String dirname, String filename)
    • getFileExtension

      public static final String getFileExtension(String filename)
      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

      public static String normalizeRealFileName(String realFileName)
    • isFileNamePrettyURLCompatible

      public static boolean isFileNamePrettyURLCompatible(String realFileName)
    • concatDirectoryWithFolder

      public static File concatDirectoryWithFolder(File dir, MediaFolder subFolder)
      Concatenates given directory with given folder. Extracts the relative path from folder and adds it to the directory.
      Parameters:
      dir - directory
      subFolder - folder whose path will be added to directory
      Returns:
      new concatenated directory
      Since:
      3.1-u4
    • addTrailingFileSepIfNeeded

      public static String addTrailingFileSepIfNeeded(String path)
      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

      public static String removeTrailingFileSepIfNeeded(String path)
      Removes trailing separator from the path if it exists.
      Parameters:
      path - the path
      Returns:
      modified path
    • removeLeadingFileSepIfNeeded

      public static String removeLeadingFileSepIfNeeded(String path)
      Removes leading separator from the path if exists.
      Parameters:
      path - the path
      Returns:
      modified path
    • addLeadingFileSepIfNeeded

      public static String addLeadingFileSepIfNeeded(String path)
      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(since="ages", forRemoval=true) public static void copyMediaData(Media src, Media tgt)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • removeFileExtension

      public static String removeFileExtension(String fileName)