private boolean getSuccessStatus() { boolean retval = false; if ( ( NrErrors == 0 && getSuccessCondition().equals( SUCCESS_IF_NO_ERRORS ) ) || ( NrfilesRetrieved >= limitFiles && getSuccessCondition().equals( SUCCESS_IF_AT_LEAST_X_FILES_DOWNLOADED ) ) || ( NrErrors <= limitFiles && getSuccessCondition().equals( SUCCESS_IF_ERRORS_LESS ) ) ) { retval = true; } return retval; }
private void updateErrors() { NrErrors++; if ( checkIfSuccessConditionBroken() ) { // Success condition was broken successConditionBroken = true; } }
wName.setText( Const.nullToEmpty( jobEntry.getName() ) ); wServerName.setText( Const.NVL( jobEntry.getServerName(), "" ) ); wPort.setText( Const.NVL( jobEntry.getPort(), "21" ) ); wUserName.setText( Const.NVL( jobEntry.getUserName(), "" ) ); wPassword.setText( Const.NVL( jobEntry.getPassword(), "" ) ); wFTPSDirectory.setText( Const.NVL( jobEntry.getFTPSDirectory(), "" ) ); wTargetDirectory.setText( Const.NVL( jobEntry.getTargetDirectory(), "" ) ); wWildcard.setText( Const.NVL( jobEntry.getWildcard(), "" ) ); wBinaryMode.setSelection( jobEntry.isBinaryMode() ); wTimeout.setText( "" + jobEntry.getTimeout() ); wRemove.setSelection( jobEntry.getRemove() ); wOnlyNew.setSelection( jobEntry.isOnlyGettingNewFiles() ); wActive.setSelection( jobEntry.isActiveConnection() ); wMove.setSelection( jobEntry.isMoveFiles() ); wMoveToDirectory.setText( Const.NVL( jobEntry.getMoveToDirectory(), "" ) ); wAddDate.setSelection( jobEntry.isDateInFilename() ); wAddTime.setSelection( jobEntry.isTimeInFilename() ); wDateTimeFormat.setText( Const.nullToEmpty( jobEntry.getDateTimeFormat() ) ); wSpecifyFormat.setSelection( jobEntry.isSpecifyFormat() ); wAddDateBeforeExtension.setSelection( jobEntry.isAddDateBeforeExtension() ); wAddFilenameToResult.setSelection( jobEntry.isAddToResult() ); wCreateMoveFolder.setSelection( jobEntry.isCreateMoveFolder() ); wProxyHost.setText( Const.NVL( jobEntry.getProxyHost(), "" ) ); wProxyPort.setText( Const.NVL( jobEntry.getProxyPort(), "" ) );
logBasic( BaseMessages.getString( PKG, "JobEntryFTPS.Started", serverName ) ); successConditionBroken = false; boolean exitjobentry = false; limitFiles = Const.toInt( environmentSubstitute( getLimit() ), 10 ); logError( BaseMessages.getString( PKG, "JobEntryFTPS.MoveToFolderEmpty" ) ); return result; localFolder = environmentSubstitute( targetDirectory ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.Start" ) ); String realServername = environmentSubstitute( serverName ); String realUsername = environmentSubstitute( userName ); String realPassword = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( password ) ); int realPort = Const.toInt( environmentSubstitute( this.port ), 0 ); connection = new FTPSConnection( getConnectionType(), realServername, realPort, realUsername, realPassword, this ); this.buildFTPSConnection( connection ); realMoveToFolder = normalizePath( environmentSubstitute( movetodirectory ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.CheckMoveToFolder", realMoveToFolder ) ); if ( createmovefolder ) {
if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.FoundNFiles", fileList.size() ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.AnalysingFile", file.getPath(), file.getName(), file.getMode(), file .getDate().toString(), file.getFileType() == 0 ? "File" : "Folder", String String localFilename = returnTargetFilename( file.getName() ); if ( ( !onlyGettingNewFiles ) || ( onlyGettingNewFiles && needsDownload( localFilename ) ) ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.GettingFile", file.getName(), targetDirectory ) ); connection.downloadFile( file, returnTargetFilename( file.getName() ) ); updateRetrievedFiles(); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.GotFile", file.getName() ) ); addFilenameToResultFilenames( result, localFilename ); if ( isDetailed() ) { if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.DeletedFile", file.getName() ) );
void buildFTPSConnection( FTPSConnection connection ) throws Exception { if ( !Utils.isEmpty( proxyHost ) ) { String realProxy_host = environmentSubstitute( proxyHost ); String realProxy_username = environmentSubstitute( proxyUsername ); String realProxy_password = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( proxyPassword ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.OpenedProxyConnectionOn", realProxy_host ) ); int proxyport = Const.toInt( environmentSubstitute( proxyPort ), 21 ); if ( proxyport != 0 ) { connection.setProxyPort( proxyport ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.OpenedConnectionTo", connection.getHostName() ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetActive" ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetPassive" ) ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetTimeout", String.valueOf( timeout ) ) ); if ( isBinaryMode() ) { connection.setBinaryMode( true ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEntryFTPS.SetBinary" ) );
if ( isAddDateBeforeExtension() ) { retval = retval.substring( 0, lastindexOfDot ); if ( isAddDateBeforeExtension() ) { retval += retval.substring( lastindexOfDot, lenstring );
/** * 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() ); }
private boolean checkIfSuccessConditionBroken() { boolean retval = false; if ( ( NrErrors > 0 && getSuccessCondition().equals( SUCCESS_IF_NO_ERRORS ) ) || ( NrErrors >= limitFiles && getSuccessCondition().equals( SUCCESS_IF_ERRORS_LESS ) ) ) { retval = true; } return retval; }