protected final URL createAsyncParamJob(String jobName, Map<String, Object> params) { URL jobListURL = getJobListURL(); HttpPost post = new HttpPost(jobListURL, params, false); if (subject != null) { Subject.doAs(subject, new RunnableAction(post)); } else { post.run(); } if (post.getThrowable() != null) { Assert.fail("failed to create job: " + jobName + " reason: " + post.getThrowable()); } URL ret = post.getRedirectURL(); Assert.assertNotNull("redirectURL", ret); log.info(jobName + " created " + ret); return ret; }
parameters.put("PHASE", "RUN"); HttpPost transfer = new HttpPost(phaseURL, parameters, false); if (transListener != null) { transfer.setTransferListener(transListener); transfer.run(); Throwable error = transfer.getThrowable(); if (error != null) if ((transfer.getResponseCode() == -1) || (transfer.getResponseCode() == 401) || (transfer.getResponseCode() == 403)) if (transfer.getResponseCode() == 400) if (transfer.getResponseCode() == 404) throw new RuntimeException("unexpected failure mode: " + error.getMessage() + "(" + transfer.getResponseCode() + ")");
private void handleResponse(HttpURLConnection conn) throws IOException, InterruptedException, TransientException { //int statusCode = checkStatusCode(conn); this.responseCode = conn.getResponseCode(); this.responseContentType = conn.getContentType(); this.responseContentEncoding = conn.getContentEncoding(); log.debug("handleResponse: " + responseCode + "|" + responseContentType); // check for a redirect String location = conn.getHeaderField("Location"); if ((responseCode == HttpURLConnection.HTTP_SEE_OTHER || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) && location != null) { this.redirectURL = new URL(location); log.debug("redirectURL: " + redirectURL); return; } // map some response codes to exceptions checkStatusCode(conn); // read response fully InputStream istream = conn.getInputStream(); readResponse(istream); }
/** * Submit login data to the service. * @param payload The payload information. * @param out The response stream. * @return Response status code. */ int post(final Map<String, Object> payload, final OutputStream out) { final HttpPost post = new HttpPost(lookupLoginURL(), payload, out); post.run(); return post.getResponseCode(); }
/** * POST PHASE=ABORTED to the Job's phase endpoint. */ @Override public void run() { URL url; try { url = new URL(jobURL.toExternalForm() + "/phase"); } catch (MalformedURLException e) { System.out.println("Unable to create URL to Job " + jobURL.toExternalForm() + " because " + e.getMessage()); return; } HttpPost post = new HttpPost(url, parameters, true); post.run(); if (post.getThrowable()!= null) { System.out.println("Failed to abort Job " + jobURL.toExternalForm() + " because " + post.getThrowable().getMessage()); return; } System.out.println("Successfully aborted Job " + jobURL.toExternalForm()); }
/** * Create and execute a synchronous job specified by parameters. * * @param jobName name to be logged * @param params parameters for this job * @return */ protected final JobResultWrapper createAndExecuteSyncParamJobPOST(String jobName, Map<String, Object> params) { URL jobListURL = getJobListURL(); JobResultWrapper ret = new JobResultWrapper(jobName); try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); log.info(jobName); HttpPost doit = new HttpPost(jobListURL, params, bos); if (subject != null) { Subject.doAs(subject, new RunnableAction(doit)); } else { doit.run(); } ret.job = null; // no formal way to get jobID ret.throwable = doit.getThrowable(); ret.responseCode = doit.getResponseCode(); ret.contentType = doit.getResponseContentType(); ret.contentEncoding = doit.getResponseContentEncoding(); ret.syncOutput = bos.toByteArray(); } finally { } return ret; }
HttpPost httpPost = new HttpPost(url, nodeContent, false); httpPost.run(); VOSClientUtil.checkFailure(httpPost.getThrowable()); String responseBody = httpPost.getResponseBody(); NodeReader nodeReader = new NodeReader(); rtnNode = nodeReader.read(responseBody);
boolean followRedirects = false; HttpPost post = new HttpPost(url, content, contentType, followRedirects); if (post.getThrowable() != null) throw new RuntimeException("Unable to run job because " + post.getThrowable().getLocalizedMessage());
URL phaseURL = new URL(jobURL.toExternalForm() + "/phase"); log.info(jobName + " execute " + phaseURL); HttpPost post = new HttpPost(phaseURL, params, false); if (subject != null) { Subject.doAs(subject, new RunnableAction(post)); } else { post.run(); if (post.getThrowable() != null) { Assert.fail("failed to set PHASE=RUN for " + jobURL + " reason: " + post.getThrowable());
HttpPost httpPost = new HttpPost(vospaceURL, transferContent, false); httpPost.run(); if (httpPost.getThrowable() != null) log.debug("Unable to post transfer because ", httpPost.getThrowable()); throw new RuntimeException("Unable to post transfer because " + httpPost.getThrowable().getMessage()); URL jobUrl = httpPost.getRedirectURL(); log.debug("Job URL is: " + jobUrl.toString());
log.debug("updateGroup: " + groupXML); HttpPost transfer = new HttpPost(updateGroupURL, groupXML.toString(), "application/xml", false); transfer.setSSLSocketFactory(getSSLSocketFactory()); transfer.setTransferListener(this); transfer.run(); Throwable error = transfer.getThrowable(); if (error != null) if ((transfer.getResponseCode() == -1) || (transfer.getResponseCode() == 401) || (transfer.getResponseCode() == 403)) if (transfer.getResponseCode() == 400) if (transfer.getResponseCode() == 404)
HttpPost httpPost = new HttpPost(vospaceURL, nodeContent, false); httpPost.run(); VOSClientUtil.checkFailure(httpPost.getThrowable()); URL jobUrl = httpPost.getRedirectURL(); log.debug("Job URL is: " + jobUrl.toString());
form.put("DIRECTION", transfer.getDirection().getValue()); form.put("PROTOCOL", transfer.getProtocols().iterator().next().getUri()); // try first protocol? httpPost = new HttpPost(vospaceURL, form, false); httpPost = new HttpPost(vospaceURL, transferContent, false); httpPost.run(); if (httpPost.getThrowable() != null) log.debug("Unable to post transfer because ", httpPost.getThrowable()); throw new RuntimeException("Unable to post transfer because " + httpPost.getThrowable().getMessage()); URL redirectURL = httpPost.getRedirectURL();