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:org.envirocar.app.dao.remote.RemoteUserDAO.java

@Override
public void updateUser(User user) throws UserUpdateException, UnauthorizedException {
    HttpPut put = new HttpPut(ECApplication.BASE_URL + "/users/" + user.getUsername());
    try {/*from www.java  2s.  c  o  m*/
        put.setEntity(new StringEntity(user.toJson()));
        super.executePayloadRequest(put);
    } catch (UnsupportedEncodingException e) {
        throw new UserUpdateException(e);
    } catch (JSONException e) {
        throw new UserUpdateException(e);
    } catch (NotConnectedException e) {
        throw new UserUpdateException(e);
    } catch (ResourceConflictException e) {
        throw new UserUpdateException(e);
    }
}

From source file:ch.cyberduck.core.dav.DAVRedirectStrategy.java

@Override
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
        throws ProtocolException {
    final String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) {
        return this.copyEntity(new HttpPut(this.getLocationURI(request, response, context)), request);
    }/*  w  w  w.j  a v a  2s .  c  o m*/
    return super.getRedirect(request, response, context);
}

From source file:io.crate.integrationtests.BlobHttpClient.java

public CloseableHttpResponse put(String table, String body) throws IOException {
    CloseableHttpClient httpClient = HttpClients.createDefault();
    String digest = Hex.encodeHexString(Blobs.digest(body));
    String url = Blobs.url(address, table + "/" + digest);
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new StringEntity(body));
    return httpClient.execute(httpPut);
}

From source file:com.hoccer.http.AsyncHttpPut.java

@Override
protected HttpEntityEnclosingRequestBase createRequest(String pUrl) {
    HttpPut request = new HttpPut(pUrl);
    return request;
}

From source file:com.meschbach.psi.util.rest.PutRequest.java

@Override
protected HttpUriRequest build(URI resource, HttpEntity entity) {
    HttpPut put = new HttpPut(resource);
    put.setEntity(entity);
    return put;
}

From source file:com.vmware.identity.rest.core.client.RequestFactory.java

public static HttpPut createPutRequest(URI uri, AccessToken token, Object entity)
        throws ClientException, JsonProcessingException {
    return prepareRequest(new HttpPut(uri), token, entity);
}

From source file:org.elasticsearch.shell.command.HttpPutCommand.java

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url) throws IOException {
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(new HttpPut(url)));
}

From source file:com.aliyun.android.oss.task.PutBucketTask.java

@Override
protected HttpUriRequest generateHttpRequest() {
    HttpPut httpPut = new HttpPut(this.getOSSEndPoint() + httpTool.generateCanonicalizedResource("/"));

    String resource = httpTool.generateCanonicalizedResource("/" + bucketName + "/");
    String dateStr = Helper.getGMTDate();
    String authorization = OSSHttpTool.generateAuthorization(accessId, accessKey, httpMethod.toString(), "", "",
            dateStr, "", resource);
    httpPut.setHeader("Authorization", authorization);
    httpPut.setHeader("Date", dateStr);

    return httpPut;
}

From source file:at.ac.tuwien.dsg.cloudlyra.utils.QualityEvaluatorREST.java

public void callQualityEvaluator(String xmlString) {

    try {//from  w  w  w  . j a  va 2 s  .  co m
        String url = "http://" + ip + ":" + port + "/RESTWSTEST/webresources/daf";

        //  String url = "http://" + ip + ":" + port + "/QualityEvaluator/webresources/QualityEvaluator";
        //HttpGet method = new HttpGet(url);
        StringEntity inputKeyspace = new StringEntity(xmlString);

        HttpPut request = new HttpPut(url);
        request.addHeader("content-type", "application/xml; charset=utf-8");
        request.addHeader("Accept", "application/xml, multipart/related");
        request.setEntity(inputKeyspace);

        HttpResponse methodResponse = this.getHttpClient().execute(request);

        int statusCode = methodResponse.getStatusLine().getStatusCode();

        System.out.println("Status Code: " + statusCode);

        BufferedReader rd = new BufferedReader(new InputStreamReader(methodResponse.getEntity().getContent()));

        StringBuilder result = new StringBuilder();
        String line;
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }

        // System.out.println("Response String: " + result.toString());
    } catch (Exception ex) {

    }

}

From source file:org.talend.dataprep.api.service.command.folder.CreateChildFolder.java

private HttpRequestBase onExecute(final String parentId, final String path) {
    try {// w  ww.  j a  va  2  s .co m

        URIBuilder uriBuilder = new URIBuilder(preparationServiceUrl + "/folders");
        uriBuilder.addParameter("parentId", parentId);
        uriBuilder.addParameter("path", path);
        return new HttpPut(uriBuilder.build());
    } catch (URISyntaxException e) {
        throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
    }
}