Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Bowl for all VFS API requests #9579

Open
wants to merge 2 commits into
base: project-profile
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.commons.vfs2.FileSystemOptions;
import org.pentaho.di.connections.ConnectionManager;
import org.pentaho.di.connections.ConnectionProvider;
import org.pentaho.di.core.bowl.Bowl;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.exception.KettleFileException;
import org.pentaho.di.core.variables.Variables;
import org.pentaho.di.core.vfs.KettleVFS;
Expand All @@ -51,12 +53,18 @@ public interface VFSConnectionProvider<T extends VFSConnectionDetails> extends C
*
* @param connectionDetails for the connection
* @param path path relative to the connection
* @deprecated use the version with the Bowl.
* @return FileSystem or null if the provided connection details are not the matching type
*/
@Deprecated
default FileObject getDirectFile( T connectionDetails, String path ) throws KettleFileException {
return getDirectFile( DefaultBowl.getInstance(), connectionDetails, path );
}

default FileObject getDirectFile( Bowl bowl, T connectionDetails, String path ) throws KettleFileException {
String pvfsUrl = connectionDetails.getType() + "://" + path;
// use an empty Variables to prevent other "connection" values from causing StackOverflowErrors
return KettleVFS.getFileObject( pvfsUrl, new Variables(), getOpts( connectionDetails ) );
return KettleVFS.getInstance( bowl ).getFileObject( pvfsUrl, new Variables(), getOpts( connectionDetails ) );
}

/**
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/pentaho/di/core/ResultFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2021 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -25,6 +25,7 @@
import java.util.Date;

import org.apache.commons.vfs2.FileObject;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.exception.KettleFileException;
import org.pentaho.di.core.row.value.ValueMetaDate;
import org.pentaho.di.core.row.value.ValueMetaString;
Expand Down Expand Up @@ -291,7 +292,7 @@ public String getXML() {
public ResultFile( Node node ) throws KettleFileException {
try {
type = getType( XMLHandler.getTagValue( node, "type" ) );
file = KettleVFS.getFileObject( XMLHandler.getTagValue( node, "file" ) );
file = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( XMLHandler.getTagValue( node, "file" ) );
originParent = XMLHandler.getTagValue( node, "parentorigin" );
origin = XMLHandler.getTagValue( node, "origin" );
comment = XMLHandler.getTagValue( node, "comment" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2023 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand Down Expand Up @@ -58,6 +58,7 @@

import org.apache.commons.lang.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.pentaho.di.core.bowl.Bowl;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.plugins.PluginTypeListener;
import org.pentaho.di.core.row.value.ValueMetaPluginType;
Expand Down Expand Up @@ -5025,15 +5026,16 @@ public void setNrExecutedCommits( int nrExecutedCommits ) {
* @throws KettleDatabaseException in case anything goes wrong.
* @sendSinglestatement send one statement
*/
public Result execStatementsFromFile( String filename, boolean sendSinglestatement ) throws KettleException {
public Result execStatementsFromFile( Bowl bowl, String filename, boolean sendSinglestatement )
throws KettleException {
FileObject sqlFile = null;
InputStream is = null;
InputStreamReader bis = null;
try {
if ( Utils.isEmpty( filename ) ) {
throw new KettleException( "Filename is missing!" );
}
sqlFile = KettleVFS.getFileObject( filename );
sqlFile = KettleVFS.getInstance( bowl ).getFileObject( filename );
if ( !sqlFile.exists() ) {
throw new KettleException( "We can not find file [" + filename + "]!" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -26,6 +26,7 @@
import java.util.List;

import org.apache.commons.vfs2.FileObject;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.vfs.KettleVFS;
Expand Down Expand Up @@ -71,10 +72,10 @@ public FileLoggingEventListener( String logChannelId, String filename, boolean a
this.layout = new KettleLogLayout( true );
this.exception = null;

file = KettleVFS.getFileObject( filename );
file = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( filename );
outputStream = null;
try {
outputStream = KettleVFS.getOutputStream( file, append );
outputStream = KettleVFS.getInstance( DefaultBowl.getInstance() ).getOutputStream( file, append );
} catch ( Exception e ) {
throw new KettleException(
"Unable to create a logging event listener to write to file '" + filename + "'", e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2022 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2022-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -29,6 +29,7 @@
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.vfs.KettleVFS;

Expand All @@ -45,13 +46,13 @@ public class Log4jFileAppender implements Appender {
public Log4jFileAppender(FileObject file ) throws IOException {
this.file = file;

fileOutputStream = KettleVFS.getOutputStream( file, false );
fileOutputStream = KettleVFS.getInstance( DefaultBowl.getInstance() ).getOutputStream( file, false );
}

public Log4jFileAppender(FileObject file, boolean append ) throws IOException {
this.file = file;

fileOutputStream = KettleVFS.getOutputStream( file, append );
fileOutputStream = KettleVFS.getInstance( DefaultBowl.getInstance() ).getOutputStream( file, append );
}

public void addFilter( Filter filter ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2019 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand Down Expand Up @@ -45,6 +45,7 @@
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSelectInfo;
import org.apache.commons.vfs2.FileSelector;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.exception.KettleXMLException;
import org.pentaho.di.core.util.Utils;
Expand Down Expand Up @@ -432,7 +433,7 @@ protected List<FileObject> findPluginFiles( String folder, final String regex )

List<FileObject> list = new ArrayList<>();
try {
FileObject folderObject = KettleVFS.getFileObject( folder );
FileObject folderObject = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( folder );
FileObject[] files = folderObject.findFiles( new FileSelector() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2018 by Hitachi Vantara : http://www.pentaho.com
* Copyright (C) 2002-2024 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -27,6 +27,7 @@
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSelectInfo;
import org.apache.commons.vfs2.FileSelector;
import org.pentaho.di.core.bowl.DefaultBowl;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.exception.KettleFileException;
import org.pentaho.di.core.util.EnvUtil;
Expand Down Expand Up @@ -122,7 +123,7 @@ public FileObject[] findJarFiles( final boolean includeLibJars ) throws KettleFi
try {
// Find all the jar files in this folder...
//
FileObject folderObject = KettleVFS.getFileObject( this.getFolder() );
FileObject folderObject = KettleVFS.getInstance( DefaultBowl.getInstance() ).getFileObject( this.getFolder() );

return folderObject.findFiles( new FileSelector() {
@Override
Expand Down
Loading