本文整理汇总了Java中org.apache.commons.httpclient.methods.DeleteMethod类的典型用法代码示例。如果您正苦于以下问题:Java DeleteMethod类的具体用法?Java DeleteMethod怎么用?Java DeleteMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteMethod类属于org.apache.commons.httpclient.methods包,在下文中一共展示了DeleteMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
/**
* 处理http deletemethod请求
*/
public Response delete(String url, PostParameter[] params, String token)
throws WeiboException {
if (0 != params.length) {
String encodedParams = HttpClient.encodeParameters(params);
if (-1 == url.indexOf("?")) {
url += "?" + encodedParams;
} else {
url += "&" + encodedParams;
}
}
DeleteMethod deleteMethod = new DeleteMethod(url);
return httpRequest(deleteMethod, token);
}
示例2: testDeleteParagraph
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testDeleteParagraph() throws IOException {
Note note = ZeppelinServer.notebook.createNote();
Paragraph p = note.addParagraph();
p.setTitle("title1");
p.setText("text1");
note.persist();
DeleteMethod delete = httpDelete("/notebook/" + note.getId() + "/paragraph/" + p.getId());
assertThat("Test delete method: ", delete, isAllowed());
delete.releaseConnection();
Note retrNote = ZeppelinServer.notebook.getNote(note.getId());
Paragraph retrParagrah = retrNote.getParagraph(p.getId());
assertNull("paragraph should be deleted", retrParagrah);
ZeppelinServer.notebook.removeNote(note.getId());
}
示例3: createHttpMethod
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
/**
* Factory method to create a {@link HttpMethod}-object according to the
* given String <code>httpMethod</codde>
*
* @param httpMethodString the name of the {@link HttpMethod} to create
* @param url
*
* @return an object of type {@link GetMethod}, {@link PutMethod},
* {@link PostMethod} or {@link DeleteMethod}
* @throws IllegalArgumentException if <code>httpMethod</code> is none of
* <code>GET</code>, <code>PUT</code>, <code>POST</POST> or <code>DELETE</code>
*/
public static HttpMethod createHttpMethod(String httpMethodString, String url) {
if ("GET".equals(httpMethodString)) {
return new GetMethod(url);
}
else if ("PUT".equals(httpMethodString)) {
return new PutMethod(url);
}
else if ("POST".equals(httpMethodString)) {
return new PostMethod(url);
}
else if ("DELETE".equals(httpMethodString)) {
return new DeleteMethod(url);
}
else {
throw new IllegalArgumentException("given httpMethod '" + httpMethodString + "' is unknown");
}
}
示例4: doDelete
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
/**
* 处理delete请求
* @param url
* @param headers
* @return
*/
public static JSONObject doDelete(String url, Map<String, String> headers){
HttpClient httpClient = new HttpClient();
DeleteMethod deleteMethod = new DeleteMethod(url);
//设置header
setHeaders(deleteMethod,headers);
String responseStr = "";
try {
httpClient.executeMethod(deleteMethod);
responseStr = deleteMethod.getResponseBodyAsString();
} catch (Exception e) {
log.error(e);
responseStr="{status:0}";
}
return JSONObject.parseObject(responseStr);
}
示例5: testDeleteParagraph
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testDeleteParagraph() throws IOException {
Note note = ZeppelinServer.notebook.createNote(anonymous);
Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
p.setTitle("title1");
p.setText("text1");
note.persist(anonymous);
DeleteMethod delete = httpDelete("/notebook/" + note.getId() + "/paragraph/" + p.getId());
assertThat("Test delete method: ", delete, isAllowed());
delete.releaseConnection();
Note retrNote = ZeppelinServer.notebook.getNote(note.getId());
Paragraph retrParagrah = retrNote.getParagraph(p.getId());
assertNull("paragraph should be deleted", retrParagrah);
ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
示例6: testAddDeleteRepository
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testAddDeleteRepository() throws IOException {
// Call create repository API
String repoId = "securecentral";
String jsonRequest = "{\"id\":\"" + repoId +
"\",\"url\":\"https://repo1.maven.org/maven2\",\"snapshot\":\"false\"}";
PostMethod post = httpPost("/interpreter/repository/", jsonRequest);
assertThat("Test create method:", post, isAllowed());
post.releaseConnection();
// Call delete repository API
DeleteMethod delete = httpDelete("/interpreter/repository/" + repoId);
assertThat("Test delete method:", delete, isAllowed());
delete.releaseConnection();
}
示例7: delete
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
/**
* 处理http deletemethod请求
*/
public Response delete(String url, PostParameter[] params, String token) throws WeiboException {
if (0 != params.length) {
String encodedParams = HttpClient.encodeParameters(params);
if (-1 == url.indexOf("?")) {
url += "?" + encodedParams;
}
else {
url += "&" + encodedParams;
}
}
DeleteMethod deleteMethod = new DeleteMethod(url);
return httpRequest(deleteMethod, token);
}
示例8: testDeleteCourses
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testDeleteCourses() throws IOException {
final ICourse course = CoursesWebService.createEmptyCourse(admin, "courseToDel", "course to delete", null);
DBFactory.getInstance().intermediateCommit();
final HttpClient c = loginWithCookie("administrator", "olat");
final DeleteMethod method = createDelete("/repo/courses/" + course.getResourceableId(), MediaType.APPLICATION_JSON, true);
final int code = c.executeMethod(method);
assertEquals(code, 200);
final List<String> courseType = new ArrayList<String>();
courseType.add(CourseModule.getCourseTypeName());
final Roles roles = new Roles(true, true, true, true, false, true, false);
final List<RepositoryEntry> repoEntries = RepositoryServiceImpl.getInstance().genericANDQueryWithRolesRestriction("*", "*", "*", courseType, roles, "");
assertNotNull(repoEntries);
for (final RepositoryEntry entry : repoEntries) {
assertNotSame(entry.getOlatResource().getResourceableId(), course.getResourceableId());
}
}
示例9: testDeleteAuthentications
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testDeleteAuthentications() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
// create an authentication token
final Identity adminIdent = baseSecurity.findIdentityByName("administrator");
final Authentication authentication = baseSecurity.createAndPersistAuthentication(adminIdent, "REST-A-2", "administrator", "credentials");
assertTrue(authentication != null && authentication.getKey() != null && authentication.getKey().longValue() > 0);
DBFactory.getInstance().intermediateCommit();
// delete an authentication token
final String request = "/users/administrator/auth/" + authentication.getKey().toString();
final DeleteMethod method = createDelete(request, MediaType.APPLICATION_XML, true);
final int code = c.executeMethod(method);
assertEquals(code, 200);
method.releaseConnection();
final Authentication refAuth = baseSecurity.findAuthentication(adminIdent, "REST-A-2");
assertNull(refAuth);
}
示例10: testDeleteCatalogEntry
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testDeleteCatalogEntry() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()).build();
final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true);
final int code = c.executeMethod(method);
assertEquals(200, code);
method.releaseConnection();
final List<CatalogEntry> entries = catalogService.getChildrenOf(root1);
for (final CatalogEntry entry : entries) {
assertFalse(entry.getKey().equals(entry2.getKey()));
}
}
示例11: testRemoveOwner
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Test
public void testRemoveOwner() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").path(id1.getUser().getKey().toString())
.build();
final DeleteMethod method = createDelete(uri, MediaType.APPLICATION_JSON, true);
final int code = c.executeMethod(method);
method.releaseConnection();
assertEquals(200, code);
final CatalogEntry entry = catalogService.loadCatalogEntry(entry1.getKey());
final List<Identity> identities = securityManager.getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
boolean found = false;
for (final Identity identity : identities) {
if (identity.getKey().equals(id1.getKey())) {
found = true;
}
}
assertFalse(found);
}
示例12: buildHttpClientMethod
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
protected static HttpMethodBase buildHttpClientMethod(String url, String method)
{
if ("GET".equals(method))
{
return new GetMethod(url);
}
if ("POST".equals(method))
{
return new PostMethod(url);
}
if ("PUT".equals(method))
{
return new PutMethod(url);
}
if ("DELETE".equals(method))
{
return new DeleteMethod(url);
}
if (TestingMethod.METHOD_NAME.equals(method))
{
return new TestingMethod(url);
}
throw new UnsupportedOperationException("Method '"+method+"' not supported");
}
示例13: getDeleteResponseFromDocStore
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
@Deprecated
public String getDeleteResponseFromDocStore(String operation, String uuid, BoundwithForm transferForm)
throws IOException {
String restfulUrl = ConfigContext.getCurrentContextConfig().getProperty("docstore.restful.url");
restfulUrl = restfulUrl.concat("/") + uuid;
HttpClient httpClient = new HttpClient();
DeleteMethod deleteMethod = new DeleteMethod(restfulUrl);
NameValuePair nvp1 = new NameValuePair("identifierType", "UUID");
NameValuePair nvp2 = new NameValuePair("operation", operation);
NameValuePair category = new NameValuePair("docCategory", transferForm.getDocCategory());
NameValuePair type = new NameValuePair("docType", transferForm.getDocType());
NameValuePair format = new NameValuePair("docFormat", transferForm.getDocFormat());
deleteMethod.setQueryString(new NameValuePair[]{nvp1, nvp2, category, type, format});
int statusCode = httpClient.executeMethod(deleteMethod);
if (LOG.isDebugEnabled()){
LOG.debug("statusCode-->" + statusCode);
}
InputStream inputStream = deleteMethod.getResponseBodyAsStream();
return IOUtils.toString(inputStream);
}
示例14: deleteDocstoreRecord
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
public String deleteDocstoreRecord(String docType, String uuid) throws IOException {
String docstoreRestfulURL = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
OLEConstants.OLE_DOCSTORE_RESTFUL_URL);
docstoreRestfulURL = docstoreRestfulURL.concat("/") + uuid;
HttpClient httpClient = new HttpClient();
DeleteMethod deleteMethod = new DeleteMethod(docstoreRestfulURL);
NameValuePair nvp1 = new NameValuePair(OLEConstants.IDENTIFIER_TYPE, OLEConstants.UUID);
NameValuePair nvp2 = new NameValuePair(OLEConstants.OPERATION, OLEConstants.DELETE);
NameValuePair category = new NameValuePair(OLEConstants.DOC_CATEGORY, OLEConstants.BIB_CATEGORY_WORK);
NameValuePair type = new NameValuePair(OLEConstants.DOC_TYPE, docType);
NameValuePair format = new NameValuePair(OLEConstants.DOC_FORMAT, OLEConstants.BIB_FORMAT_OLEML);
deleteMethod.setQueryString(new NameValuePair[]{nvp1, nvp2, category, type, format});
int statusCode = httpClient.executeMethod(deleteMethod);
InputStream inputStream = deleteMethod.getResponseBodyAsStream();
return IOUtils.toString(inputStream);
}
示例15: performRestFulOperation
import org.apache.commons.httpclient.methods.DeleteMethod; //导入依赖的package包/类
public Response performRestFulOperation(String docCategory, String docType, String docFormat, String ids) throws Exception {
String restfulUrl = ConfigContext.getCurrentContextConfig().getProperty("docstore.restful.url");
restfulUrl = restfulUrl.concat("/") + ids;
HttpClient httpClient = new HttpClient();
DeleteMethod deleteMethod = new DeleteMethod(restfulUrl);
NameValuePair nvp1 = new NameValuePair("identifierType", "UUID");
NameValuePair nvp2 = new NameValuePair("operation", "delete");
// NameValuePair nvp3 = new NameValuePair("id", ids);
NameValuePair category = new NameValuePair("docCategory", docCategory);
NameValuePair type = new NameValuePair("docType", docType);
NameValuePair format = new NameValuePair("docFormat", docFormat);
deleteMethod.setQueryString(new NameValuePair[]{nvp1, nvp2, category, type, format});
int statusCode = httpClient.executeMethod(deleteMethod);
LOG.info("statusCode-->" + statusCode);
InputStream inputStream = deleteMethod.getResponseBodyAsStream();
String responseXML = IOUtils.toString(inputStream, "UTF-8");
LOG.info("Response-->" + responseXML);
return new ResponseHandler().toObject(responseXML);
}