當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。