List of usage examples for org.springframework.http HttpEntity HttpEntity
public HttpEntity(MultiValueMap<String, String> headers)
From source file:org.cloudfoundry.identity.uaa.scim.remote.RemoteScimUserProvisioning.java
@Override public ScimUser delete(String id, int version) throws ScimResourceNotFoundException { HttpHeaders headers = new HttpHeaders(); headers.set("If-Match", String.format("%d", version)); return restTemplate.exchange(baseUrl + "/User/{id}", HttpMethod.DELETE, new HttpEntity<Void>(headers), ScimUser.class, id).getBody(); }
From source file:se.vgregion.alfrescoclient.service.AlfrescoService.java
/** * Sets up the Http request entity./*from w ww . ja v a2 s .c o m*/ * * @param ssoUser user id for the user that the API calls should performed as. * @return Http entity */ private HttpEntity<String> setUpHttpEntity(String ssoUser) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(ssoUserHeaderField, ssoUser); HttpEntity<String> httpEntity = new HttpEntity<String>(httpHeaders); return httpEntity; }
From source file:sample.RestTests.java
private <T> ResponseEntity<T> getForUser(String resourceUrl, HttpHeaders headers, Class<T> type) { return this.restTemplate.exchange(resourceUrl, HttpMethod.GET, new HttpEntity<T>(headers), type); }
From source file:org.openbaton.nse.beans.connectivitymanageragent.ConnectivityManagerRequestor.java
public Server getServerData(String hypervisorName, String serverName) { logger.debug("Getting data for server " + serverName + " that belong to " + hypervisorName); String url = configuration.getBaseUrl() + "/server/" + hypervisorName + "/" + serverName; HttpHeaders headers = new HttpHeaders(); HttpEntity<String> getEntity = new HttpEntity<>(headers); ResponseEntity<String> server = template.exchange(url, HttpMethod.GET, getEntity, String.class); logger.debug("Setting of QoS has produced http status:" + server.getStatusCode() + " with body: " + server.getBody());// w w w.ja v a 2 s .co m if (!server.getStatusCode().is2xxSuccessful()) { return null; } else { Server result = mapper.fromJson(server.getBody(), Server.class); logger.debug("Request produced " + server.getStatusCode() + " with data " + mapper.toJson(result, Server.class)); return result; } }
From source file:org.cloudfoundry.identity.uaa.integration.VmcScimUserEndpointIntegrationTests.java
@SuppressWarnings("rawtypes") private ResponseEntity<Map> deleteUser(RestOperations client, String id, int version) { HttpHeaders headers = new HttpHeaders(); headers.add("If-Match", "\"" + version + "\""); return client.exchange(serverRunning.getUrl(usersEndpoint + "/{id}"), HttpMethod.DELETE, new HttpEntity<Void>(headers), Map.class, id); }
From source file:com.acc.test.ProductWebServiceTest.java
@Test() public void testGetProductByCode_Success_XML_Deep() { final HttpEntity<String> requestEntity = new HttpEntity<String>(getXMLHeaders()); final ResponseEntity<ProductData> response = template.exchange(URL + "/{code}", HttpMethod.GET, requestEntity, ProductData.class, TestConstants.PRODUCT_CODE); final ProductData productData = response.getBody(); assertEquals(TestConstants.PRODUCT_CODE, productData.getCode()); assertEquals("EASYSHARE V1253, Black", productData.getName()); assertEquals(5, productData.getImages().size()); }
From source file:com.aktios.appthree.server.service.OAuthAuthenticationService.java
public String getAuthorizationCode(String accessTokenA, String redirectUri, String appTokenClientTwo) { RestOperations rest = new RestTemplate(); HttpHeaders headersA = new HttpHeaders(); headersA.set("Authorization", "Bearer " + accessTokenA); ResponseEntity<String> resAuth2 = rest.exchange( MessageFormat.format( "{0}/oauth/authorize?" + "client_id={1}&response_type=code&redirect_uri={2}&scope=read,write", oauthServerBaseURL, appTokenClientTwo, redirectUri), HttpMethod.GET, new HttpEntity<String>(headersA), String.class); String sessionId = resAuth2.getHeaders().get("Set-Cookie").get(0); int p1 = sessionId.indexOf("=") + 1; int p2 = sessionId.indexOf(";"); sessionId = sessionId.substring(p1, p2); headersA.add("Cookie", "JSESSIONID=" + sessionId); resAuth2 = rest.exchange(/*from www .j a v a 2 s . c o m*/ MessageFormat.format("{0}/oauth/authorize?" + "user_oauth_approval=true&authorize=Authorize", oauthServerBaseURL), HttpMethod.POST, new HttpEntity<String>(headersA), String.class); String code = resAuth2.getHeaders().get("location").get(0); p1 = code.lastIndexOf("=") + 1; code = code.substring(p1); return code; }
From source file:com.iata.ndc.trial.controllers.DefaultController.java
@RequestMapping(value = "/sita", method = RequestMethod.GET) public String getSita() { RestTemplate restTemplate = new RestTemplate(); List<HttpMessageConverter<?>> converters = new ArrayList<>(); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.getObjectMapper().configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); converters.add(converter);/* ww w .j a v a 2 s. c o m*/ restTemplate.setMessageConverters(converters); HttpHeaders headers = new HttpHeaders(); headers.add("client-key", "zmd9apqgg2jwekf8zgqg5ybf"); headers.setContentType(MediaType.APPLICATION_JSON); ResponseEntity<BALocationsResponseWrapper> baLocationsResponse = restTemplate.exchange( "https://api.ba.com/rest-v1/v1/balocations", HttpMethod.GET, new HttpEntity<Object>(headers), BALocationsResponseWrapper.class); System.out.println(baLocationsResponse.getBody().getGetBALocationsResponse().getCountry().size()); return "index"; }
From source file:com.keithandthegirl.services.download.DownloadService.java
public DownloadService() { super("DownloadService"); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAcceptEncoding(Collections.singletonList(ContentCodingType.GZIP)); entity = new HttpEntity<Object>(requestHeaders); }
From source file:org.client.one.service.OAuthAuthenticationService.java
public Profile getCurrentUserProfile(String token) throws JSONException { RestOperations rest = new RestTemplate(); HttpHeaders headersA = new HttpHeaders(); headersA.set("Authorization", "Bearer " + token); ResponseEntity<String> responseA = rest.exchange(oauthServerBaseURL + "/resources/profile/read", HttpMethod.GET, new HttpEntity<String>(headersA), String.class); JSONObject profile = new JSONObject(responseA.getBody()); profile = profile.getJSONObject("profile"); Profile u = new Profile(); u.setFirstName(profile.getString("firstName")); u.setLastName(profile.getString("lastName")); u.setPhoneNumber(profile.getString("phoneNumber")); u.setUsername(profile.getString("username")); return u;/*from ww w. jav a2s. c om*/ }