@Test public void remoteFilenameFieldIsMandatoryWhenStreamingFromInputField() throws Exception { RowMeta rowMeta = rowOfStringsMeta( "sourceFilenameFieldName", "remoteDirectoryFieldName" ); step.setInputRowMeta( rowMeta ); doReturn( new Object[] { "qwerty", "asdfg" } ).when( step ).getRow(); SFTPPutMeta meta = new SFTPPutMeta(); meta.setInputStream( true ); meta.setPassword( "qwerty" ); meta.setSourceFileFieldName( "sourceFilenameFieldName" ); meta.setRemoteDirectoryFieldName( "remoteDirectoryFieldName" ); step.processRow( meta, new SFTPPutData() ); assertEquals( 1, step.getErrors() ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; }
SFTPPut extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; } }
SFTPPut extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
SFTPPut extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
SFTPPut extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (SFTPPutMeta) smi; data = (SFTPPutData) sdi; boolean sendToErrorRow = false; String errorMessage = null; Object[] r = getRow(); if ( r == null ) { setOutputDone(); return false; } if ( first ) { first = false; try { String realServerName = environmentSubstitute( meta.getServerName() ); String realServerPort = environmentSubstitute( meta.getServerPort() ); String realUsername = environmentSubstitute( meta.getUserName() ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( meta.getPassword() ) ); String realKeyFilename = null; String realPassPhrase = null; if ( meta.isUseKeyFile() ) { realKeyFilename = environmentSubstitute( meta.getKeyFilename() ); if ( Utils.isEmpty( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileMissing" ) ); return false; } if ( !KettleVFS.fileExists( realKeyFilename ) ) { logError( BaseMessages.getString( PKG, "SFTPPut.Error.KeyFileNotFound", realKeyFilename ) ); return false; } realPassPhrase = environmentSubstitute( meta.getKeyPassPhrase() ); } data.sftpclient = createSftpClient( realServerName, realServerPort, realUsername, realKeyFilename, realPassPhrase ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPUT.Log.OpenedConnection", realServerName, realServerPort, realUsername ) ); } data.sftpclient.setCompression( meta.getCompression() ); String realProxyHost = environmentSubstitute( meta.getProxyHost() ); if ( !Utils.isEmpty( realProxyHost ) ) { data.sftpclient.setProxy( realProxyHost, environmentSubstitute( meta.getProxyPort() ), environmentSubstitute( meta .getProxyUsername() ), environmentSubstitute( meta.getProxyPassword() ), meta.getProxyType() ); } data.sftpclient.login( realPassword ); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SFTPPUT.Error.Connection" ), e ); } checkSourceFileField( meta.getSourceFileFieldName(), data ); checkRemoteFoldernameField( meta.getRemoteDirectoryFieldName(), data ); checkRemoteFilenameField( meta.getRemoteFilenameFieldName(), data ); if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { checkDestinationFolderField( meta.getDestinationFolderFieldName(), data ); } } String sourceData = getInputRowMeta().getString( r, data.indexOfSourceFileFieldName ); InputStream inputStream = null; FileObject destinationFolder = null; String destinationFilename; FileObject file = null; try { if ( Utils.isEmpty( sourceData ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.SourceDataEmpty" ) ); } if ( meta.isInputStream() ) { inputStream = new ByteArrayInputStream( sourceData.getBytes() ); if ( data.indexOfRemoteFilename == -1 ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.RemoteFilenameFieldMissing" ) ); } destinationFilename = getInputRowMeta().getString( r, data.indexOfRemoteFilename ); } else { file = KettleVFS.getFileObject( sourceData ); if ( !file.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindField", sourceData ) ); } inputStream = KettleVFS.getInputStream( file ); destinationFilename = file.getName().getBaseName(); } if ( file != null ) { if ( meta.getAfterFTPS() == JobEntrySFTPPUT.AFTER_FTPSPUT_MOVE ) { String realDestationFolder = getInputRowMeta().getString( r, data.indexOfMoveToFolderFieldName ); if ( Utils.isEmpty( realDestationFolder ) ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.MoveToDestinationFolderIsEmpty" ) ); } destinationFolder = KettleVFS.getFileObject( realDestationFolder ); if ( !destinationFolder.exists() ) { throw new KettleStepException( BaseMessages.getString( PKG, "SFTPPut.Error.CanNotFindFolder", realDestationFolder ) ); } } } setSFTPDirectory( getInputRowMeta().getString( r, data.indexOfRemoteDirectory ) ); data.sftpclient.put( inputStream, destinationFilename ); if ( file != null ) { finishTheJob( file, sourceData, destinationFolder ); } putRow( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.LineNumber" ) + getLinesRead() ); } } } catch ( Exception e ) { if ( getStepMeta().isDoingErrorHandling() ) { sendToErrorRow = true; errorMessage = e.toString(); } else { logError( BaseMessages.getString( PKG, "SFTPPut.Log.ErrorInStep" ), e ); setErrors( 1 ); stopAll(); setOutputDone(); return false; } if ( sendToErrorRow ) { putError( getInputRowMeta(), r, 1, errorMessage, null, "SFTPPUT001" ); } } finally { try { if ( destinationFolder != null ) { destinationFolder.close(); } if ( file != null ) { file.close(); } if ( inputStream != null ) { inputStream.close(); } } catch ( Exception e ) { } } return true; } SFTPPut( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi );  }