public void uploadDirectoryWithRetries ( final String ftpServer , final String username , final String password , final String sourceDirectory , final String targetDirectory , final int maxRetryCount ) throws MojoExecutionException { int retryCount = 0 ; while ( retryCount < maxRetryCount ) { retryCount ++ ; log . info ( UPLOAD_START + ftpServer ) ; if ( uploadDirectory ( ftpServer , username , password , sourceDirectory , targetDirectory ) ) { log . info ( UPLOAD_SUCCESS + ftpServer ) ; return ; } else { log . warn ( String . format ( UPLOAD_FAILURE , retryCount , maxRetryCount ) ) ; } } // Reaching here means all retries failed. throw new MojoExecutionException ( String . format ( UPLOAD_RETRY_FAILURE , maxRetryCount ) ) ; }
Upload directory to specified FTP server with retries .