protected File downloadFile ( DriverDetails driverDetails , boolean shouldWeCheckFileHash ) throws MojoExecutionException , IOException , URISyntaxException { URL remoteFileLocation = driverDetails . fileLocation ; final String filename = FilenameUtils . getName ( remoteFileLocation . getFile ( ) ) ; for ( int retryAttempts = 1 ; retryAttempts <= this . fileDownloadRetryAttempts ; retryAttempts ++ ) { File downloadedFile = fileDownloader . attemptToDownload ( remoteFileLocation ) ; if ( null != downloadedFile ) { if ( ! shouldWeCheckFileHash || checkFileHash ( downloadedFile , driverDetails . hash , driverDetails . hashType ) ) { LOG . info ( "Archive file '" + downloadedFile . getName ( ) + "' is valid : true" ) ; return downloadedFile ; } else { LOG . info ( "Archive file '" + downloadedFile . getName ( ) + "' is valid : false" ) ; } } LOG . info ( "Problem downloading '" + filename + "'... " ) ; if ( retryAttempts < this . fileDownloadRetryAttempts ) { LOG . info ( "Retry attempt " + ( retryAttempts ) + " for '" + filename + "'" ) ; } } throw new MojoExecutionException ( "Unable to successfully download '" + filename + "'!" ) ; }
Perform the file download