当前位置: 首页>>代码示例>>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;未经允许,请勿转载。