use of org.apache.http.client.methods.HttpDelete in project sling by apache.
the class AbstractHtmlClientImpl method delete.
@Override
public <T extends Document> T delete(String url) throws ClientException {
try {
URI absoluteUri = absoluteUri(url);
LOG.info("DELETE " + absoluteUri);
HttpResponse response = this.execute(new HttpDelete(absoluteUri));
return newDocument(response.getEntity().toString());
} catch (URISyntaxException e) {
throw new ClientException("Invalid post url " + url, e);
} catch (Exception e) {
throw new ClientException("Could not execute DELETE request", e);
}
}
use of org.apache.http.client.methods.HttpDelete in project cdap by caskdata.
the class AppFabricTestBase method doDelete.
protected static HttpResponse doDelete(String resource) throws Exception {
DefaultHttpClient client = new DefaultHttpClient();
HttpDelete delete = new HttpDelete(getEndPoint(resource));
delete.setHeader(AUTH_HEADER);
return client.execute(delete);
}
use of org.apache.http.client.methods.HttpDelete in project iTest by e-government-ua.
the class DeleteTask method methodDelete.
public void methodDelete(String ID) throws Exception {
if (configVariables.baseUrl.contains("alpha.test.igov.org.ua")) {
Url = "https://alpha.test.region.igov.org.ua";
} else if (configVariables.baseUrl.contains("beta.test.igov.org.ua")) {
Url = "https://beta.test.region.igov.org.ua";
} else if (configVariables.baseUrl.contains("beta-old.test.igov.org.ua")) {
Url = "https://beta-old.test.region.igov.org.ua";
} else if (configVariables.baseUrl.contains("delta.test.igov.org.ua")) {
Url = "https://delta.test.region.igov.org.ua";
} else {
throw new Exception("ERROR URL ");
}
/*
switch (configVariables.baseUrl) {
case "https://alpha.test.igov.org.ua":
Url ="https://alpha.test.region.igov.org.ua";
break;
case "https://beta.test.igov.org.ua":
Url ="https://beta.test.region.igov.org.ua";
break;
case "https://beta-old.test.igov.org.ua":
Url ="https://beta-old.test.region.igov.org.ua";
break;
case "https://delta.test.igov.org.ua":
Url ="https://delta.test.region.igov.org.ua";
break;
default:
throw new Exception("ERROR URL ");
}
*/
String patch = "/wf/service/action/task/delete-process?nID_Order=";
String IdOrder = ID;
String urlDelete = Url + patch + IdOrder;
System.out.println("\nSending 'delete' request to URL : " + urlDelete);
HttpResponse response = null;
try {
HttpClient client = createHttpClient_AcceptsUntrustedCerts();
HttpDelete httpDelete = new HttpDelete(urlDelete);
httpDelete.addHeader("Content-Type", "application/json");
httpDelete.addHeader("Authorization", "Basic a2VybWl0Omtlcm1pdA==");
response = client.execute(httpDelete);
System.out.println("response: " + response);
} catch (Exception oException) {
System.err.println("Cant 'delete' " + urlDelete + "):" + oException.getMessage());
throw new Exception("Cant 'delete' " + urlDelete + "):" + oException.getMessage());
//throw oException;
}
// HttpResponse response = Request.Post(url).stringBody("request_body","content_type").execute().returnResponse();
// JSONObject jsonResponse = new JSONObject(IOUtils.toString(response.getEntity().getContent()));
// JSONArray jsonResponse = new JSONArray(IOUtils.toString(response.getEntity().getContent()));
// JSONObject jsonResponse = new JSONObject(IOUtils.toString(response.getEntity().getContent()));
//
// System.out.println("Response Code : " +
// response.getStatusLine().getStatusCode());
//
// System.out.print("RESP Body :"+ jsonResponse);
System.out.println("\nSending 'delete' request to URL : " + urlDelete);
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
System.out.println("rd: " + rd);
StringBuffer result = new StringBuffer();
System.out.println("result: " + result);
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println("line = rd.readLine(): " + rd.readLine());
result.append(line);
System.out.println("result.append(line): " + result.append(line));
}
System.out.println("result.toString(): " + result.toString());
}
use of org.apache.http.client.methods.HttpDelete in project dhis2-core by dhis2.
the class HttpUtils method httpDELETE.
/**
* <pre>
* <b>Description : </b>
* Method to make an http DELETE call to a given URL with/without authentication.
*
* @param requestURL
* @param authorize
* @param username
* @param password
* @param headers
* @param timeout
* @return
* @throws Exception </pre>
*/
public static DhisHttpResponse httpDELETE(String requestURL, boolean authorize, String username, String password, Map<String, String> headers, int timeout) throws Exception {
DefaultHttpClient httpclient = null;
DhisHttpResponse dhisHttpResponse = null;
try {
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, timeout);
HttpConnectionParams.setSoTimeout(params, timeout);
httpclient = new DefaultHttpClient(params);
HttpDelete httpDelete = new HttpDelete(requestURL);
if (headers instanceof Map) {
for (Map.Entry<String, String> e : headers.entrySet()) {
httpDelete.addHeader(e.getKey(), e.getValue());
}
}
if (authorize) {
httpDelete.setHeader("Authorization", CodecUtils.getBasicAuthString(username, password));
}
HttpResponse response = httpclient.execute(httpDelete);
dhisHttpResponse = processResponse(requestURL, username, response);
return dhisHttpResponse;
} catch (Exception e) {
log.error("exception occurred in httpDELETE call with username " + username, e);
throw e;
} finally {
if (httpclient != null) {
httpclient.getConnectionManager().shutdown();
}
}
}
use of org.apache.http.client.methods.HttpDelete in project cxf by apache.
the class Client method deleteCustomerInfo.
public void deleteCustomerInfo(String name, String password, int id) throws Exception {
System.out.println("HTTP DELETE to update customer info, user : " + name + ", password : " + password);
System.out.println("Confirming a customer with id " + id + " exists first");
getCustomerInfo(name, password, id);
System.out.println("Deleting now...");
HttpDelete del = new HttpDelete("http://localhost:9002/customerservice/customers/" + id);
setMethodHeaders(del, name, password);
handleHttpMethod(del);
System.out.println("Confirming a customer with id " + id + " does not exist anymore");
getCustomerInfo(name, password, id);
}
Aggregations