public JobEntryFTPPUT( String n ) { super( n, "" ); serverName = null; serverPort = "21"; socksProxyPort = "1080"; remoteDirectory = null; localDirectory = null; setControlEncoding( DEFAULT_CONTROL_ENCODING ); }
public void modifyText( ModifyEvent e ) { ftpclient = null; pwdFolder = null; jobEntry.setChanged(); } };
FTPClient createFtpClient() { return new PDIFTPClient( log ); }
return; jobEntry.setName( wName.getText() ); jobEntry.setServerName( wServerName.getText() ); jobEntry.setServerPort( wServerPort.getText() ); jobEntry.setUserName( wUserName.getText() ); jobEntry.setPassword( wPassword.getText() ); jobEntry.setRemoteDirectory( wRemoteDirectory.getText() ); jobEntry.setLocalDirectory( wLocalDirectory.getText() ); jobEntry.setWildcard( wWildcard.getText() ); jobEntry.setRemove( wRemove.getSelection() ); jobEntry.setBinaryMode( wBinaryMode.getSelection() ); jobEntry.setTimeout( Const.toInt( wTimeout.getText(), 10000 ) ); jobEntry.setOnlyPuttingNewFiles( wOnlyNew.getSelection() ); jobEntry.setActiveConnection( wActive.getSelection() ); jobEntry.setControlEncoding( wControlEncoding.getText() ); jobEntry.setProxyHost( wProxyHost.getText() ); jobEntry.setProxyPort( wProxyPort.getText() ); jobEntry.setProxyUsername( wProxyUsername.getText() ); jobEntry.setProxyPassword( wProxyPassword.getText() ); jobEntry.setSocksProxyHost( wSocksProxyHost.getText() ); jobEntry.setSocksProxyPort( wSocksProxyPort.getText() ); jobEntry.setSocksProxyUsername( wSocksProxyUsername.getText() ); jobEntry.setSocksProxyPassword( wSocksProxyPassword.getText() ); dispose();
if ( jobEntry.getName() != null ) { wName.setText( jobEntry.getName() ); wServerName.setText( Const.NVL( jobEntry.getServerName(), "" ) ); wServerPort.setText( Const.NVL( jobEntry.getServerPort(), "" ) ); wUserName.setText( Const.NVL( jobEntry.getUserName(), "" ) ); wPassword.setText( Const.NVL( jobEntry.getPassword(), "" ) ); wRemoteDirectory.setText( Const.NVL( jobEntry.getRemoteDirectory(), "" ) ); wLocalDirectory.setText( Const.NVL( jobEntry.getLocalDirectory(), "" ) ); wWildcard.setText( Const.NVL( jobEntry.getWildcard(), "" ) ); wRemove.setSelection( jobEntry.getRemove() ); wBinaryMode.setSelection( jobEntry.isBinaryMode() ); wTimeout.setText( "" + jobEntry.getTimeout() ); wOnlyNew.setSelection( jobEntry.isOnlyPuttingNewFiles() ); wActive.setSelection( jobEntry.isActiveConnection() ); wControlEncoding.setText( jobEntry.getControlEncoding() ); wProxyHost.setText( Const.NVL( jobEntry.getProxyHost(), "" ) ); wProxyPort.setText( Const.NVL( jobEntry.getProxyPort(), "" ) ); wProxyUsername.setText( Const.NVL( jobEntry.getProxyUsername(), "" ) ); wProxyPassword.setText( Const.NVL( jobEntry.getProxyPassword(), "" ) ); wSocksProxyHost.setText( Const.NVL( jobEntry.getSocksProxyHost(), "" ) ); wSocksProxyPort.setText( Const.NVL( jobEntry.getSocksProxyPort(), "1080" ) ); wSocksProxyUsername.setText( Const.NVL( jobEntry.getSocksProxyUsername(), "" ) ); wSocksProxyPassword.setText( Const.NVL( jobEntry.getSocksProxyPassword(), "" ) );
@Test public void createFtpClient_UsesProxyIfSet() throws Exception { entry.setProxyHost( "localhost" ); entry.setProxyPort( "123" ); entry.createAndSetUpFtpClient(); assertEquals( "localhost", getHostFromClient() ); // we cannot distinguish values of proxy and target server, as both of them refers to localhost // that is why I put invocation counter here verify( ftpClient, times( 2 ) ).setRemoteAddr( InetAddress.getByName( "localhost" ) ); verify( ftpClient ).setRemotePort( 123 ); }
logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.Starting" ) ); ftpclient = createAndSetUpFtpClient(); String realUsername = environmentSubstitute( userName ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( password ) ); ftpclient.connect(); ftpclient.login( realUsername, realPassword ); ftpclient.setType( FTPTransferType.BINARY ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.BinaryMode" ) ); logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.Logged", realUsername ) ); this.hookInOtherParsers( ftpclient ); String realRemoteDirectory = environmentSubstitute( remoteDirectory ); if ( !Utils.isEmpty( realRemoteDirectory ) ) { ftpclient.chdir( realRemoteDirectory ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.ChangedDirectory", realRemoteDirectory ) ); String realLocalDirectory = environmentSubstitute( localDirectory ); if ( realLocalDirectory == null ) { throw new FTPException( BaseMessages.getString( PKG, "JobFTPPUT.LocalDir.NotSpecified" ) ); logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.FoundFileLocalDirectory", "" + files.size(), realLocalDirectory ) );
FTPClient createAndSetUpFtpClient() throws IOException, FTPException { String realServerName = environmentSubstitute( serverName ); String realServerPort = environmentSubstitute( serverPort ); FTPClient ftpClient = createFtpClient(); ftpClient.setRemoteAddr( InetAddress.getByName( realServerName ) ); if ( !Utils.isEmpty( realServerPort ) ) { String realProxyHost = environmentSubstitute( proxyHost ); ftpClient.setRemoteAddr( InetAddress.getByName( realProxyHost ) ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPPUT.OpenedProxyConnectionOn", realProxyHost ) ); int port = Const.toInt( environmentSubstitute( proxyPort ), FTP_DEFAULT_PORT ); if ( port != 0 ) { ftpClient.setRemotePort( port ); logDetailed( BaseMessages.getString( PKG, "JobEntryFTPPUT.OpenConnection", realServerName ) ); ftpClient.setConnectMode( FTPConnectMode.ACTIVE ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.SetActiveConnection" ) ); logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.SetPassiveConnection" ) ); ftpClient.setTimeout( timeout ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.SetTimeout", "" + timeout ) ); logDetailed( BaseMessages.getString( PKG, "JobFTPPUT.Log.SetEncoding", controlEncoding ) );
@Test public void createFtpClient_SetsLocalhostByDefault() throws Exception { entry.setServerName( null ); entry.createAndSetUpFtpClient(); assertEquals( "localhost", getHostFromClient() ); }
@Test public void createFtpClient_UsesTimeoutIfSet() throws Exception { entry.setTimeout( 10 ); entry.createAndSetUpFtpClient(); verify( ftpClient ).setTimeout( 10 ); }
@Test public void createFtpClient_DoesNotChangePortByDefault() throws Exception { entry.setServerPort( null ); entry.createAndSetUpFtpClient(); verify( ftpClient, never() ).setRemotePort( anyInt() ); }
logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Hooking.Parsers" ) ); logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Created.MVS.Parser" ) ); logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Created.Factory" ) ); logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Get.Variable.Space" ) ); VariableSpace vs = this.getVariables(); if ( vs != null ) { if ( log.isDebug() ) { logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Getting.Other.Parsers" ) ); logDebug( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Creating.Parsers" ) ); if ( parserInstance instanceof FTPFileParser ) { if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTP.DEBUG.Created.Other.Parser", cName ) ); if ( log.isDebug() ) { ignored.printStackTrace(); logError( BaseMessages.getString( PKG, "JobEntryFTP.ERROR.Creating.Parser", cName ) );
public JobEntryFTPPUTDialog( Shell parent, JobEntryInterface jobEntryInt, Repository rep, JobMeta jobMeta ) { super( parent, jobEntryInt, rep, jobMeta ); jobEntry = (JobEntryFTPPUT) jobEntryInt; if ( this.jobEntry.getName() == null ) { this.jobEntry.setName( BaseMessages.getString( PKG, "JobFTPPUT.Name.Default" ) ); } }
@Before public void setUp() throws Exception { ftpClient = mock( FTPClient.class ); entry = spy( new JobEntryFTPPUT() ); doReturn( ftpClient ).when( entry ).createFtpClient(); }
public String getXML() { StringBuilder retval = new StringBuilder( 450 ); // 365 characters in spaces and tag names alone retval.append( super.getXML() ); retval.append( " " ).append( XMLHandler.addTagValue( "servername", serverName ) ); retval.append( " " ).append( XMLHandler.addTagValue( "serverport", serverPort ) ); retval.append( " " ).append( XMLHandler.addTagValue( "username", userName ) ); retval.append( " " ).append( XMLHandler.addTagValue( "password", Encr.encryptPasswordIfNotUsingVariables( getPassword() ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "remoteDirectory", remoteDirectory ) ); retval.append( " " ).append( XMLHandler.addTagValue( "localDirectory", localDirectory ) ); retval.append( " " ).append( XMLHandler.addTagValue( "wildcard", wildcard ) ); retval.append( " " ).append( XMLHandler.addTagValue( "binary", binaryMode ) ); retval.append( " " ).append( XMLHandler.addTagValue( "timeout", timeout ) ); retval.append( " " ).append( XMLHandler.addTagValue( "remove", remove ) ); retval.append( " " ).append( XMLHandler.addTagValue( "only_new", onlyPuttingNewFiles ) ); retval.append( " " ).append( XMLHandler.addTagValue( "active", activeConnection ) ); retval.append( " " ).append( XMLHandler.addTagValue( "control_encoding", controlEncoding ) ); retval.append( " " ).append( XMLHandler.addTagValue( "proxy_host", proxyHost ) ); retval.append( " " ).append( XMLHandler.addTagValue( "proxy_port", proxyPort ) ); retval.append( " " ).append( XMLHandler.addTagValue( "proxy_username", proxyUsername ) ); retval.append( " " ).append( XMLHandler.addTagValue( "proxy_password", Encr.encryptPasswordIfNotUsingVariables( proxyPassword ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "socksproxy_host", socksProxyHost ) ); retval.append( " " ).append( XMLHandler.addTagValue( "socksproxy_port", socksProxyPort ) ); retval.append( " " ).append( XMLHandler.addTagValue( "socksproxy_username", socksProxyUsername ) ); retval.append( " " ).append( XMLHandler.addTagValue( "socksproxy_password", Encr .encryptPasswordIfNotUsingVariables( socksProxyPassword ) ) ); return retval.toString(); }
public boolean exists( String remoteFile ) throws IOException, FTPException { checkConnection( true ); FTPFile[] files = dirDetails( null ); // My fix - replace "." with null in this call for MVS support for ( int i = 0; i < files.length; i++ ) { if ( files[i].getName().equals( remoteFile ) ) {
@Override protected Map<String, String> createGettersMap() { return toMap( "servername", "getServerName", "serverport", "getServerPort", "username", "getUserName", "password", "getPassword", "remoteDirectory", "getRemoteDirectory", "localDirectory", "getLocalDirectory", "wildcard", "getWildcard", "binary", "isBinaryMode", "timeout", "getTimeout", "remove", "getRemove", "only_new", "isOnlyPuttingNewFiles", "active", "isActiveConnection", "control_encoding", "getControlEncoding", "proxy_host", "getProxyHost", "proxy_port", "getProxyPort", "proxy_username", "getProxyUsername", "proxy_password", "getProxyPassword", "socksproxy_host", "getSocksProxyHost", "socksproxy_port", "getSocksProxyPort", "socksproxy_username", "getSocksProxyUsername", "socksproxy_password", "getSocksProxyPassword" ); }
public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ) throws KettleException { try { rep.saveJobEntryAttribute( id_job, getObjectId(), "servername", serverName ); rep.saveJobEntryAttribute( id_job, getObjectId(), "serverport", serverPort ); rep.saveJobEntryAttribute( id_job, getObjectId(), "username", userName ); rep.saveJobEntryAttribute( id_job, getObjectId(), "password", Encr .encryptPasswordIfNotUsingVariables( password ) ); rep.saveJobEntryAttribute( id_job, getObjectId(), "remoteDirectory", remoteDirectory ); rep.saveJobEntryAttribute( id_job, getObjectId(), "localDirectory", localDirectory ); rep.saveJobEntryAttribute( id_job, getObjectId(), "wildcard", wildcard ); rep.saveJobEntryAttribute( id_job, getObjectId(), "binary", binaryMode ); rep.saveJobEntryAttribute( id_job, getObjectId(), "timeout", timeout ); rep.saveJobEntryAttribute( id_job, getObjectId(), "remove", remove ); rep.saveJobEntryAttribute( id_job, getObjectId(), "only_new", onlyPuttingNewFiles ); rep.saveJobEntryAttribute( id_job, getObjectId(), "active", activeConnection ); rep.saveJobEntryAttribute( id_job, getObjectId(), "control_encoding", controlEncoding ); rep.saveJobEntryAttribute( id_job, getObjectId(), "proxy_host", proxyHost ); rep.saveJobEntryAttribute( id_job, getObjectId(), "proxy_port", proxyPort ); rep.saveJobEntryAttribute( id_job, getObjectId(), "proxy_username", proxyUsername ); rep.saveJobEntryAttribute( id_job, getObjectId(), "proxy_password", Encr .encryptPasswordIfNotUsingVariables( proxyPassword ) ); rep.saveJobEntryAttribute( id_job, getObjectId(), "socksproxy_host", socksProxyHost ); rep.saveJobEntryAttribute( id_job, getObjectId(), "socksproxy_port", socksProxyPort ); rep.saveJobEntryAttribute( id_job, getObjectId(), "socksproxy_username", socksProxyUsername ); rep.saveJobEntryAttribute( id_job, getObjectId(), "socksproxy_password", Encr .encryptPasswordIfNotUsingVariables( socksProxyPassword ) );
private void cancel() { jobEntry.setChanged( changed ); jobEntry = null; dispose(); }
@Override protected Map<String, String> createSettersMap() { return toMap( "servername", "setServerName", "serverport", "setServerPort", "username", "setUserName", "password", "setPassword", "remoteDirectory", "setRemoteDirectory", "localDirectory", "setLocalDirectory", "wildcard", "setWildcard", "binary", "setBinaryMode", "timeout", "setTimeout", "remove", "setRemove", "only_new", "setOnlyPuttingNewFiles", "active", "setActiveConnection", "control_encoding", "setControlEncoding", "proxy_host", "setProxyHost", "proxy_port", "setProxyPort", "proxy_username", "setProxyUsername", "proxy_password", "setProxyPassword", "socksproxy_host", "setSocksProxyHost", "socksproxy_port", "setSocksProxyPort", "socksproxy_username", "setSocksProxyUsername", "socksproxy_password", "setSocksProxyPassword" ); } }