當前位置: 首頁>>代碼示例>>Java>>正文


Java RestTemplate.delete方法代碼示例

本文整理匯總了Java中org.springframework.web.client.RestTemplate.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java RestTemplate.delete方法的具體用法?Java RestTemplate.delete怎麽用?Java RestTemplate.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.client.RestTemplate的用法示例。


在下文中一共展示了RestTemplate.delete方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unfollowChannel

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Endpoint: Unfollow Channel
 * Deletes a specified user from the followers of a specified channel.
 * Requires Scope: user_follows_edit
 *
 * @param credential Credential
 * @param channelId  Channel to follow
 * @return Optional Follow, if user is following.
 */
public Boolean unfollowChannel(OAuthCredential credential, Long channelId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/follows/channels/%s", Endpoints.API.getURL(), credential.getUserId(), channelId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		restTemplate.delete(requestUrl);

		return true;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return false;
}
 
開發者ID:twitch4j,項目名稱:twitch4j,代碼行數:30,代碼來源:UserEndpoint.java

示例2: deleteBlock

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Endpoint: Unblock User
 * Unblocks a user; that is, deletes a specified target user from the blocks list of a specified source user.
 * Requires Scope: user_blocks_edit
 *
 * @param credential   Credential
 * @param targetUserId UserID of the Target
 * @return todo
 */
public Boolean deleteBlock(OAuthCredential credential, Long targetUserId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/blocks/%s", Endpoints.API.getURL(), credential.getUserId(), targetUserId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		restTemplate.delete(requestUrl);

		return true;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return false;
}
 
開發者ID:twitch4j,項目名稱:twitch4j,代碼行數:30,代碼來源:UserEndpoint.java

示例3: run

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
@Override
@SuppressWarnings("checkstyle:emptyblock")
public void run() {
    LOG.warn("****** SelfRevokingProvider Thread going to sleep for 15 secs");
    try {
        Thread.sleep(THREAD_SLEEP);
    } catch (InterruptedException ie) {
    }
    LOG.warn("****** SelfRevokingProvider finished sleeping, revoking all tokens");
    try {
        RestTemplate rt = restManager.getRestTemplate("keystone-revoke");
        rt.setInterceptors(Collections.singletonList(this));
        LOG.warn("****** deleting " + keystoneTokenURI.toString());
        for (TokenHolder tokenHolder : TokenManager.getInstance().getAllTokenHolders()) {
            currentToken = tokenHolder.getUnscoped();
            LOG.warn("****** deleting token " + currentToken + "[" + keystoneTokenURI.toString() + "]");
            rt.delete(keystoneTokenURI);
        }
    } catch (HttpClientErrorException ex) {
        LOG.error("****** token revocation refused for token " + currentToken);
    }
    LOG.warn("****** all tokens have been revoked - SelfRevokingProvider Thread is exiting...");
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:24,代碼來源:SelfRevokingKeystoneV3Provider.java

示例4: stopWorkspace

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Stops a running workspace.
 */
public void stopWorkspace(String cheServerURL, Workspace workspace, String keycloakToken) {
        LOG.info("Stopping workspace {}", workspace.getId());
        String url = CheRestEndpoints.STOP_WORKSPACE.generateUrl(cheServerURL, workspace.getId());
        RestTemplate template = new KeycloakRestTemplate(keycloakToken);
        template.delete(url);
}
 
開發者ID:redhat-developer,項目名稱:che-starter,代碼行數:10,代碼來源:WorkspaceClient.java

示例5: deleteProject

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Delete a project from workspace. Workspace must be running to delete a
 * project.
 * 
 * @param cheServerURL
 * @param workspaceName
 * @param projectName
 */
public void deleteProject(String cheServerURL, Workspace workspace, String projectName, String keycloakToken) {
    String wsAgentUrl = getWsAgentUrl(workspace);

    String deleteProjectURL = CheRestEndpoints.DELETE_PROJECT.generateUrl(wsAgentUrl, projectName);
    LOG.info("Deleting project {}", projectName);
    RestTemplate template = new KeycloakRestTemplate(keycloakToken);
    template.delete(deleteProjectURL);
}
 
開發者ID:redhat-developer,項目名稱:che-starter,代碼行數:17,代碼來源:ProjectClient.java

示例6: deleteZone

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Deletes desired Zone. Makes a client call that deletes the desired zone. This method should be use after the
 * set of tests for that zone are finished.
 * 
 * @param restTemplate
 * @param zoneName
 * @return HttpStatus
 */
public HttpStatus deleteZone(final RestTemplate restTemplate, final String zoneName) {
    try {
        restTemplate.delete(this.acsBaseUrl + ACS_ZONE_API_PATH + zoneName);
        return HttpStatus.NO_CONTENT;
    } catch (HttpClientErrorException httpException) {
        return httpException.getStatusCode();
    } catch (RestClientException e) {
        return HttpStatus.INTERNAL_SERVER_ERROR;
    }
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:19,代碼來源:ZoneFactory.java

示例7: logout

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/**
 * Log this user out (based on the token in the TokenHolder).
 *
 * @param baseUrl keystone url to logout with
 * @return true if it was successful.
 */
public boolean logout(final String baseUrl) {
    boolean success = false;
    try {
        URI keystoneTokenURI = EndpointUtils.keystoneTokenURINoCatalog(baseUrl);
        RestTemplate rt = openstackApp.getRestTemplateWithUnscopedAndSubjectToken();
        rt.delete(keystoneTokenURI);
        success = true;
    } catch (RestClientException ex) {
        LOG.error("Revoke failed!!! " + ex.getMessage());
        success = false;
    }
    return success;
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:20,代碼來源:KeystoneProjects.java

示例8: testDelete

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
private static void testDelete(RestTemplate template, String cseUrlPrefix) {
  Map<String, String> params = new HashMap<>();
  params.put("name", "world");
  template.delete(cseUrlPrefix + "/compute/sayhei/?name={name}", params);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:6,代碼來源:JaxrsClient.java

示例9: deletePolicySet

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
public void deletePolicySet(final RestTemplate restTemplate, final String acsUrl, final String testPolicyName) {
    if (testPolicyName != null) {
        restTemplate.delete(acsUrl + ACS_POLICY_SET_API_PATH + testPolicyName);
    }
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:6,代碼來源:PolicyHelper.java

示例10: deleteWorkspace

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
/** Deletes a workspace. Workspace must be stopped before invoking its  deletion.
 * 
 * @param cheServerURL Che server URL
 * @param workspaceId workspace ID
 * @throws WorkspaceNotFound if workspace does not exists
 */
public void deleteWorkspace(String cheServerURL, String workspaceId, String keycloakToken) throws WorkspaceNotFound {
    String url = CheRestEndpoints.DELETE_WORKSPACE.generateUrl(cheServerURL, workspaceId);
    RestTemplate template = new KeycloakRestTemplate(keycloakToken);
    template.delete(url);
}
 
開發者ID:redhat-developer,項目名稱:che-starter,代碼行數:12,代碼來源:WorkspaceClient.java

示例11: main

import org.springframework.web.client.RestTemplate; //導入方法依賴的package包/類
public static void main(String[] args) {
	RestTemplate template = new RestTemplate();
	template.delete("http://localhost:8081/Ch09_Spring_Rest_JDBC/books/1234");


}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-5.0,代碼行數:7,代碼來源:Main_Delete.java


注:本文中的org.springframework.web.client.RestTemplate.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。