Package org.pentaho.di.core.vfs
Class KettleVFS
java.lang.Object
org.pentaho.di.core.vfs.KettleVFS
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.
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
cleanseFilename
(String vfsFilename) Private method for stripping password from filename when a FileObject can not be obtained.static void
closeEmbeddedFileSystem
(String embeddedMetastoreKey) static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, String suffix, String directory) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, String suffix, String directory, VariableSpace space) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, KettleVFS.Suffix suffix) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, KettleVFS.Suffix suffix, String directory) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, KettleVFS.Suffix suffix, String directory, VariableSpace space) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
createTempFile
(String prefix, KettleVFS.Suffix suffix, VariableSpace variableSpace) Deprecated.use getInstance( Bowl )static boolean
fileExists
(String vfsFilename) Deprecated.use getInstance( Bowl )static boolean
fileExists
(String vfsFilename, VariableSpace space) Deprecated.use getInstance( Bowl )static void
static Comparator<org.apache.commons.vfs2.FileObject>
static FileInputStream
getFileInputStream
(org.apache.commons.vfs2.FileObject fileObject) Deprecated.because of API change in Apache VFS.static String
getFilename
(org.apache.commons.vfs2.FileObject fileObject) static org.apache.commons.vfs2.FileObject
getFileObject
(String vfsFilename) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
getFileObject
(String vfsFilename, org.apache.commons.vfs2.FileSystemOptions fsOptions) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
getFileObject
(String vfsFilename, VariableSpace space) Deprecated.use getInstance( Bowl )static org.apache.commons.vfs2.FileObject
getFileObject
(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions) Deprecated.use getInstance( Bowl )org.apache.commons.vfs2.FileSystemManager
static String
getFriendlyURI
(String filename) Deprecated.use getInstance( Bowl )static String
getFriendlyURI
(String filename, VariableSpace space) Deprecated.use getInstance( Bowl )static String
getFriendlyURI
(org.apache.commons.vfs2.FileObject fileObject) static InputStream
getInputStream
(String vfsFilename) Deprecated.use getInstance( Bowl )static InputStream
getInputStream
(String vfsFilename, VariableSpace space) Deprecated.use getInstance( Bowl )static InputStream
getInputStream
(org.apache.commons.vfs2.FileObject fileObject) static KettleVFS
Use only when the caller is positive that a Bowl is not in use.static IKettleVFS
getInstance
(Bowl bowl) Gets a handle on an IKettleVFS for a particular Bowl.static OutputStream
getOutputStream
(String vfsFilename, boolean append) Deprecated.use getInstance( Bowl )static OutputStream
getOutputStream
(String vfsFilename, VariableSpace space, boolean append) Deprecated.use getInstance( Bowl )static OutputStream
getOutputStream
(String vfsFilename, VariableSpace space, org.apache.commons.vfs2.FileSystemOptions fsOptions, boolean append) Deprecated.use getInstance( Bowl )static OutputStream
getOutputStream
(org.apache.commons.vfs2.FileObject fileObject, boolean append) Deprecated.use getInstance( Bowl )static String
getTextFileContent
(String vfsFilename, String charSetName) Deprecated.use getInstance( Bowl )static String
getTextFileContent
(String vfsFilename, VariableSpace space, String charSetName) Deprecated.use getInstance( Bowl )static boolean
hasSchemePattern
(String path) protected static boolean
hasSchemePattern
(String path, String patternString) protected static String
normalizePath
(String path, String scheme) void
reset()
resets the FileSystemManagerstatic boolean
startsWithScheme
(String vfsFileName) Check if filename starts with one of the known protocols like file: zip: ram: smb: jar: etc.
-
Field Details
-
TEMP_DIR
-
-
Method Details
-
getFileSystemManager
public org.apache.commons.vfs2.FileSystemManager getFileSystemManager() -
getInstance
Use only when the caller is positive that a Bowl is not in use. -
getInstance
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
-
hasSchemePattern
-
hasSchemePattern
-
cleanseFilename
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 fromcharSetName
- 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.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.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
-
getFriendlyURI
Deprecated.use getInstance( Bowl ) -
getFriendlyURI
Deprecated.use getInstance( Bowl ) -
getFriendlyURI
-
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 nameprefix
- - 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 namesuffix
- - file extensionvariableSpace
- 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 namesuffix
- - file extensiondirectory
- - 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 namedirectory
- path to directory where file will be createdspace
- 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
-
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
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
-
reset
public void reset()resets the FileSystemManager -
freeUnusedResources
public static void freeUnusedResources()- See Also:
-
DefaultFileSystemManager.freeUnusedResources()
-