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

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

Introduction

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

Prototype

String METHOD_NAME

To view the source code for org.apache.http.client.methods HttpPut METHOD_NAME.

Click Source Link

Usage

From source file:eu.over9000.cathode.Dispatcher.java

public <ResponseType> Result<ResponseType> performPut(final Class<ResponseType> resultClass, final String path,
        final HttpEntity payload, final Parameter... parameters) {
    return performInternal(HttpPut.METHOD_NAME, resultClass, path, payload, parameters);
}

From source file:com.blacklocus.jres.request.index.JresIndexDocument.java

@Override
public String getHttpMethod() {
    return id == null ? HttpPost.METHOD_NAME : HttpPut.METHOD_NAME;
}

From source file:org.trancecode.xproc.step.RequestParser.java

public XProcHttpRequest parseRequest(final XdmNode requestNode, final Processor processor) {
    final String method = requestNode.getAttributeValue(XProcXmlModel.Attributes.METHOD);
    if (Strings.isNullOrEmpty(method)) {
        throw XProcExceptions.xc0006(requestNode);
    }//from   ww w.ja v a  2 s .  com
    request.setHeaders(parseHeaders(requestNode));
    request.setEntity(parseMultipart(requestNode, processor));
    if (!request.hasEntity()) {
        request.setEntity(parseBody(requestNode, processor));
    }
    if (request.hasEntity()) {
        checkCoherenceHeaders(request.getHeaders(), request.getEntity(), requestNode);
        if (!(StringUtils.equalsIgnoreCase(HttpPut.METHOD_NAME, method)
                || StringUtils.equalsIgnoreCase(HttpPost.METHOD_NAME, method))) {
            throw XProcExceptions.xc0005(requestNode);
        }
    }

    final boolean status = Boolean.valueOf(requestNode.getAttributeValue(XProcXmlModel.Attributes.STATUS_ONLY));
    final boolean detailed = Boolean.valueOf(requestNode.getAttributeValue(XProcXmlModel.Attributes.DETAILED));
    if (status && !detailed) {
        throw XProcExceptions.xc0004(requestNode);
    }
    request.setDetailled(detailed);
    request.setStatusOnly(status);

    final String href = requestNode.getAttributeValue(XProcXmlModel.Attributes.HREF);
    final URI hrefUri = requestNode.getBaseURI().resolve(href);
    if (hrefUri.getPort() != -1) {
        request.setHttpHost(new HttpHost(hrefUri.getHost(), hrefUri.getPort(), hrefUri.getScheme()));
    } else {
        request.setHttpHost(new HttpHost(hrefUri.getHost()));
    }

    final CredentialsProvider credentialsProvider = parseAuthentication(requestNode);
    request.setCredentials(credentialsProvider);
    request.setHttpRequest(constructMethod(method, hrefUri));
    request.setOverrideContentType(
            requestNode.getAttributeValue(XProcXmlModel.Attributes.OVERRIDE_CONTENT_TYPE));

    return request;
}

From source file:com.googlecode.webutilities.servlets.WebProxyServlet.java

private HttpUriRequest getRequest(String method, String url) {
    if (HttpPost.METHOD_NAME.equals(method)) {
        return new HttpPost(url);
    } else if (HttpPut.METHOD_NAME.equals(method)) {
        return new HttpPut(url);
    } else if (HttpDelete.METHOD_NAME.equals(method)) {
        return new HttpDelete(url);
    } else if (HttpOptions.METHOD_NAME.equals(method)) {
        return new HttpOptions(url);
    } else if (HttpHead.METHOD_NAME.equals(method)) {
        return new HttpHead(url);
    }//from  ww w  . j  ava 2 s  .  c  o m
    return new HttpGet(url);
}

From source file:org.elasticsearch.test.rest.client.http.HttpRequestBuilder.java

private HttpUriRequest buildRequest() {

    if (HttpGetWithEntity.METHOD_NAME.equalsIgnoreCase(method)) {
        return addOptionalBody(new HttpGetWithEntity(buildUri()));
    }/*  www .  j a v  a2  s  .  c  o m*/

    if (HttpHead.METHOD_NAME.equalsIgnoreCase(method)) {
        checkBodyNotSupported();
        return new HttpHead(buildUri());
    }

    if (HttpDeleteWithEntity.METHOD_NAME.equalsIgnoreCase(method)) {
        return addOptionalBody(new HttpDeleteWithEntity(buildUri()));
    }

    if (HttpPut.METHOD_NAME.equalsIgnoreCase(method)) {
        return addOptionalBody(new HttpPut(buildUri()));
    }

    if (HttpPost.METHOD_NAME.equalsIgnoreCase(method)) {
        return addOptionalBody(new HttpPost(buildUri()));
    }

    throw new UnsupportedOperationException("method [" + method + "] not supported");
}

From source file:com.uploader.Vimeo.java

public VimeoResponse uploadVideo(File file, String uploadLinkSecure) throws IOException {
    return apiRequest(uploadLinkSecure, HttpPut.METHOD_NAME, null, file);
}

From source file:com.linkedin.pinot.common.utils.FileUploadDownloadClient.java

private static HttpUriRequest getUpdateSchemaRequest(URI uri, String schemaName, File schemaFile) {
    return getUploadFileRequest(HttpPut.METHOD_NAME, uri, getContentBody(schemaName, schemaFile), null, null,
            DEFAULT_SOCKET_TIMEOUT_MS);
}

From source file:org.apache.zeppelin.notebook.repo.zeppelinhub.rest.HttpProxyClient.java

private HttpAsyncClientBuilder setRedirects(HttpAsyncClientBuilder clientBuilder) {
    clientBuilder.setRedirectStrategy(new DefaultRedirectStrategy() {
        /** Redirectable methods. */
        private String[] REDIRECT_METHODS = new String[] { HttpGet.METHOD_NAME, HttpPost.METHOD_NAME,
                HttpPut.METHOD_NAME, HttpDelete.METHOD_NAME, HttpHead.METHOD_NAME };

        @Override/*w  w w  . ja  va 2  s .  c  o  m*/
        protected boolean isRedirectable(String method) {
            for (String m : REDIRECT_METHODS) {
                if (m.equalsIgnoreCase(method)) {
                    return true;
                }
            }
            return false;
        }
    });
    return clientBuilder;
}

From source file:org.elasticsearch.client.SearchIT.java

@Before
public void indexDocuments() throws IOException {
    StringEntity doc1 = new StringEntity("{\"type\":\"type1\", \"num\":10, \"num2\":50}",
            ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index/type/1", Collections.emptyMap(), doc1);
    StringEntity doc2 = new StringEntity("{\"type\":\"type1\", \"num\":20, \"num2\":40}",
            ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index/type/2", Collections.emptyMap(), doc2);
    StringEntity doc3 = new StringEntity("{\"type\":\"type1\", \"num\":50, \"num2\":35}",
            ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index/type/3", Collections.emptyMap(), doc3);
    StringEntity doc4 = new StringEntity("{\"type\":\"type2\", \"num\":100, \"num2\":10}",
            ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index/type/4", Collections.emptyMap(), doc4);
    StringEntity doc5 = new StringEntity("{\"type\":\"type2\", \"num\":100, \"num2\":10}",
            ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index/type/5", Collections.emptyMap(), doc5);
    client().performRequest(HttpPost.METHOD_NAME, "/index/_refresh");

    StringEntity doc = new StringEntity("{\"field\":\"value1\", \"rating\": 7}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index1/doc/1", Collections.emptyMap(), doc);
    doc = new StringEntity("{\"field\":\"value2\"}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index1/doc/2", Collections.emptyMap(), doc);

    StringEntity mappings = new StringEntity(
            "{" + "  \"mappings\": {" + "    \"doc\": {" + "      \"properties\": {" + "        \"rating\": {"
                    + "          \"type\":  \"keyword\"" + "        }" + "      }" + "    }" + "  }" + "}}",
            ContentType.APPLICATION_JSON);
    client().performRequest("PUT", "/index2", Collections.emptyMap(), mappings);
    doc = new StringEntity("{\"field\":\"value1\", \"rating\": \"good\"}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index2/doc/3", Collections.emptyMap(), doc);
    doc = new StringEntity("{\"field\":\"value2\"}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index2/doc/4", Collections.emptyMap(), doc);

    doc = new StringEntity("{\"field\":\"value1\"}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index3/doc/5", Collections.emptyMap(), doc);
    doc = new StringEntity("{\"field\":\"value2\"}", ContentType.APPLICATION_JSON);
    client().performRequest(HttpPut.METHOD_NAME, "/index3/doc/6", Collections.emptyMap(), doc);
    client().performRequest(HttpPost.METHOD_NAME, "/index1,index2,index3/_refresh");
}

From source file:com.uploader.Vimeo.java

public VimeoResponse likeVideo(String videoId) throws IOException {
    return apiRequest(new StringBuffer("/me/likes/").append(videoId).toString(), HttpPut.METHOD_NAME, null,
            null);// w w w.  j  a  v a 2  s.  c o m
}