List of usage examples for org.springframework.web.client RestTemplate put
@Override public void put(String url, @Nullable Object request, Map<String, ?> uriVariables) throws RestClientException
From source file:org.apache.servicecomb.demo.jaxrs.client.JaxrsClient.java
private static void testPut(RestTemplate template, String cseUrlPrefix) { template.put(cseUrlPrefix + "/compute/sayhi/{name}", null, "world"); }
From source file:org.ambient.rest.SetCurrentClimateProfileTask.java
@Override protected Void doInBackground(String... params) { try {//from ww w .j a va 2 s . com String url = Rest.getUrl(URL); Map<String, String> vars = Collections.singletonMap("roomName", params[0]); RestTemplate restTemplate = Rest.getRestTemplate(); restTemplate.put(url, params[1], vars); } catch (Exception e) { Log.e(LOG, e.getMessage()); } return null; }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static ScimGroup createOrUpdateGroup(RestTemplate client, String url, ScimGroup scimGroup) { //dont modify the actual argument LinkedList<ScimGroupMember> members = new LinkedList<>(scimGroup.getMembers()); ScimGroup existing = getGroup(client, url, scimGroup.getDisplayName()); if (existing != null) { members.addAll(existing.getMembers()); }/*from w w w . j a v a 2s . c o m*/ scimGroup.setMembers(members); if (existing != null) { scimGroup.setId(existing.getId()); client.put(url + "/Groups/{id}", scimGroup, scimGroup.getId()); return scimGroup; } else { ResponseEntity<String> group = client.postForEntity(url + "/Groups", scimGroup, String.class); if (group.getStatusCode() == HttpStatus.CREATED) { return JsonUtils.readValue(group.getBody(), ScimGroup.class); } else { throw new IllegalStateException("Invalid return code:" + group.getStatusCode()); } } }
From source file:com.wisemapping.test.rest.RestAdminITCase.java
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") public void changePassword(final @NotNull MediaType mediaType) { // Configure media types ... final HttpHeaders requestHeaders = createHeaders(mediaType); final RestTemplate templateRest = createTemplate(authorisation); // Fill user data ... final RestUser restUser = createDummyUser(); // User has been created ... final URI location = createUser(requestHeaders, templateRest, restUser); // Check that the user has been created ... ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location); // Change password ... requestHeaders.setContentType(MediaType.TEXT_PLAIN); HttpEntity<String> createUserEntity = new HttpEntity<String>("some-new-password", requestHeaders); templateRest.put(BASE_REST_URL + "/admin/users/{id}/password", createUserEntity, result.getBody().getId()); }
From source file:org.cloudfoundry.client.lib.rest.CloudControllerClientV1.java
/** * Upload an app using the legacy API used for older vcap versions like Micro Cloud Foundry 1.1 and older * As of Micro Cloud Foundry 1.2 and for any recent CloudFoundry.com deployment the current method of setting * the content type as JSON works fine.//from w ww . j a va 2s . com * * @param path app path * @param entity HttpEntity for the payload * @param appName name of app * @throws HttpServerErrorException */ private void uploadAppUsingLegacyApi(String path, HttpEntity<?> entity, String appName) throws HttpServerErrorException { RestTemplate legacyRestTemplate = new RestTemplate(); legacyRestTemplate.setRequestFactory(this.getRestTemplate().getRequestFactory()); legacyRestTemplate.setErrorHandler(new ErrorHandler()); legacyRestTemplate.setMessageConverters(getLegacyMessageConverters()); legacyRestTemplate.put(path, entity, appName); }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client, String url, String id, String subdomain, Consumer<IdentityZoneConfiguration> configureZone) { ResponseEntity<String> zoneGet = client.getForEntity(url + "/identity-zones/{id}", String.class, id); if (zoneGet.getStatusCode() == HttpStatus.OK) { IdentityZone existing = JsonUtils.readValue(zoneGet.getBody(), IdentityZone.class); existing.setSubdomain(subdomain); client.put(url + "/identity-zones/{id}", existing, id); return existing; }//from w ww. jav a 2 s. c om IdentityZone identityZone = fixtureIdentityZone(id, subdomain, new IdentityZoneConfiguration()); configureZone.accept(identityZone.getConfig()); ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone, IdentityZone.class); return zone.getBody(); }
From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java
public static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client, String url, String id, String subdomain, IdentityZoneConfiguration config) { ResponseEntity<String> zoneGet = client.getForEntity(url + "/identity-zones/{id}", String.class, id); if (zoneGet.getStatusCode() == HttpStatus.OK) { IdentityZone existing = JsonUtils.readValue(zoneGet.getBody(), IdentityZone.class); existing.setSubdomain(subdomain); existing.setConfig(config);/*w w w.j a va 2 s. com*/ client.put(url + "/identity-zones/{id}", existing, id); return existing; } IdentityZone identityZone = fixtureIdentityZone(id, subdomain, config); ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone, IdentityZone.class); return zone.getBody(); }