Class UploadFileUtils

java.lang.Object
org.pentaho.platform.web.servlet.UploadFileUtils

public class UploadFileUtils extends Object
  • Field Details

    • DEFAULT_RELATIVE_UPLOAD_FILE_PATH

      public static final String DEFAULT_RELATIVE_UPLOAD_FILE_PATH
  • Constructor Details

    • UploadFileUtils

      public UploadFileUtils(org.pentaho.platform.api.engine.IPentahoSession sessionValue)
  • Method Details

    • checkExtension

      protected boolean checkExtension(String extension, boolean emitMessage) throws IOException

      Checks if the given extension is supported.

      A null is an invalid extension; to check if a NoExtension is allowed, an empty string must be given.

      Parameters:
      extension - the extension to check
      emitMessage - if a message is to be written when an error occurs
      Returns:
      true if the given extension is supported, false if it's an invalid or unsupported extension
      Throws:
      IOException
    • process

      public boolean process() throws Exception
      Throws:
      Exception
    • process

      public boolean process(InputStream inputStream) throws Exception
      process uploading using inputStream instead of UploadedFileItem do not support unzipping
      Parameters:
      inputStream -
      Returns:
      true if the processing finished successfully and false otherwise
      Throws:
      Exception
    • handleUnzip

      protected boolean handleUnzip(File file) throws IOException
      Throws:
      IOException
    • handleZip

      protected String handleZip(File file) throws IOException
      Decompress a zip file and return a list of the file names that were unpacked
      Parameters:
      file -
      Returns:
      Throws:
      IOException
    • handleGZip

      protected String handleGZip(File file, boolean fullPath) throws IOException
      Throws:
      IOException
    • handleTar

      protected String handleTar(File file) throws IOException
      Throws:
      IOException
    • handleTarGZ

      protected String handleTarGZ(File file) throws IOException
      Throws:
      IOException
    • checkLimits

      public boolean checkLimits(long itemSize) throws IOException
      Throws:
      IOException
    • checkLimits

      public boolean checkLimits(long itemSize, boolean compressed) throws IOException
      Throws:
      IOException
    • removeFileName

      protected String removeFileName(String filename)

      Removes the file name, leaving all extensions of a given filename.

      Returns null if filename is null, and an empty string if the filename is empty or has no extensions.

      The result, if not null nor an empty string is sanitized by replacing any character that is not a letter (lower or upper case), a digit (0-9), an underscore ("_"), a dot (".") or a dash ("-"), by an underscore ("_").

      Parameters:
      filename - the filename for which we want the extensions
      Returns:
      all extensions (sanitized) of the given filename
    • getFileName

      public String getFileName()
      Getters and Setters
    • setFileName

      public void setFileName(String value)
    • isShouldUnzip

      public boolean isShouldUnzip()
    • setShouldUnzip

      public void setShouldUnzip(boolean value)
    • isTemporary

      public boolean isTemporary()
    • setTemporary

      public void setTemporary(boolean value)
    • setWriter

      public void setWriter(Writer value)
    • getWriter

      public Writer getWriter()
    • setUploadedFileItem

      public void setUploadedFileItem(org.apache.commons.fileupload.FileItem value)
    • getUploadedFileItem

      public org.apache.commons.fileupload.FileItem getUploadedFileItem()
    • getUploadedPart

      public javax.servlet.http.Part getUploadedPart()
    • setUploadedPart

      public void setUploadedPart(javax.servlet.http.Part uploadedPart)
    • getPath

      public String getPath()
    • getPathDir

      public File getPathDir()
    • getRelativePath

      public String getRelativePath()