HttpDownload get = new HttpDownload(location, bos); get.run(); if ( get.getThrowable() != null) if (get.getThrowable() instanceof IOException) throw (IOException) get.getThrowable(); if (get.getThrowable() instanceof AccessControlException) throw (AccessControlException) get.getThrowable(); if (get.getThrowable() instanceof FileNotFoundException) throw new ResourceNotFoundException(get.getThrowable().getMessage(), get.getThrowable()); throw new RuntimeException("unexpected failure download certificate", get.getThrowable());
new HttpDownload(getGroupNamesURL, new InputStreamWrapper() httpDownload.setRetry(0, 0, HttpTransfer.RetryReason.NONE); httpDownload.setSSLSocketFactory(getSSLSocketFactory()); httpDownload.run(); final Throwable error = httpDownload.getThrowable(); final int responseCode = httpDownload.getResponseCode(); log.debug("Content-Length: " + httpDownload.getContentLength()); log.debug("Content-Type: " + httpDownload.getContentType());
download = new HttpDownload(url, localFile); } else { download = new HttpDownload(url, inWrapper); download.setOverwrite(true); download.setRequestProperties(httpRequestProperties); download.setMaxRetries(maxRetries); if (transListener != null) download.setTransferListener(transListener); if (download.getThrowable() == null) this.localFile = download.getFile(); return; throw new IOException("failed to download file", firstDownload.getThrowable());
/** * 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); } }
HttpDownload transfer = new HttpDownload(getGroupURL, out); transfer.setSSLSocketFactory(getSSLSocketFactory()); transfer.run(); Throwable error = transfer.getThrowable(); if (error != null) log.debug("getGroup throwable (" + transfer.getResponseCode() + ")", error); if ((transfer.getResponseCode() == -1) || (transfer.getResponseCode() == 401) || (transfer.getResponseCode() == 403)) if (transfer.getResponseCode() == 400) if (transfer.getResponseCode() == 404)
final List<User> webUsers = new ArrayList<User>(); HttpDownload httpDownload = new HttpDownload(usersURL, new JsonUserListInputStreamWrapper(webUsers)); httpDownload.setRequestProperty("Accept", "application/json"); httpDownload.run(); final Throwable error = httpDownload.getThrowable(); final int responseCode = httpDownload.getResponseCode(); log.debug("getDisplayUsers response " + responseCode + ": " + errMessage); log.debug("Content-Length: " + httpDownload.getContentLength()); log.debug("Content-Type: " + httpDownload.getContentType());
get = new HttpDownload(url, dump); get.setHeadOnly(true); get.setFollowRedirects(true); get.run(); if (get.getThrowable() != null) log.debug("FAIL", get.getThrowable()); throw new CheckException(name + " " + url.toExternalForm() + " test failed: " + get.getThrowable()); int responseCode = get.getResponseCode(); String contentType = get.getContentType(); int i = contentType.indexOf(';'); if (i > 0)
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 get = new HttpDownload(jobURL, out); if (get.getThrowable() != null) throw new RuntimeException("Unable to get job because " + get.getThrowable().getLocalizedMessage());
final HttpDownload get = download(whoAmIURL, out); final int responseCode = get.getResponseCode(); if (responseCode == 200) if (get.getThrowable() != null) log.debug("error calling get user", get.getThrowable()); message = get.getThrowable().getMessage();
httpDownload.run(); if (httpDownload.getResponseCode() == 200)
mr = Integer.MAX_VALUE; currentTask.setMaxRetries(mr); currentTask.run(); } else { log.debug(workerBasename + "no longer part of pool");
protected HttpDownload getHttpDownload(final URL url, final ByteArrayOutputStream out) { return new HttpDownload(url, out); }
sb.append(te.getFile().getAbsolutePath()); textPane.setText(sb.toString()); totalSize = dl.getContentLength(); } else { textPane.setText("decompressing -> " + te.getFile().getAbsolutePath()); totalSize = dl.getSize(); totalStr = " of " + sizeToString(dl.getSize(), 0); progress.setIndeterminate(false); progress.setMinimum(0); textPane.setText(dl.getURL() + "\nfailed: " + te.getError().getMessage()); textPane.setForeground(FAILED_COLOR); validate(); textPane.setText(dl.getURL() + "\ncancelled"); textPane.setForeground(CANCELLED_COLOR); sb.append(dl.getURL().toString()); sb.append(" -> "); sb.append(te.getFile().getAbsolutePath());
HttpDownload doit = new HttpDownload(getURL, bos); if (subject != null) { Subject.doAs(subject, new RunnableAction(doit)); } else { doit.run(); ret.throwable = doit.getThrowable(); ret.responseCode = doit.getResponseCode(); ret.contentType = doit.getContentType(); ret.contentEncoding = doit.getContentEncoding(); ret.syncOutput = bos.toByteArray(); } catch (MalformedURLException ex) {
HttpDownload get = new HttpDownload(jobURL, out); if (get.getThrowable() != null) throw new RuntimeException("Unable to get Job because " + get.getThrowable().getLocalizedMessage());
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, bos); get.run(); Throwable t1 = get.getThrowable(); // report this fail if password fails if (get.getThrowable() != null) { if (get.getResponseCode() == 401 // no cookie or cookie invalid || get.getResponseCode() == 403) { // no cookie and private node log.debug("resolved URL: " + url + " auth: " + AuthMethod.PASSWORD); bos = new ByteArrayOutputStream(); get = new HttpDownload(url, bos); get.run(); if (get.getThrowable() == null) { if (ManifestReader.CONTENT_TYPE.equals(get.getContentType())) { // view=manifest String responseContent = bos.toString("UTF-8"); log.debug("response from " + url + "\n" + responseContent); + " with view=manifest [" + get.getResponseCode() + ", " + get.getContentType() + "]"); } catch (MalformedURLException bug) { log.error("failed to read DataLink result table", bug);
HttpDownload get = new HttpDownload(url, out); get.run(); VOSClientUtil.checkFailure(get.getThrowable());