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


Java RestTemplate.put方法代码示例

本文整理汇总了Java中org.springframework.web.client.RestTemplate.put方法的典型用法代码示例。如果您正苦于以下问题:Java RestTemplate.put方法的具体用法?Java RestTemplate.put怎么用?Java RestTemplate.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.client.RestTemplate的用法示例。


在下文中一共展示了RestTemplate.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: followChannel

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
 * Endpoint: Follow Channel
 * Adds a specified user to the followers of a specified channel.
 * Requires Scope: user_follows_edit
 *
 * @param credential    Credential
 * @param channelId     Channel to follow
 * @param notifications Send's email notifications on true.
 * @return Optional Follow, if user is following.
 */
public Boolean followChannel(OAuthCredential credential, Long channelId, Optional<Boolean> notifications) {
	// 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.put(requestUrl, Follow.class, new HashMap<String, String>());

		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,代码行数:31,代码来源:UserEndpoint.java

示例2: addBlock

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
 * Endpoint: Block User
 * Blocks a user; that is, adds a specified target user to 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 addBlock(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.put(requestUrl, Follow.class, new HashMap<String, String>());

		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: setTestPolicy

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
public String setTestPolicy(final RestTemplate acs, final HttpHeaders headers, final String endpoint,
        final String policyFile) throws JsonParseException, JsonMappingException, IOException {

    PolicySet policySet = new ObjectMapper().readValue(new File(policyFile), PolicySet.class);
    String policyName = policySet.getName();
    acs.put(endpoint + ACS_POLICY_SET_API_PATH + policyName, new HttpEntity<>(policySet, headers));
    return policyName;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:9,代码来源:PolicyHelper.java

示例4: publishTransaction

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void publishTransaction(URL node, Path privateKey, String text, byte[] senderHash) throws Exception {
    RestTemplate restTemplate = new RestTemplate();
    byte[] signature = SignatureUtils.sign(text.getBytes(), Files.readAllBytes(privateKey));
    Transaction transaction = new Transaction(text, senderHash, signature);
    restTemplate.put(node.toString() + "/transaction?publish=true", transaction);
    System.out.println("Hash of new transaction: " + Base64.encodeBase64String(transaction.getHash()));
}
 
开发者ID:neozo-software,项目名称:jblockchain,代码行数:8,代码来源:BlockchainClient.java

示例5: testCreateConnectorDeniedWithoutOauthToken

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
@Test(dataProvider = "requestUrlProvider")
public void testCreateConnectorDeniedWithoutOauthToken(final String endpointUrl) throws Exception {
    RestTemplate acs = new RestTemplate();
    try {
        acs.put(this.acsUrl + V1 + endpointUrl,
                new HttpEntity<>(new AttributeConnector(), this.zone1Headers));
        Assert.fail("No exception thrown when configuring connector without a token.");
    } catch (HttpClientErrorException e) {
        Assert.assertEquals(e.getStatusCode(), HttpStatus.UNAUTHORIZED);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:12,代码来源:AttributeConnectorConfigurationIT.java

示例6: createContainer

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
@Override
public JsonContainer[] createContainer(final String containerName) {
    // JsonEndpoint jsonEndpoint = openstackApp.getPublicEndPoints(region, projectId, this);
    String url = jsonEndpoint.getUrl() + "/" + containerName;
    RestTemplate rt = getRestTemplate(jsonEndpoint.getProjectId());
    rt.put(url, null);
    return getJsonResources();
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:9,代码来源:SwiftContainersImpl.java

示例7: addObject

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
 * Adds an object to this container.
 *
 * @param jsonContainer Container to add to
 * @param item String item to add
 */
public void addObject(final JsonContainer jsonContainer, final String item) {
    // JsonEndpoint jsonEndpoint = openstackApp.getPublicEndPoints(region, projectId, this);
    String url = jsonEndpoint.getUrl() + "/" + jsonContainer.getName() + "/" + item;
    RestTemplate rt = getRestTemplate(jsonEndpoint.getProjectId());
    rt.put(url, item);
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:13,代码来源:SwiftContainersImpl.java

示例8: testPut

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void testPut(RestTemplate template, String cseUrlPrefix) {
  template.put(cseUrlPrefix + "/compute/sayhi/{name}", null, "world");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:4,代码来源:JaxrsClient.java

示例9: publishAddress

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void publishAddress(URL node, Path publicKey, String name) throws IOException {
    RestTemplate restTemplate = new RestTemplate();
    Address address = new Address(name, Files.readAllBytes(publicKey));
    restTemplate.put(node.toString() + "/address?publish=true", address);
    System.out.println("Hash of new address: " + Base64.encodeBase64String(address.getHash()));
}
 
开发者ID:neozo-software,项目名称:jblockchain,代码行数:7,代码来源:BlockchainClient.java

示例10: attemptToUpdateServiceParameter

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private void attemptToUpdateServiceParameter(String parameterName, Object parameter, RestTemplate restTemplate,
    String updateServiceUrl) {
    Map<String, Object> serviceRequest = createUpdateServiceRequest(parameterName, parameter);
    restTemplate.put(updateServiceUrl, serviceRequest);
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:6,代码来源:ServiceUpdater.java

示例11: createTestZone

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
 * Creates desired Zone. Makes a call to the zone API and creates a zone in order to execute your set of test
 * against it.
 * 
 * @param restTemplate
 * @param zoneId
 * @param trustedIssuerIds
 * @return Zone
 * @throws IOException
 */
public Zone createTestZone(final RestTemplate restTemplate, final String zoneId,
        final List<String> trustedIssuerIds) throws IOException {
    Zone zone = new Zone(zoneId, zoneId, "Zone for integration testing.");
    restTemplate.put(this.acsBaseUrl + ACS_ZONE_API_PATH + zoneId, zone);
    return zone;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:17,代码来源:ZoneFactory.java

示例12: main

import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
public static void main(String[] args) {
	// TODO Auto-generated method stub
	
	RestTemplate template = new RestTemplate();
	
	Map<String,Long> request_parms=new HashMap<>();
	request_parms.put("ISBN",13l);
	
	Book book=new Book();
	book.setPrice(200);
	template.put("http://localhost:8081/Ch09_Spring_Rest_JDBC/books/13",book,request_parms);


}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:15,代码来源:Main_Update.java


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