private void closeFTPSConnection() { // Close FTPS connection if necessary if ( connection != null ) { try { connection.disconnect(); } catch ( Exception e ) { // Ignore errors } } }
/** * * this method is used to return filenames in working directory * * @return filenames * @throws KettleException */ public String[] getFileNames() throws KettleException { ArrayList<String> list = null; try { List<FTPFile> fileList = getFileList( getWorkingDirectory() ); list = new ArrayList<String>(); Iterator<FTPFile> it = fileList.iterator(); while ( it.hasNext() ) { FTPFile file = it.next(); if ( !file.isDirectory() ) { list.add( file.getName() ); } } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "JobFTPS.Error.RetrievingFilenames" ), e ); } return list == null ? null : list.toArray( new String[list.size()] ); }
new FTPSConnection( FTPSConnection.getConnectionTypeByDesc( wConnectionType.getText() ), realServername, port, realUsername, realPassword ); String realProxy_user = jobMeta.environmentSubstitute( wProxyUsername.getText() ); String realProxy_pass = Utils.resolvePassword( jobMeta, wProxyPassword.getText() ); ftpsclient.setProxyHost( realProxy_host ); int proxyport = Const.toInt( jobMeta.environmentSubstitute( wProxyPort.getText() ), 990 ); if ( proxyport != 0 ) { ftpsclient.setProxyPort( proxyport ); ftpsclient.setProxyUser( realProxy_user ); ftpsclient.setProxyPassword( realProxy_pass ); ftpsclient.connect(); pwdFolder = ftpsclient.getWorkingDirectory(); if ( ftpsclient != null ) { try { ftpsclient.disconnect(); } catch ( Exception ignored ) {
connection.setProxyHost( realProxy_host ); if ( !Utils.isEmpty( realProxy_username ) ) { connection.setProxyUser( realProxy_username ); connection.setProxyPassword( realProxy_password ); connection.setProxyPort( proxyport ); logDetailed( BaseMessages.getString( PKG, "JobEntryFTPSPUT.OpenedConnectionTo", connection.getHostName() ) ); connection.setPassiveMode( false ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.Log.SetActiveConnection" ) ); connection.setPassiveMode( true ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.Log.SetPassiveConnection" ) ); connection.setTimeOut( timeout ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.Log.SetTimeout", timeout ) ); connection.connect(); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.Log.Logged", connection.getUserName() ) ); logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.WorkingDirectory", connection.getWorkingDirectory() ) ); connection.setBinaryMode( true );
new FTPSConnection( getFTPSConnectionType(), realservername, realport, realusername, realpassword ); ftpsclient.setProxyHost( realProxy_host ); if ( !Utils.isEmpty( realProxy_username ) ) { ftpsclient.setProxyUser( realProxy_username ); ftpsclient.setProxyPassword( realProxy_password ); ftpsclient.setProxyPort( proxyport ); ftpsclient.setPassiveMode( false ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPDelete.SetActive" ) ); ftpsclient.setPassiveMode( true ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPDelete.SetPassive" ) ); ftpsclient.setTimeOut( realtimeout ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPDelete.SetTimeout", String.valueOf( realtimeout ) ) ); ftpsclient.connect(); ftpsclient.changeDirectory( realFTPDirectory ); if ( isDetailed() ) { logDetailed( "Changed to directory [" + realFTPDirectory + "]" );
int realPort = Const.toInt( environmentSubstitute( this.port ), 0 ); connection = new FTPSConnection( getConnectionType(), realServername, realPort, realUsername, realPassword, this ); realMoveToFolder = normalizePath( environmentSubstitute( movetodirectory ) ); boolean folderExist = connection.isDirectoryExists( realMoveToFolder ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.CheckMoveToFolder", realMoveToFolder ) ); connection.createDirectory( realMoveToFolder ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.MoveToFolderCreated", realMoveToFolder ) ); downloadFiles( connection, connection.getWorkingDirectory(), pattern, result ); if ( connection != null ) { try { connection.disconnect(); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobEntryFTPS.ErrorQuitting", e.getMessage() ) );
connection = new FTPSConnection( getConnectionType(), realServerName, realPort, realUsername, realPassword ); connection.changeDirectory( realRemoteDirectory ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPSPUT.Log.ChangedDirectory", realRemoteDirectory ) ); boolean fileExist = connection.isFileExists( filelist[i] ); connection.uploadFile( localFilename, filelist[i] ); if ( connection != null ) { try { connection.disconnect(); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobFTPSPUT.Log.ErrorQuitingFTP", e.getMessage() ) );
/** * PDI-6868, attempt to set binary mode is after the connection.connect() succeeded. * @throws Exception */ @Test public void testBinaryModeSetAfterConnectionSuccess() throws Exception { JobEntryFTPSGet job = new JobEntryFTPSGetCustom(); FTPSConnection connection = Mockito.mock( FTPSConnection.class ); InOrder inOrder = Mockito.inOrder( connection ); job.buildFTPSConnection( connection ); inOrder.verify( connection ).connect(); inOrder.verify( connection ).setBinaryMode( Mockito.anyBoolean() ); }
filelist = ftpsclient.getFileNames(); } else if ( protocol.equals( PROTOCOL_SFTP ) ) { ftpsclient.deleteFile( filelist[i] ); } else if ( protocol.equals( PROTOCOL_SFTP ) ) { sftpclient.delete( filelist[i] ); ftpsclient.disconnect(); } catch ( Exception e ) { logError( BaseMessages.getString( PKG, "JobEntryFTPDelete.ErrorQuitting", e.getMessage() ) );
/** * * this method is used to delete a file in remote host * * @param filename * Name of file on remote host to delete * @throws KettleException */ public void deleteFile( String filename ) throws KettleException { try { this.connection.deleteFile( new FTPFile( getWorkingDirectory(), filename ) ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "JobFTPS.Error.DeletingFile", filename ), e ); } }
ftpsclient.changeDirectory( pwdFolder ); ftpsclient.changeDirectory( realfoldername ); folderexists = true; } else if ( wProtocol.getText().equals( JobEntryFTPDelete.PROTOCOL_SFTP ) ) {
new FTPSConnection( FTPSConnection.getConnectionTypeByDesc( wConnectionType.getText() ), realServername, realPort, realUsername, realPassword ); String realProxy_pass = Utils.resolvePassword( jobMeta, wProxyPassword.getText() ); connection.setProxyHost( realProxy_host ); int proxyport = Const.toInt( jobMeta.environmentSubstitute( wProxyPort.getText() ), 990 ); if ( proxyport != 0 ) { connection.setProxyPort( proxyport ); connection.setProxyUser( realProxy_user ); connection.setProxyPassword( realProxy_pass ); connection.connect(); return connection.isDirectoryExists( realFtpDirectory ); if ( connection != null ) { try { connection.disconnect(); } catch ( Exception ignored ) {
connection.setProxyHost( realProxy_host ); if ( !Utils.isEmpty( realProxy_username ) ) { connection.setProxyUser( realProxy_username ); connection.setProxyPassword( realProxy_password ); connection.setProxyPort( proxyport ); logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.OpenedConnectionTo", connection.getHostName() ) ); connection.setPassiveMode( false ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetActive" ) ); connection.setPassiveMode( true ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetPassive" ) ); connection.setTimeOut( timeout ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetTimeout", String.valueOf( timeout ) ) ); connection.connect(); connection.setBinaryMode( true ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetBinary" ) ); logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.LoggedIn", connection.getUserName() ) );
/** * PDI-6868, attempt to set binary mode is after the connection.connect() succeeded. * @throws Exception */ @Test public void testBinaryModeSetAfterConnectionSuccess() throws Exception { JobEntryFTPSPUT job = new JobEntryFTPSPUTCustom(); FTPSConnection connection = Mockito.mock( FTPSConnection.class ); InOrder inOrder = Mockito.inOrder( connection ); job.buildFTPSConnection( connection ); inOrder.verify( connection ).connect(); inOrder.verify( connection ).setBinaryMode( Mockito.anyBoolean() ); }
new FTPSConnection( FTPSConnection.getConnectionTypeByDesc( wConnectionType.getText() ), realServername, port, realUsername, realPassword ); String realProxy_user = jobMeta.environmentSubstitute( wProxyUsername.getText() ); String realProxy_pass = Utils.resolvePassword( jobMeta, wProxyPassword.getText() ); connection.setProxyHost( realProxy_host ); int proxyport = Const.toInt( jobMeta.environmentSubstitute( wProxyPort.getText() ), 990 ); if ( proxyport != 0 ) { connection.setProxyPort( proxyport ); connection.setProxyUser( realProxy_user ); connection.setProxyPassword( realProxy_pass ); connection.connect(); retval = connection.isDirectoryExists( realFTPSDirectory ); retval = connection.isDirectoryExists( realMoveDirectory ); if ( connection != null ) { try { connection.disconnect(); } catch ( Exception ignored ) {
private void closeFTPSConnection() { // Close FTP connection if necessary if ( connection != null ) { try { connection.disconnect(); } catch ( Exception e ) { // Ignore errors } } }