当前位置: 首页>>代码示例>>Java>>正文


Java DeleteMethod类代码示例

本文整理汇总了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);

}
 
开发者ID:seagrape,项目名称:kekoa,代码行数:19,代码来源:HttpClient.java

示例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());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:21,代码来源:ZeppelinRestApiTest.java

示例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");
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:31,代码来源:HttpUtil.java

示例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);
}
 
开发者ID:apicloudcom,项目名称:Java-sdk,代码行数:27,代码来源:HttpUtils.java

示例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);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:21,代码来源:ZeppelinRestApiTest.java

示例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();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:InterpreterRestApiTest.java

示例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);

}
 
开发者ID:jpbirdy,项目名称:WordsDetection,代码行数:19,代码来源:HttpClient.java

示例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());
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:21,代码来源:CourseITCase.java

示例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);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:21,代码来源:UserAuthenticationMgmtITCase.java

示例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()));
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:17,代码来源:CatalogITCase.java

示例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);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:23,代码来源:CatalogITCase.java

示例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");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:RemoteConnectorRequestImpl.java

示例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);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:22,代码来源:TransferUtil.java

示例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);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:17,代码来源:OleDocstoreHelperServiceImpl.java

示例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);
    }
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:21,代码来源:DocstoreHelperService.java


注:本文中的org.apache.commons.httpclient.methods.DeleteMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。