Examples of HttpPut


Examples of org.apache.http.client.methods.HttpPut

    case POST:
      request = new HttpPost(uri);
      break;

    case PUT:
      request = new HttpPut(uri);
      break;

    case DELETE:
      request = new HttpDelete(uri);
      break;
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

    @Override
    public void submit(JobId id) throws IOException, InterruptedException {
        if (id == null) {
            throw new IllegalArgumentException("id must not be null"); //$NON-NLS-1$
        }
        HttpPut request = new HttpPut();
        URI uri = createUri(String.format("jobs/%s/execute", id.getToken()));
        request.setURI(uri);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Submitting job: method=put, uri={}", uri);
        }
        HttpResponse response = http.execute(request);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            JobStatus status = extractJobStatus(request, response);
            if (status.getKind() == JobStatus.Kind.ERROR) {
                throw toException(request, response, status, MessageFormat.format(
                        "Failed to submit job: {0} ({1})",
                        id.getToken(),
                        request.getURI()));
            }
        } else {
            throw toException(request, response, MessageFormat.format(
                    "Failed to submit job: {0} ({1})",
                    id.getToken(),
                    request.getURI()));
        }
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

    @Test
    public void querylessUrlAndMethodWithName() {
        assertThat(QUERYLESS_URL_AND_METHOD.getNameFor(
                "some-service",
                new HttpPut("https://thing.com:8090/my/path?ignore=this&and=this")),
                is("org.apache.http.client.HttpClient.some-service.https://thing.com:8090/my/path.put-requests"));
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

            break;
          case DELETE:
            meth = new HttpDelete(url);
            break;
          case PUT:
            meth = new HttpPut(url);
            break;
          default:
            meth = new HttpEntityEnclosingRequestBase() {
              @Override
              public String getMethod() {
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

                case POST:
                    httpMethod = new HttpPost(url);
                    ((HttpPost) httpMethod).setEntity(new StringEntity(this.requestBody));
                    break;
                case PUT:
                    httpMethod = new HttpPut(url);
                    ((HttpPut) httpMethod).setEntity(new StringEntity(this.requestBody));
                    break;
                default:
                    throw new IllegalStateException("Can't execute this method : " + method);
            }
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

    {
      throw new ManifoldCFException(e.getMessage(),e);
    }

    StringBuffer url = getApiUrl(config.getIndexType() + "/" + idField, false);
    HttpPut put = new HttpPut(url.toString());
    put.setEntity(new IndexRequestEntity(document, inputStream));
    if (call(put) == false)
      return false;
    if ("true".equals(checkJson(jsonStatus)))
      return true;
    String error = checkJson(jsonException);
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

       
    }
   
    @Test
    public void testPutConsumer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + CXT + "/rest/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.addHeader("test", "header1;header2");
        put.setEntity(entity);
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(put);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

  */
  public String performAPIPutOperation(String apiURL, int expectedResponse, String input)
    throws Exception
  {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpPut method = new HttpPut(apiURL);
    try
    {
      method.setEntity(new StringEntity(input,ContentType.create("text/plain","UTF-8")));
      HttpResponse response = client.execute(method);
      int responseCode = response.getStatusLine().getStatusCode();
      String responseString = convertToString(response);
      if (responseCode != expectedResponse)
        throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
      // We presume that the data is utf-8, since that's what the API uses throughout.
      return responseString;
    }
    finally
    {
      method.abort();
    }
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

        super(URI.create(requestURI), content, null, null);
    }

    @Override
    protected HttpEntityEnclosingRequest createRequest(final URI requestURI, final HttpEntity entity) {
        HttpPut httpput = new HttpPut(requestURI);
        httpput.setEntity(entity);
        return httpput;
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpPut

    public static HttpAsyncRequestProducer createPut(
            final URI requestURI,
            final String content,
            final ContentType contentType) throws UnsupportedEncodingException {
        HttpPut httpput = new HttpPut(requestURI);
        NStringEntity entity = new NStringEntity(content, contentType);
        httpput.setEntity(entity);
        HttpHost target = URIUtils.extractHost(requestURI);
        return new RequestProducerImpl(target, httpput, entity);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.