private File downloadArtifact ( ElasticsearchArtifact artifactReference , ClusterConfiguration config ) throws IOException { String filename = Joiner . on ( "-" ) . skipNulls ( ) . join ( artifactReference . getArtifactId ( ) , artifactReference . getVersion ( ) , artifactReference . getClassifier ( ) // May be null ) + "." + artifactReference . getType ( ) ; File tempFile = new File ( FilesystemUtil . getTempDirectory ( ) , filename ) ; tempFile . deleteOnExit ( ) ; FileUtils . deleteQuietly ( tempFile ) ; URL downloadUrl = new URL ( StringUtils . isBlank ( config . getDownloadUrl ( ) ) ? String . format ( ELASTICSEARCH_DOWNLOAD_URL , filename ) : config . getDownloadUrl ( ) ) ; config . getLog ( ) . debug ( "Downloading " + downloadUrl + " to " + tempFile ) ; FileUtils . copyURLToFile ( downloadUrl , tempFile ) ; return tempFile ; }
Download the artifact from the download repository .