List of usage examples for org.springframework.web.client RestTemplate RestTemplate
public RestTemplate()
From source file:org.cloudfoundry.identity.uaa.oauth.RemoteTokenServicesTests.java
public RemoteTokenServicesTests() { services.setClientId("client"); services.setClientSecret("secret"); body.put(Claims.CLIENT_ID, "remote"); body.put(Claims.USER_NAME, "olds"); body.put(Claims.EMAIL, "olds@vmware.com"); body.put(Claims.USER_ID, "HDGFJSHGDF"); services.setRestTemplate(new RestTemplate() { @SuppressWarnings("unchecked") @Override/* w w w . jav a2s .com*/ public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException { return new ResponseEntity<T>((T) body, headers, status); } }); }
From source file:gumga.framework.security.GumgaRequestFilter.java
public GumgaRequestFilter() { softwareId = "SomeSoftware"; restTemplate = new RestTemplate(); mapper = new ObjectMapper(); }
From source file:org.starfishrespect.myconsumption.android.tasks.ConfigUpdater.java
public void refreshDB() { AsyncTask<Void, List, Void> task = new AsyncTask<Void, List, Void>() { @Override/*from w w w .j ava2s. c o m*/ protected Void doInBackground(Void... params) { DatabaseHelper db = SingleInstance.getDatabaseHelper(); RestTemplate template = new RestTemplate(); template.getMessageConverters().add(new MappingJacksonHttpMessageConverter()); try { String url = SingleInstance.getServerUrl() + "configs/co2"; Double co2 = template.getForObject(url, Double.class); int id = db.getIdForKey("config_co2"); KeyValueData valueData = new KeyValueData("config_co2", co2.toString()); valueData.setId(id); LOGD(TAG, "writing stat in local db: " + co2); db.getKeyValueDao().createOrUpdate(valueData); } catch (SQLException e) { LOGD(TAG, "Cannot create config co2", e); } catch (ResourceAccessException | HttpClientErrorException e) { LOGE(TAG, "Cannot access server ", e); } try { String url = SingleInstance.getServerUrl() + "configs/day"; Double day = template.getForObject(url, Double.class); int id = db.getIdForKey("config_day"); KeyValueData valueData = new KeyValueData("config_day", day.toString()); valueData.setId(id); LOGD(TAG, "writing stat in local db: " + day); db.getKeyValueDao().createOrUpdate(valueData); } catch (SQLException e) { LOGD(TAG, "Cannot create config day", e); } catch (ResourceAccessException | HttpClientErrorException e) { LOGE(TAG, "Cannot access server ", e); } try { String url = SingleInstance.getServerUrl() + "configs/night"; Double night = template.getForObject(url, Double.class); int id = db.getIdForKey("config_night"); KeyValueData valueData = new KeyValueData("config_night", night.toString()); valueData.setId(id); LOGD(TAG, "writing stat in local db: " + night); db.getKeyValueDao().createOrUpdate(valueData); } catch (SQLException e) { LOGD(TAG, "Cannot create config night", e); } catch (ResourceAccessException | HttpClientErrorException e) { LOGE(TAG, "Cannot access server ", e); } return null; } @Override protected void onPostExecute(Void aVoid) { if (configUpdateFinishedCallback != null) { configUpdateFinishedCallback.onConfigUpdateFinished(); } } }; task.execute(); }
From source file:io.pivotal.tzolov.gemfire.adapter.GemfireHawqAdapterService.java
@SuppressWarnings("rawtypes") public void runAdhocQuery(String oqlQuery, Writer writer) throws Exception { List rows = new RestTemplate().getForObject( "http://{hostname}:{port}/gemfire-api/v1/queries/adhoc?q={query}", List.class, hostName, port, oqlQuery);/*from ww w. ja v a2s.c om*/ processResponse(rows, writer); }
From source file:uk.ac.ebi.eva.vcfdump.cellbasewsclient.CellbaseWSClient.java
public Set<String> getChromosomes() { try {//from w w w . ja v a2 s . co m // call cellbase chromosomes WS RestTemplate restTemplate = new RestTemplate(); ParameterizedTypeReference<QueryResponse<QueryResult<CellbaseChromosomesWSOutput>>> responseType = new ParameterizedTypeReference<QueryResponse<QueryResult<CellbaseChromosomesWSOutput>>>() { }; String cellbaseGetChromosomesUrl = cellbaseRestURL + "/" + cellbaseRestVersion + "/" + species + "/genomic/chromosome/all"; logger.debug("Getting chromosomes list from {} ...", cellbaseGetChromosomesUrl); ResponseEntity<QueryResponse<QueryResult<CellbaseChromosomesWSOutput>>> wsOutput = restTemplate .exchange(cellbaseGetChromosomesUrl, HttpMethod.GET, null, responseType); // parse WS output and return all chromosome names QueryResponse<QueryResult<CellbaseChromosomesWSOutput>> response = wsOutput.getBody(); QueryResult<CellbaseChromosomesWSOutput> result = response.getResponse().get(0); CellbaseChromosomesWSOutput results = result.getResult().get(0); return results.getAllChromosomeNames(); } catch (Exception e) { logger.debug("Error retrieving list of chromosomes: {}", e.getMessage()); throw new RuntimeException("Error retrieving list of chromosomes", e); } }
From source file:org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient.java
public ConfluentSchemaRegistryClient() { this.template = new RestTemplate(); this.mapper = new ObjectMapper(); }
From source file:org.zalando.stups.twintip.TwintipApplicationIT.java
@Test public void isConfigured() { String endpointUrl = "http://localhost:" + port + "/.well-known/schema-discovery"; LOG.info("ENDPOINT_URL : {}", endpointUrl); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.getForEntity(endpointUrl, String.class); HttpStatus statusCode = entity.getStatusCode(); String body = entity.getBody(); Assertions.assertThat(statusCode).isEqualTo(HttpStatus.OK); Assertions.assertThat(body).contains("swagger-2.0"); LOG.info("BODY : {}", body); }
From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.SpringApiClientImplTest.java
/** * Tests constructor {@link SpringApiClientImpl#SpringApiClientImpl(String, String, Integer, RestTemplate)} in the * case where the supplied protocol and port are for valid, unencrypted communications. *///from w ww. j a va2 s. c o m @Test public final void testConstructValidUnencryptedProtocolAndPort() { new SpringApiClientImpl("http", "api.test.brighttalk.net", 80, new RestTemplate()); }
From source file:example.customers.integration.StoreIntegration.java
private void verify(Link link) { try {//from w ww .ja va 2 s. c o m log.info("Verifying stores-nearby link pointing to {}", storesByLocationLink); new RestTemplate().headForHeaders(link.expand().getHref()); log.info("Successfully verified link!"); } catch (RestClientException o_O) { log.info("Verification failed, marking as outdated!"); this.storesByLocationLink = null; } }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String runQuery(String sparqlQuery) { final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/query/run"; //final String uri = "http://localhost:8090/api/v1/ontology/query/run"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); RestTemplate restTemplate = new RestTemplate(); HttpEntity<String> entity = new HttpEntity<>(sparqlQuery, headers); String result = restTemplate.postForObject(uri, entity, String.class); return result; }