Search in sources :

Example 1 with IKettleFileSystemConfigBuilder

use of org.pentaho.di.core.vfs.configuration.IKettleFileSystemConfigBuilder in project pentaho-kettle by pentaho.

the class KettleVFS method buildFsOptions.

private static FileSystemOptions buildFsOptions(VariableSpace varSpace, FileSystemOptions sourceOptions, String vfsFilename, String scheme) throws IOException {
    if (varSpace == null || vfsFilename == null) {
        // We cannot extract settings from a non-existant variable space
        return null;
    }
    IKettleFileSystemConfigBuilder configBuilder = KettleFileSystemConfigBuilderFactory.getConfigBuilder(varSpace, scheme);
    FileSystemOptions fsOptions = (sourceOptions == null) ? new FileSystemOptions() : sourceOptions;
    String[] varList = varSpace.listVariables();
    for (String var : varList) {
        if (var.startsWith("vfs.")) {
            String param = configBuilder.parseParameterName(var, scheme);
            String varScheme = KettleGenericFileSystemConfigBuilder.extractScheme(var);
            if (param != null) {
                if (varScheme == null || varScheme.equals("sftp") || varScheme.equals(scheme)) {
                    configBuilder.setParameter(fsOptions, param, varSpace.getVariable(var), var, vfsFilename);
                }
            } else {
                throw new IOException("FileSystemConfigBuilder could not parse parameter: " + var);
            }
        }
    }
    return fsOptions;
}
Also used : IKettleFileSystemConfigBuilder(org.pentaho.di.core.vfs.configuration.IKettleFileSystemConfigBuilder) IOException(java.io.IOException) FileSystemOptions(org.apache.commons.vfs2.FileSystemOptions)

Aggregations

IOException (java.io.IOException)1 FileSystemOptions (org.apache.commons.vfs2.FileSystemOptions)1 IKettleFileSystemConfigBuilder (org.pentaho.di.core.vfs.configuration.IKettleFileSystemConfigBuilder)1