use of org.apache.commons.httpclient.methods.DeleteMethod in project cloudstack by apache.
the class BigSwitchBcfApi method executeDeleteObject.
protected String executeDeleteObject(final String uri) throws BigSwitchBcfApiException {
checkInvariants();
DeleteMethod dm = (DeleteMethod) createMethod("delete", uri, _port);
setHttpHeader(dm);
executeMethod(dm);
String hash = checkResponse(dm, "BigSwitch HTTP delete failed: ");
dm.releaseConnection();
return hash;
}
use of org.apache.commons.httpclient.methods.DeleteMethod in project android by nextcloud.
the class NotificationExecuteActionTask method doInBackground.
@Override
protected Boolean doInBackground(Action... actions) {
HttpMethod method;
Action action = actions[0];
switch(action.type) {
case "GET":
method = new GetMethod(action.link);
break;
case "POST":
method = new Utf8PostMethod(action.link);
break;
case "DELETE":
method = new DeleteMethod(action.link);
break;
case "PUT":
method = new PutMethod(action.link);
break;
default:
// do nothing
return Boolean.FALSE;
}
method.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE);
int status;
try {
status = client.executeMethod(method);
} catch (IOException e) {
Log_OC.e(this, "Execution of notification action failed: " + e);
return Boolean.FALSE;
} finally {
method.releaseConnection();
}
return status == HttpStatus.SC_OK || status == HttpStatus.SC_ACCEPTED;
}
use of org.apache.commons.httpclient.methods.DeleteMethod in project alfresco-repository by Alfresco.
the class BaseWebScriptTest method sendRemoteRequest.
/**
* Send Remote Request to stand-alone Web Script Server
*
* @param req Request
* @param expectedStatus int
* @return response
* @throws IOException
*/
protected Response sendRemoteRequest(Request req, int expectedStatus) throws IOException {
String uri = req.getFullUri();
if (!uri.startsWith("http")) {
uri = remoteServer.baseAddress + uri;
}
// construct method
HttpMethod httpMethod = null;
String method = req.getMethod();
if (method.equalsIgnoreCase("GET")) {
GetMethod get = new GetMethod(req.getFullUri());
httpMethod = get;
} else if (method.equalsIgnoreCase("POST")) {
PostMethod post = new PostMethod(req.getFullUri());
post.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = post;
} else if (method.equalsIgnoreCase("PATCH")) {
PatchMethod post = new PatchMethod(req.getFullUri());
post.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = post;
} else if (method.equalsIgnoreCase("PUT")) {
PutMethod put = new PutMethod(req.getFullUri());
put.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = put;
} else if (method.equalsIgnoreCase("DELETE")) {
DeleteMethod del = new DeleteMethod(req.getFullUri());
httpMethod = del;
} else {
throw new AlfrescoRuntimeException("Http Method " + method + " not supported");
}
if (req.getHeaders() != null) {
for (Map.Entry<String, String> header : req.getHeaders().entrySet()) {
httpMethod.setRequestHeader(header.getKey(), header.getValue());
}
}
// execute method
httpClient.executeMethod(httpMethod);
return new HttpMethodResponse(httpMethod);
}
use of org.apache.commons.httpclient.methods.DeleteMethod in project jaxrs-api by eclipse-ee4j.
the class MethodFactory method getInstance.
/*
* public methods
* ========================================================================
*/
/**
* Returns the approriate request method based on the provided request string.
* The request must be in the format of METHOD URI_PATH HTTP_VERSION, i.e. GET
* /index.jsp HTTP/1.1.
*
* @return HttpMethod based in request.
*/
public static HttpMethod getInstance(String request) {
StringTokenizer st = new StringTokenizer(request);
String method;
String query = null;
String uri;
String version;
try {
method = st.nextToken();
uri = TS_URL.getRequest(st.nextToken());
version = st.nextToken();
} catch (NoSuchElementException nsee) {
throw new IllegalArgumentException("Request provided: " + request + " is malformed.");
}
// check to see if there is a query string appended
// to the URI
int queryStart = uri.indexOf('?');
if (queryStart != -1) {
query = uri.substring(queryStart + 1);
uri = uri.substring(0, queryStart);
}
HttpMethodBase req;
if (method.equals(GET_METHOD)) {
req = new GetMethod(uri);
} else if (method.equals(POST_METHOD)) {
req = new PostMethod(uri);
} else if (method.equals(PUT_METHOD)) {
req = new PutMethod(uri);
} else if (method.equals(DELETE_METHOD)) {
req = new DeleteMethod(uri);
} else if (method.equals(HEAD_METHOD)) {
req = new HeadMethod(uri);
} else if (method.equals(OPTIONS_METHOD)) {
req = new OptionsMethod(uri);
} else {
throw new IllegalArgumentException("Invalid method: " + method);
}
setHttpVersion(version, req);
if (query != null) {
req.setQueryString(query);
}
return req;
}
Aggregations