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

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

Introduction

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

Prototype

public void setEntity(final HttpEntity entity) 

Source Link

Usage

From source file:de.devbliss.apitester.factory.impl.DefaultPutFactory.java

public HttpPut createPutRequest(URI uri, Object payload) throws IOException {
    HttpPut request = new HttpPut(uri);

    if (payload != null) {
        request.setEntity(entityBuilder.buildEntity(payload));
    }/*from   w  w  w.  j  av  a2 s .co m*/

    return request;
}

From source file:org.apache.cloudstack.storage.datastore.util.DateraUtil.java

public static void updateInitiatorGroup(DateraObject.DateraConnection conn, String initiatorPath,
        String groupName, DateraObject.DateraOperation op)
        throws DateraObject.DateraError, UnsupportedEncodingException {

    DateraObject.InitiatorGroup initiatorGroup = getInitiatorGroup(conn, groupName);

    if (initiatorGroup == null) {
        throw new CloudRuntimeException("Unable to find initiator group by name " + groupName);
    }/* ww  w  . j  a  v  a2s. co  m*/

    HttpPut addReq = new HttpPut(generateApiUrl("initiator_groups", groupName, "members"));

    DateraObject.Initiator initiator = new DateraObject.Initiator(initiatorPath, op);

    addReq.setEntity(new StringEntity(gson.toJson(initiator)));
    executeApiRequest(conn, addReq);
}

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

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url, String body) throws IOException {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new StringEntity(body, ContentType.DEFAULT_TEXT));
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(httpPut));
}

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

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url, String body, String mimeType) throws IOException {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new StringEntity(body, ContentType.create(mimeType)));
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(httpPut));
}

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

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url, HttpParameters parameters) throws IOException {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new UrlEncodedFormEntity(parameters));
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(httpPut));
}

From source file:com.magnet.plugin.api.requests.PutRequest.java

@Override
protected HttpRequestBase getRequest(RequestModel requestModel) {
    HttpPut httpPost = new HttpPut(requestModel.getTestUrl());
    try {/* ww w. j  a v a  2 s. c o m*/
        httpPost.setEntity(new StringEntity(requestModel.getRequest(), "UTF-8"));
    } catch (Exception e) {
    }
    return httpPost;
}

From source file:org.commonjava.maven.galley.transport.htcli.internal.HttpPublish.java

@Override
public HttpPublish call() {
    //            logger.info( "Trying: {}", url );
    final HttpPut put = new HttpPut(url);
    put.setEntity(new InputStreamEntity(stream, length, ContentType.create(contentType)));

    request = put;/*from  w  w w.ja  v a2s  .  com*/

    try {
        success = executeHttp();
    } catch (final TransferException e) {
        this.error = e;
    } finally {
        cleanup();
    }

    return this;
}

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

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url, String body, String mimeType, String charsetName)
        throws IOException {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new StringEntity(body, ContentType.create(mimeType, Charset.forName(charsetName))));
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(httpPut));
}

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

@SuppressWarnings("unused")
public HttpCommandResponse execute(String url, HttpParameters parameters, String charsetName)
        throws IOException {
    HttpPut httpPut = new HttpPut(url);
    httpPut.setEntity(new UrlEncodedFormEntity(parameters, Charset.forName(charsetName)));
    return new HttpCommandResponse(shellHttpClient.getHttpClient().execute(httpPut));
}

From source file:com.strato.hidrive.api.connection.httpgateway.request.InputStreamPutRequest.java

@Override
protected HttpRequestBase createHttpRequest(String requestUri, HttpRequestParamsVisitor<?> visitor)
        throws UnsupportedEncodingException {
    HttpPut httpPut = new HttpPut(requestUri + visitor.getHttpRequestParams());
    httpPut.setEntity(new InputStreamEntity(getInputStream(), getStreamLength()));
    return httpPut;
}