List of usage examples for org.apache.http.client.methods HttpPut HttpPut
public HttpPut(final String uri)
From source file:org.fcrepo.oai.integration.AbstractOAIProviderIT.java
protected static HttpPut putDSMethod(final String pid, final String ds, final String content) throws UnsupportedEncodingException { final HttpPut put = new HttpPut(serverAddress + pid + "/" + ds); put.setEntity(new StringEntity(content)); return put;//from w w w .j av a2s . c o m }
From source file:io.kyligence.benchmark.loadtest.client.RestClient.java
public void wipeCache(String entity, String event, String cacheKey) throws IOException { String url = baseUrl + "/cache/" + entity + "/" + cacheKey + "/" + event; HttpPut request = new HttpPut(url); try {// w ww . ja va 2 s . c om HttpResponse response = client.execute(request); String msg = EntityUtils.toString(response.getEntity()); if (response.getStatusLine().getStatusCode() != 200) throw new IOException("Invalid response " + response.getStatusLine().getStatusCode() + " with cache wipe url " + url + "\n" + msg); } catch (Exception ex) { throw new IOException(ex); } finally { request.releaseConnection(); } }
From source file:net.sf.jaceko.mock.it.helper.request.HttpRequestSender.java
public MockResponse sendPutRequest(String url, String requestBody, String mediaType, Map<String, String> headers, List<RestAttachment> attachments) throws IOException { HttpEntityEnclosingRequestBase httpRequest = new HttpPut(url); addRequestBody(httpRequest, requestBody, mediaType, attachments); return executeRequest(httpRequest, headers); }
From source file:co.cask.cdap.client.rest.RestStreamClient.java
@Override public void setTTL(String stream, long ttl) throws IOException { HttpPut putRequest = new HttpPut(restClient.getBaseURL() .resolve(String.format("/%s/streams/%s/config", restClient.getVersion(), stream))); StringEntity entity = new StringEntity(GSON.toJson(ImmutableMap.of(TTL_ATTRIBUTE_NAME, ttl))); entity.setContentType(MediaType.APPLICATION_JSON); putRequest.setEntity(entity);/*from w w w.j a v a 2 s .c o m*/ CloseableHttpResponse httpResponse = restClient.execute(putRequest); try { int responseCode = httpResponse.getStatusLine().getStatusCode(); LOG.debug("Set TTL Response Code : {}", responseCode); RestClient.responseCodeAnalysis(httpResponse); } finally { httpResponse.close(); } }
From source file:org.metaeffekt.dcc.agent.DccAgentEndpoint.java
private HttpPut createPutRequest(String command, String deploymentId, String packageId, String unitId, byte[] payload) { StringBuilder sb = new StringBuilder("/"); sb.append(deploymentId).append("/"); if (!"clean".equals(command)) { sb.append("packages").append("/").append(packageId).append("/"); sb.append("units").append("/").append(unitId != null ? unitId + "/" : ""); }/* w w w .j a va 2 s .co m*/ String paramsPart = sb.toString(); URIBuilder uriBuilder = getUriBuilder(); String path = String.format("/%s%s%s", PATH_ROOT, paramsPart, command); uriBuilder.setPath(path); URI uri; try { uri = uriBuilder.build(); } catch (URISyntaxException e) { throw new RuntimeException(e); } HttpPut put = new HttpPut(uri); if (payload != null && payload.length > 0) { put.setEntity(new ByteArrayEntity(payload)); } if (requestConfig != null) { put.setConfig(requestConfig); } return put; }
From source file:org.osmsurround.ae.osmrequest.OsmSignedRequestTemplate.java
private int openChangeset(String comment) throws JAXBException, HttpException, IOException { DefaultHttpClient httpClient = createHttpClient(); HttpEntityEnclosingRequestBase request = new HttpPut(osmApiBaseUrl + "/api/0.6/changeset/create"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); OsmRoot root = osmConvertService.createOsmRoot(); osmEditorService.addChangeset(root, comment); schemaService.createOsmMarshaller().marshal(osmConvertService.toJaxbElement(root), baos); request.setEntity(new ByteArrayEntity(baos.toByteArray())); oAuthService.signRequest(request);/*from ww w . ja v a 2 s. c o m*/ HttpResponse httpResponse = httpClient.execute(request); log.info("Create result: " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) { BufferedReader reader = new BufferedReader( new InputStreamReader(httpResponse.getEntity().getContent())); return Integer.parseInt(reader.readLine()); } else { throw RequestUtils.createExceptionFromHttpResponse(httpResponse); } }
From source file:com.griddynamics.jagger.invoker.http.HttpInvoker.java
private HttpRequestBase createMethod(HttpQuery query, URI uri) throws UnsupportedEncodingException { HttpRequestBase method;/* w w w . j ava2s .com*/ switch (query.getMethod()) { case POST: method = new HttpPost(uri); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> methodParam : query.getMethodParams().entrySet()) { nameValuePairs.add(new BasicNameValuePair(methodParam.getKey(), methodParam.getValue())); } ((HttpPost) method).setEntity(new UrlEncodedFormEntity(nameValuePairs)); break; case PUT: method = new HttpPut(uri); break; case GET: method = new HttpGet(uri); break; case DELETE: method = new HttpDelete(uri); break; case TRACE: method = new HttpTrace(uri); break; case HEAD: method = new HttpHead(uri); break; case OPTIONS: method = new HttpOptions(uri); break; default: throw new UnsupportedOperationException( "Invoker does not support \"" + query.getMethod() + "\" HTTP request."); } return method; }
From source file:org.fcrepo.client.utils.HttpHelperTest.java
@Test(expected = ReadOnlyException.class) public void testExecuteReadOnlyPut() throws Exception { final HttpPut put = new HttpPut(repoURL); readOnlyHelper.execute(put);/*from w w w . j av a2 s .co m*/ }
From source file:com.sap.dirigible.runtime.scripting.HttpUtils.java
public HttpPut createPut(String strURL) { return new HttpPut(strURL); }
From source file:com.kolich.http.common.HttpClient4ClosureBase.java
public T put(final URI uri) { return put(new HttpPut(uri), null); }