@VisibleForTesting File download(final RemotePlugin remote) { try { final RemotePluginFile file = remote.file(); return fileCache.get(file.getFilename(), file.getHash(), new FileDownloader(remote.getKey())); } catch (Exception e) { throw new IllegalStateException("Fail to download plugin: " + remote.getKey(), e); } }
@Override public File pluginFile(final RemotePlugin remote) { try { final RemotePluginFile file = remote.file(); return fileCache.get(file.getFilename(), file.getHash(), new FileCache.Downloader() { @Override public void download(String filename, File toFile) throws IOException { String url = "/deploy/plugins/" + remote.getKey() + "/" + file.getFilename(); if (LOG.isDebugEnabled()) { LOG.debug("Download {} to {}", url, toFile.getAbsolutePath()); } else { LOG.info("Download {}", file.getFilename()); } server.download(url, toFile); } }); } catch (Exception e) { throw new IllegalStateException("Fail to download plugin: " + remote.getKey(), e); } }
public void start() { if (!analysisMode.isPreview()) { try { LOG.info("Install JDBC driver"); String[] nameAndHash = downloadJdbcDriverIndex(); if (nameAndHash.length > 0) { String filename = nameAndHash[0]; String hash = nameAndHash[1]; File jdbcDriver = fileCache.get(filename, hash, new FileCache.Downloader() { @Override public void download(String filename, File toFile) throws IOException { String url = "/deploy/" + filename; if (LOG.isDebugEnabled()) { LOG.debug("Download {} to {}", url, toFile.getAbsolutePath()); } else { LOG.info("Download {}", filename); } serverClient.download(url, toFile); } }); classLoader = initClassloader(jdbcDriver); } } catch (SonarException e) { throw e; } catch (Exception e) { throw new SonarException("Fail to install JDBC driver", e); } } }