Example usage for org.apache.http.client.methods HttpPut HttpPut

List of usage examples for org.apache.http.client.methods HttpPut HttpPut

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpPut HttpPut.

Prototype

public HttpPut(final String uri) 

Source Link

Usage

From source file:com.ea.core.bridge.ws.rest.client.PutClient.java

@Override
protected HttpRequestBase getMethod(String url) {
    // TODO Auto-generated method stub
    return new HttpPut(url);
}

From source file:appserver.grupo5.http.java

public static Response Request(Method method, String url, String content, String contentType) {
    Response response;/*www  .  j  a  v  a  2s  .  co m*/
    try {
        HttpClient client = new DefaultHttpClient();
        HttpUriRequest request;
        switch (method) {
        case GET:
            request = new HttpGet(url);
            break;
        case POST:
            request = new HttpPost(url);
            ((HttpPost) request).setEntity(new StringEntity(content));
            break;
        case PUT:
            request = new HttpPut(url);
            ((HttpPut) request).setEntity(new StringEntity(content));
            break;
        case DELETE:
            request = new HttpDeleteWithBody(url);
            ((HttpDeleteWithBody) request).setEntity(new StringEntity(content));
            break;
        default:
            request = new HttpGet(url);
            break;
        }
        if (method != Method.GET) {
            request.setHeader("Content-type", contentType);
        }
        response = executeRequest(client, request);
    } catch (Exception e) {
        response = Response.status(400).entity(e.getMessage()).build();
    }
    return response;
}

From source file:org.talend.dataprep.api.service.command.preparation.PreparationLock.java

private PreparationLock(final String preparationId) {
    super(GenericCommand.PREPARATION_GROUP);
    execute(() -> new HttpPut(preparationServiceUrl + "/preparations/" + preparationId + "/lock"));
    on(HttpStatus.OK).then(asNull());//www  .  j  a  va2s  .c om
}

From source file:org.talend.dataprep.api.service.command.preparation.PreparationUnlock.java

private PreparationUnlock(final String preparationId) {
    super(GenericCommand.PREPARATION_GROUP);
    execute(() -> new HttpPut(preparationServiceUrl + "/preparations/" + preparationId + "/unlock"));
    on(HttpStatus.OK).then(asNull());// w w  w. j  av a2 s. co m
}

From source file:webrequester.CouchDBWebRequest.java

public String requestWithPut(String content) {
    String s = "";
    try {/*  w  w w  . j a  v a2 s.c o  m*/

        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPut httpput = new HttpPut(buildURI().toString());

        StringEntity se = new StringEntity(content);
        httpput.setEntity(se);

        CloseableHttpResponse response = httpclient.execute(httpput);
        try {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                s = EntityUtils.toString(entity, "UTF-8");
            }
        } finally {
            response.close();
        }
    } catch (IOException ex) {
        return null;
    }
    return s;
}

From source file:org.talend.dataprep.api.service.command.preparation.PreparationMoveHead.java

private PreparationMoveHead(final String preparationId, final String headId) {
    super(GenericCommand.PREPARATION_GROUP);
    execute(() -> new HttpPut(preparationServiceUrl + "/preparations/" + preparationId + "/head/" + headId));
    on(HttpStatus.OK).then(asNull());/*from   w  ww.  j ava2  s.co m*/
}

From source file:org.talend.dataprep.api.service.command.dataset.DatasetCertification.java

private DatasetCertification(String dataSetId) {
    super(GenericCommand.DATASET_GROUP);
    execute(() -> new HttpPut(datasetServiceUrl + "/datasets/" + dataSetId + "/processcertification"));
    onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_CERTIFY_DATASET, e));
    on(HttpStatus.OK).then(asNull());//w ww .j  ava 2 s. c  o m
}

From source file:com.noelportugal.amazonecho.SmartThings.java

public String setApp(String url, String body) {
    String output = "";
    try {//from w  w  w .j a  v a 2  s  .co  m

        HttpPut httpPut = new HttpPut(url);
        httpPut.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
        httpPut.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + bearer);

        StringEntity xmlEntity = new StringEntity(body);
        httpPut.setEntity(xmlEntity);

        HttpResponse httpResponse = httpclient.execute(httpPut);
        httpResponse.getEntity();
        output = new BasicResponseHandler().handleResponse(httpResponse);

        if (xmlEntity != null) {
            EntityUtils.consume(xmlEntity);
        }

    } catch (Exception e) {
        System.err.println("setApp Error: " + e.getMessage());
    }

    return output;

}

From source file:tech.beshu.ror.integration.DynamicVariablesTests.java

private static void insertDoc(String indexName, RestClient restClient) {
    if (adminClient == null) {
        adminClient = restClient;/*from w w w  .j  a v  a  2s.  c om*/
    }

    String docPath = "/" + indexName + "/documents/doc-asd";
    try {
        HttpPut request = new HttpPut(restClient.from(docPath) + "?refresh=true");
        request.setHeader("Content-Type", "application/json");
        request.setHeader("refresh", "true");
        request.setHeader("timeout", "50s");
        request.setEntity(new StringEntity("{\"title\": \"" + indexName + "\"}"));
        System.out.println(body(restClient.execute(request)));

    } catch (Exception e) {
        e.printStackTrace();
        throw new IllegalStateException("Test problem", e);
    }

}