List of usage examples for org.apache.http.client.methods HttpPatch HttpPatch
public HttpPatch(final String uri)
From source file:io.kahu.hawaii.util.call.http.PatchRequest.java
public PatchRequest(RequestPrototype<HttpResponse, T> prototype, URI uri) { super(prototype, new HttpPatch(uri)); }
From source file:org.fcrepo.auth.xacml.XACMLTestUtil.java
/** * Removes the policy link from an object. * * @param client/*from w w w. ja va2s . c o m*/ * @param serverAddress * @param objectPath * @throws Exception */ public static void unlinkPolicies(final HttpClient client, final String serverAddress, final String objectPath) throws Exception { final String subjectURI = serverAddress + objectPath; final HttpPatch patch = new HttpPatch(subjectURI); // setAuth(patch, "fedoraAdmin"); patch.addHeader("Content-Type", "application/sparql-update"); final BasicHttpEntity e = new BasicHttpEntity(); e.setContent(new ByteArrayInputStream(("DELETE { <" + subjectURI + "> <http://fedora.info/definitions/v4/authorization#policy> ?o } " + "WHERE { <" + subjectURI + "> <http://fedora.info/definitions/v4/authorization#policy> ?o }").getBytes())); patch.setEntity(e); LOGGER.debug("PATCH: {}", patch.getURI()); final HttpResponse response = client.execute(patch); assertEquals(NO_CONTENT.getStatusCode(), response.getStatusLine().getStatusCode()); }
From source file:de.devbliss.apitester.factory.impl.DefaultPatchFactory.java
public HttpPatch createPatchRequest(URI uri, Object payload) throws IOException { HttpPatch request = new HttpPatch(uri); if (payload != null) { request.setEntity(entityBuilder.buildEntity(payload)); }/* w w w . j av a 2s . c o m*/ return request; }
From source file:org.fcrepo.integration.generator.DublinCoreGeneratorIT.java
@Test public void testJcrPropertiesBasedOaiDc() throws Exception { final int status = getStatus(postObjMethod("DublinCoreTest1")); assertEquals(201, status);/* w ww .j a v a2s. co m*/ final HttpPatch post = new HttpPatch(serverAddress + "DublinCoreTest1"); post.setHeader("Content-Type", "application/sparql-update"); final BasicHttpEntity entity = new BasicHttpEntity(); final String subjectURI = serverAddress + "DublinCoreTest1"; entity.setContent(new ByteArrayInputStream(("INSERT { <" + subjectURI + "> <http://purl.org/dc/elements/1.1/identifier> \"this is an identifier\" } WHERE {}") .getBytes())); post.setEntity(entity); assertEquals(204, getStatus(post)); final HttpGet getWorstCaseOaiMethod = new HttpGet(serverOAIAddress + "DublinCoreTest1/oai:dc"); getWorstCaseOaiMethod.setHeader("Accept", TEXT_XML); final HttpResponse response = client.execute(getWorstCaseOaiMethod); assertEquals(200, response.getStatusLine().getStatusCode()); final String content = EntityUtils.toString(response.getEntity()); logger.debug("Got content: {}", content); assertTrue("Didn't find oai_dc!", compile("oai_dc", DOTALL).matcher(content).find()); assertTrue("Didn't find dc:identifier!", compile("dc:identifier", DOTALL).matcher(content).find()); }
From source file:com.github.segator.scaleway.api.Utils.java
public static HttpRequestBase buildRequest(String type, String requestPath, String accessToken) { HttpRequestBase request = null;//from ww w. ja v a2s. co m switch (type) { case "POST": request = new HttpPost(requestPath); break; case "GET": request = new HttpGet(requestPath); break; case "DELETE": request = new HttpDelete(requestPath); break; case "PATCH": request = new HttpPatch(requestPath); break; } request.setHeader(ScalewayConstants.HEADER_AUTH_TOKEN, accessToken); request.setHeader(HttpHeaders.CONTENT_TYPE, ScalewayConstants.JSON_APPLICATION); return request; }
From source file:org.fcrepo.it.BasicIT.java
private static void updateProperties(final String pid, final String sparql) throws IOException { final HttpPatch patch = new HttpPatch(getURIForPid(pid)); patch.setHeader("Content-type", "application/sparql-update"); patch.setEntity(new StringEntity(sparql)); Assert.assertEquals(204, getStatusCode(patch)); }
From source file:com.redhat.refarch.microservices.warehouse.service.WarehouseService.java
public void fulfillOrder(Result result) throws Exception { HttpClient client = new DefaultHttpClient(); JSONObject jsonObject = new JSONObject(); jsonObject.put("status", "Shipped"); URIBuilder uriBuilder = new URIBuilder("http://gateway-service:9091/customers/" + result.getCustomerId() + "/orders/" + result.getOrderNumber()); HttpPatch patch = new HttpPatch(uriBuilder.build()); patch.setEntity(new StringEntity(jsonObject.toString(), ContentType.APPLICATION_JSON)); logInfo("Executing " + patch); HttpResponse response = client.execute(patch); String responseString = EntityUtils.toString(response.getEntity()); logInfo("Got response " + responseString); }
From source file:com.messagemedia.restapi.client.v1.internal.RestRequest.java
/** * Builds an apache http request/*from w ww.ja v a 2 s . c o m*/ * * @return the apache http request */ HttpUriRequest getHttpRequest() { HttpUriRequest request; switch (method) { case GET: request = new HttpGet(url); break; case DELETE: request = new HttpDelete(url); break; case HEAD: request = new HttpHead(url); break; case POST: HttpPost post = new HttpPost(url); post.setEntity(new ByteArrayEntity(body)); request = post; break; case PUT: HttpPut put = new HttpPut(url); put.setEntity(new ByteArrayEntity(body)); request = put; break; case PATCH: HttpPatch patch = new HttpPatch(url); patch.setEntity(new ByteArrayEntity(body)); request = patch; break; default: throw new RuntimeException("Method not supported"); } addHeaders(request); return request; }
From source file:com.microsoft.office365.meetingmgr.HttpHelperBase.java
public <TBody, TResult> TResult patchItem(String uri, TBody body, Class<TResult> clazz) { return doHttp(new HttpPatch(buildUri(uri)), body, clazz); }