List of usage examples for org.apache.http.client.fluent Request Delete
public static Request Delete(final String uri)
From source file:org.jboss.arquillian.container.was.wlp_remote_8_5.WLPRestClient.java
/** * Deletes the specified application from the servers dropins directory. WLP * will detect this and then undeploy it. * /*from w ww . j a v a 2 s. com*/ * @param String * - applicationName * @throws ClientProtocolException * @throws IOException */ public void undeploy(String applicationName) throws ClientProtocolException, IOException { if (log.isLoggable(Level.FINER)) { log.entering(className, "undeploy"); } String deployPath = String.format("${wlp.user.dir}/servers/%s/dropins/%s", configuration.getServerName(), applicationName); String serverRestEndpoint = String.format("https://%s:%d%s%s", configuration.getHostName(), configuration.getHttpsPort(), FILE_ENDPOINT, URLEncoder.encode(deployPath, UTF_8)); HttpResponse result = executor .execute(Request.Delete(serverRestEndpoint).useExpectContinue().version(HttpVersion.HTTP_1_1)) .returnResponse(); if (isSuccessful(result)) { log.fine("File " + applicationName + " was deleted"); } else { throw new ClientProtocolException("Unable to undeploy application " + applicationName + ", server returned response: " + result.getStatusLine()); } if (log.isLoggable(Level.FINER)) { log.exiting(className, "undeploy", result); } }
From source file:de.elomagic.carafile.client.CaraFileClient.java
/** * Deletes a file at the registry./* www . j ava 2 s . c om*/ * * @param fileId File identifier * @param beQuite If true then no FileNotFoundException will be thrown when file already doesn't exists * @throws IOException Thrown when unable to call REST services */ public void deleteFile(final String fileId, final boolean beQuite) throws IOException { if (registryURI == null) { throw new IllegalArgumentException("Parameter 'registryURI' must not be null!"); } if (fileId == null) { throw new IllegalArgumentException("Parameter 'fileId' must not be null!"); } URI uri = CaraFileUtils.buildURI(registryURI, "registry", "deleteFile", fileId); HttpResponse response = executeRequest(Request.Delete(uri)).returnResponse(); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK || (statusCode == HttpStatus.SC_NOT_FOUND && beQuite)) { } else if (statusCode == HttpStatus.SC_NOT_FOUND) { throw new FileNotFoundException("File Id " + fileId + " not found."); } else { throw new IOException(statusCode + " " + response.getStatusLine().getReasonPhrase()); } }
From source file:org.jclarity.GitReleaseRollback.java
protected void deleteDeployment() { String version = releaseProperties .getProperty("project.rel." + project.getGroupId() + ":" + project.getArtifactId()); ArtifactRepository releaseArtifactRepository = getReleaseRepo(); if (releaseArtifactRepository == null) { getLog().warn("Failed to find the release repo, any released artifacts will not be deleted"); return;//from w w w . java2 s .c o m } String username = releaseArtifactRepository.getAuthentication().getUsername(); String password = releaseArtifactRepository.getAuthentication().getPassword(); String url = releaseArtifactRepository.getUrl() + "/" + project.getGroupId() + "/" + project.getArtifactId() + "/" + version; try { int resposeCode = Executor.newInstance().auth(username, password).execute(Request.Delete(url)) .returnResponse().getStatusLine().getStatusCode(); if (resposeCode != HttpStatus.SC_NO_CONTENT) { getLog().warn("Could not delete artifact, it may not have been deployed"); } } catch (Exception e) { getLog().warn("Failed to delete artifact"); } }
From source file:com.qwazr.database.TableSingleClient.java
@Override public Boolean deleteRow(String table_name, String row_id) { UBuilder uriBuilder = new UBuilder("/table/", table_name, "/row/", row_id); Request request = Request.Delete(uriBuilder.build()); return commonServiceRequest(request, null, null, Boolean.class, 200); }
From source file:photosharing.api.conx.CommentsDefinition.java
/** * deletes a comment with the given comments api url uses the HTTP method * delete/*w ww. j a v a 2 s .c o m*/ * * Method: DELETE URL: * http://localhost:9080/photoSharing/api/comments?uid=20514318 * &pid=bf33a9b5- * 3042-46f0-a96e-b8742fced7a4&cid=4ec9c9c2-6e21-4815-bd42-91d502d2d427 * * @param bearer * token * @param cid * comment id * @param pid * document id * @param uid * user id * @param response * @param nonce */ public void deleteComment(String bearer, String cid, String pid, String uid, HttpServletResponse response, String nonce) { String apiUrl = getApiUrl() + "/userlibrary/" + uid + "/document/" + pid + "/comment/" + cid + "/entry"; Request delete = Request.Delete(apiUrl); delete.addHeader("Authorization", "Bearer " + bearer); delete.addHeader("X-Update-Nonce", nonce); try { Executor exec = ExecutorUtil.getExecutor(); Response apiResponse = exec.execute(delete); HttpResponse hr = apiResponse.returnResponse(); /** * Check the status codes */ int code = hr.getStatusLine().getStatusCode(); // Checks the Status Code if (code == HttpStatus.SC_FORBIDDEN) { // Session is no longer valid or access token is expired response.setStatus(HttpStatus.SC_FORBIDDEN); } else if (code == HttpStatus.SC_UNAUTHORIZED) { // User is not authorized response.setStatus(HttpStatus.SC_UNAUTHORIZED); } else { // Default to SC_NO_CONTENT(204) response.setStatus(HttpStatus.SC_NO_CONTENT); } } catch (IOException e) { response.setHeader("X-Application-Error", e.getClass().getName()); response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); logger.severe("Issue with delete comment" + e.toString()); } }
From source file:de.elomagic.carafile.client.CaraCloud.java
private void deleteFile(final Path path) throws IOException { LOG.debug("Deleting file \"" + path + "\" file at " + client.getRegistryURI()); URI uri = CaraFileUtils.buildURI(client.getRegistryURI(), "cloud", "delete", getSubPath(path)); HttpResponse response = client.executeRequest(Request.Delete(uri)).returnResponse(); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new IOException(); }//w ww .jav a 2 s. co m MetaData md = client.getMetaDataFromResponse(response); client.deleteFile(md.getId(), true); }
From source file:org.vas.test.rest.RestImpl.java
protected Request httpDelete(String uri) { Request request = Request.Delete(uri); configureRequest(request); return request; }
From source file:com.qwazr.graph.test.FullTest.java
@Test public void test210DeleteRandomEdges() throws IOException { for (int i = 0; i < VISIT_NUMBER / 100; i++) { int visiteNodeId = RandomUtils.nextInt(0, VISIT_NUMBER / 2); if (!nodeExists(visiteNodeId)) continue; int productNodeId = RandomUtils.nextInt(0, PRODUCT_NUMBER / 2); HttpResponse response = Request .Delete(BASE_URL + '/' + TEST_BASE + "/node/v" + visiteNodeId + "/edge/see/p" + productNodeId) .connectTimeout(60000).socketTimeout(60000).execute().returnResponse(); Assert.assertThat(response.getStatusLine().getStatusCode(), AnyOf.anyOf(Is.is(200), Is.is(404))); }// w ww. ja v a2s . c o m }
From source file:com.adobe.acs.commons.http.impl.HttpClientFactoryImpl.java
@Override public Request delete(String partialUrl) { String url = baseUrl + partialUrl; return Request.Delete(url); }
From source file:com.qwazr.search.index.IndexSingleClient.java
@Override public Response deleteField(String schema_name, String index_name, String field_name) { try {// w w w . j a v a 2s. co m UBuilder uriBuilder = new UBuilder("/indexes/", schema_name, "/", index_name, "/fields/", field_name); Request request = Request.Delete(uriBuilder.build()); HttpResponse response = execute(request, null, null); HttpUtils.checkStatusCodes(response, 200); return Response.status(response.getStatusLine().getStatusCode()).build(); } catch (HttpResponseEntityException e) { throw e.getWebApplicationException(); } catch (IOException e) { throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR); } }