protected HttpDownload getHttpDownload(final URL url, final ByteArrayOutputStream out) { return new HttpDownload(url, out); }
/** * Used for tests to override. * * @param url The URL to download from. * @param outputStream The OutputStream to write to. * @return HttpDownload instance used. * @throws IOException Any errors. */ protected HttpDownload download(final URL url, final OutputStream outputStream) throws IOException { final HttpDownload get = new HttpDownload(url, outputStream); get.run(); return get; }
private void addDownload(DownloadDescriptor dd) { if (downloadDir == null) { this.downloadDir = new File(System.getProperty("user.dir")); } HttpDownload dl = new HttpDownload(userAgent, dd.url, downloadDir); dl.setOverwrite(overwrite); dl.setDecompress(decompress); synchronized (downloads) { downloads.add(dl); } }
public void add(Iterator<DownloadDescriptor> downloads) { while (downloads.hasNext()) { DownloadDescriptor dd = downloads.next(); if (DownloadDescriptor.OK.equals(dd.status)) { File dest = downloadManager.getDestinationDir(); if (dd.destination != null) { dest = new File(dest, dd.destination); } HttpDownload dl = new HttpDownload(userAgent, dd.url, dest); this.add(dd, dl); } else { StringBuilder sb = new StringBuilder(); sb.append("failed to setup download: "); if (dd.uri != null) { sb.append(dd.uri); } if (dd.destination != null) { sb.append(" -> "); sb.append(dd.destination); } sb.append("\n\treason: "); sb.append(dd.error); log.error(sb.toString()); } } }
HttpDownload get = new HttpDownload(url, out);
public ExecutionPhase getPhase(String jobID) throws JobNotFoundException, JobPersistenceException { try { URL u = new URL(baseURL.toExternalForm() + "/" + jobID); ByteArrayOutputStream out = new ByteArrayOutputStream(); HttpDownload get = new HttpDownload(u, out); get.setUserAgent(this.getClass().getName()); get.run(); if (get.getThrowable() != null) { if (get.getThrowable().getMessage().contains("not found")) throw new JobNotFoundException("not found: " + jobID); throw new JobPersistenceException("failed to get " + jobID, get.getThrowable()); } String phase = out.toString().trim(); log.debug("phase: " + phase); ExecutionPhase ret = ExecutionPhase.toValue(phase); return ret; } catch(MalformedURLException bug) { throw new RuntimeException("BUG - failed to create valid URL", bug); } }
HttpDownload doit = new HttpDownload(getURL, bos); if (subject != null) { Subject.doAs(subject, new RunnableAction(doit));
get = new HttpDownload(url, dump); get.setHeadOnly(true); get.setFollowRedirects(true);
HttpDownload get = new HttpDownload(jobURL, out);
HttpDownload get = new HttpDownload(jobURL, out);
log.debug("datalink: " + url); ByteArrayOutputStream bos = new ByteArrayOutputStream(); HttpDownload get = new HttpDownload(url, bos); get.run(); if (get.getThrowable() != null) {
HttpDownload download = new HttpDownload(getUserURL, out); download.run();
download = new HttpDownload(url, localFile); } else { download = new HttpDownload(url, inWrapper);
HttpDownload get = new HttpDownload(url, bos); get.run(); log.debug("resolved URL: " + url + " auth: " + AuthMethod.PASSWORD); bos = new ByteArrayOutputStream(); get = new HttpDownload(url, bos); get.run(); if (get.getThrowable() == null) {
HttpDownload transfer = new HttpDownload(getGroupURL, out); transfer.setSSLSocketFactory(getSSLSocketFactory()); transfer.run();
log.info(jobName + " wait " + blockURL); ByteArrayOutputStream bos = new ByteArrayOutputStream(); HttpDownload get = new HttpDownload(blockURL, bos); if (subject != null) { Subject.doAs(subject, new RunnableAction(get));
new HttpDownload(getGroupNamesURL, new InputStreamWrapper()
HttpDownload get = new HttpDownload(getUserURL, out);
final List<User> webUsers = new ArrayList<User>(); HttpDownload httpDownload = new HttpDownload(usersURL, new JsonUserListInputStreamWrapper(webUsers)); httpDownload.setRequestProperty("Accept", "application/json");
HttpDownload get = new HttpDownload(location, bos);