Class KettleVFS

java.lang.Object
org.pentaho.di.core.vfs.KettleVFS

public class KettleVFS extends Object
This class now serves two purposes: legacy (deprecated) backwards-compatible access to VFS methods for components that don't yet support Bowls, and singleton/static data and methods that need to still be shared. Most code trying to read and write files over VFS should use getInstance( Bowl ) and IKettleVFS.
  • Field Details

    • TEMP_DIR

      public static final String TEMP_DIR
  • Method Details

    • getFileSystemManager

      public org.apache.commons.vfs2.FileSystemManager getFileSystemManager()
    • getInstance

      public static KettleVFS getInstance()
      Use only when the caller is positive that a Bowl is not in use.
    • getInstance

      public static IKettleVFS getInstance(Bowl bowl)
      Gets a handle on an IKettleVFS for a particular Bowl. It is important that all VFS Filesystems for a given Bowl are shared correctly between instances. VFS Filesystem instances are compared by the FileSystemOptions, and the Bowl is set as a parameter in those options. It is important that all Bowl implementations correctly implement equals() and hashcode() to make this work. It is also critical that there is only one ConnectionManager for a given Bowl. Anything that needs a ConnectionManager (especially including VFS code) should only use Bowl.getConnectionManager() to ensure there is a single instance per bowl.
      Parameters:
      bowl - the bowl for the current context
      Returns:
      IKettleVFS The API for file operations.
    • getFileObject

      @Deprecated public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      only use this method as a last resort if you don't yet have a variables object. Since VFS connections can be used with variables for the dialog fields, it is important to pass the Variables to getFileObject. Failure to do this means any settings for the job/ktr will not be available for variables substitution. Use getFileObject( String vfsFilename, VariableSpace space ), instead and pass the steps/entries variable space.
      Parameters:
      vfsFilename -
      Returns:
      Throws:
      KettleFileException
    • getFileObject

      @Deprecated public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, VariableSpace space) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getFileObject

      @Deprecated public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, org.apache.commons.vfs2.FileSystemOptions fsOptions) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getFileObject

      @Deprecated public static org.apache.commons.vfs2.FileObject getFileObject(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • normalizePath

      protected static String normalizePath(String path, String scheme)
    • hasSchemePattern

      public static boolean hasSchemePattern(String path)
    • hasSchemePattern

      protected static boolean hasSchemePattern(String path, String patternString)
    • cleanseFilename

      public static String cleanseFilename(String vfsFilename)
      Private method for stripping password from filename when a FileObject can not be obtained. getFriendlyURI(FileObject) or getFriendlyURI(String) are the public methods.
    • getTextFileContent

      @Deprecated public static String getTextFileContent(String vfsFilename, String charSetName) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Read a text file (like an XML document). WARNING DO NOT USE FOR DATA FILES.
      Parameters:
      vfsFilename - the filename or URL to read from
      charSetName - the character set of the string (UTF-8, ISO8859-1, etc)
      Returns:
      The content of the file as a String
      Throws:
      IOException
      KettleFileException
    • getTextFileContent

      @Deprecated public static String getTextFileContent(String vfsFilename, VariableSpace space, String charSetName) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • fileExists

      @Deprecated public static boolean fileExists(String vfsFilename) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • fileExists

      @Deprecated public static boolean fileExists(String vfsFilename, VariableSpace space) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getInputStream

      public static InputStream getInputStream(org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
      Throws:
      org.apache.commons.vfs2.FileSystemException
    • getInputStream

      @Deprecated public static InputStream getInputStream(String vfsFilename) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getInputStream

      @Deprecated public static InputStream getInputStream(String vfsFilename, VariableSpace space) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getOutputStream

      @Deprecated public static OutputStream getOutputStream(org.apache.commons.vfs2.FileObject fileObject, boolean append) throws IOException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      IOException
    • getOutputStream

      @Deprecated public static OutputStream getOutputStream(String vfsFilename, boolean append) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getOutputStream

      @Deprecated public static OutputStream getOutputStream(String vfsFilename, VariableSpace space, boolean append) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getOutputStream

      @Deprecated public static OutputStream getOutputStream(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions, boolean append) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getFilename

      public static String getFilename(org.apache.commons.vfs2.FileObject fileObject)
    • getFriendlyURI

      @Deprecated public static String getFriendlyURI(String filename)
      Deprecated.
      use getInstance( Bowl )
    • getFriendlyURI

      @Deprecated public static String getFriendlyURI(String filename, VariableSpace space)
      Deprecated.
      use getInstance( Bowl )
    • getFriendlyURI

      public static String getFriendlyURI(org.apache.commons.vfs2.FileObject fileObject)
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Creates a file using "java.io.tmpdir" directory
      Parameters:
      prefix - - file name
      prefix - - file extension
      Returns:
      FileObject
      Throws:
      KettleFileException
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, VariableSpace variableSpace) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Creates a file using "java.io.tmpdir" directory
      Parameters:
      prefix - - file name
      suffix - - file extension
      variableSpace - is used to get system variables
      Returns:
      FileObject
      Throws:
      KettleFileException
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, String directory) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Parameters:
      prefix - - file name
      suffix - - file extension
      directory - - directory where file will be created
      Returns:
      FileObject
      Throws:
      KettleFileException
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, String suffix, String directory) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, KettleVFS.Suffix suffix, String directory, VariableSpace space) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Parameters:
      prefix - - file name
      directory - path to directory where file will be created
      space - is used to get system variables
      Returns:
      FileObject
      Throws:
      KettleFileException
    • createTempFile

      @Deprecated public static org.apache.commons.vfs2.FileObject createTempFile(String prefix, String suffix, String directory, VariableSpace space) throws KettleFileException
      Deprecated.
      use getInstance( Bowl )
      Throws:
      KettleFileException
    • getComparator

      public static Comparator<org.apache.commons.vfs2.FileObject> getComparator()
    • getFileInputStream

      @Deprecated public static FileInputStream getFileInputStream(org.apache.commons.vfs2.FileObject fileObject) throws IOException
      Deprecated.
      because of API change in Apache VFS. As a workaround use FileObject.getName().getPathDecoded(); Then use a regular File() object to create a File Input stream.
      Get a FileInputStream for a local file. Local files can be read with NIO.
      Parameters:
      fileObject -
      Returns:
      a FileInputStream
      Throws:
      IOException
    • startsWithScheme

      public static boolean startsWithScheme(String vfsFileName)
      Check if filename starts with one of the known protocols like file: zip: ram: smb: jar: etc. If yes, return true otherwise return false
      Parameters:
      vfsFileName -
      Returns:
      boolean
    • closeEmbeddedFileSystem

      public static void closeEmbeddedFileSystem(String embeddedMetastoreKey)
    • reset

      public void reset()
      resets the FileSystemManager
    • freeUnusedResources

      public static void freeUnusedResources()
      See Also:
      • DefaultFileSystemManager.freeUnusedResources()