List of usage examples for org.springframework.http HttpMethod GET
HttpMethod GET
To view the source code for org.springframework.http HttpMethod GET.
Click Source Link
From source file:de.zib.gndms.gndmc.AbstractClient.java
/** * Executes a GET on a url, where the request header contains a given user name and workflow id. * // w ww .ja va2 s. co m * @param <T> The body type of the response. * @param clazz The type of the return value. * @param url The url of the request. * @param dn The user name. * @param wid The workflow id. * @return The response as entity. */ protected final <T> ResponseEntity<T> unifiedGet(final Class<T> clazz, final String url, final String dn, final String wid) { return unifiedX(HttpMethod.GET, clazz, null, url, dn, wid); }
From source file:io.pivotal.receptor.client.ReceptorClient.java
@Override public List<DesiredLRPResponse> getDesiredLRPs() { return restTemplate .exchange("{baseUrl}/desired_lrps", HttpMethod.GET, null, DESIRED_LRP_RESPONSE_LIST_TYPE, baseUrl) .getBody();// w ww .j a v a 2s . c om }
From source file:com.haulmont.restapi.idp.IdpAuthController.java
@GetMapping(value = "/v2/idp/token") public ResponseEntity<OAuth2AccessToken> getAccessToken(Principal principal, @RequestParam Map<String, String> parameters, HttpServletRequest request) throws HttpRequestMethodNotSupportedException { if (!allowedRequestMethods.contains(HttpMethod.GET)) { throw new HttpRequestMethodNotSupportedException("GET"); }// www . j a v a2s . c o m return postAccessToken(principal, parameters, request); }
From source file:jp.go.aist.six.util.core.web.spring.Http.java
/** * HTTP GET: Receives the contents from the specified URL and writes them to the given writer. * * @throws HttpException/* ww w.jav a 2s . c o m*/ * when an exceptional condition occurred during the HTTP method execution. */ public static void getTo(final URL from_url, final Writer to_writer, final List<MediaType> accept_media_types) { _LOG_.debug("HTTP GET: from URL=" + from_url + ", accept=" + accept_media_types); AcceptHeaderRequestCallback callback = new AcceptHeaderRequestCallback(accept_media_types); WriterResponseExtractor extractor = new WriterResponseExtractor(to_writer); _execute(from_url, HttpMethod.GET, callback, extractor); }
From source file:com.cemeterylistingswebtest.test.rest.SearchSurnameControllerTest.java
@Test(enabled = false) public void testreadClubById() { String cemeteryID = "2"; HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Cemetery> responseEntity = restTemplate.exchange(URL + "api/SearchSurname/id/" + cemeteryID, HttpMethod.GET, requestEntity, Cemetery.class); Cemetery cemetery = responseEntity.getBody(); Assert.assertNotNull(cemetery);//www . j a va 2s .c om }
From source file:com.tikinou.schedulesdirect.ClientUtils.java
public <R_IMPL extends R, P extends BaseCommandParameter, R extends CommandResult, C extends ParameterizedCommand<P, R>, R_OVER> R_OVER executeRequest( SchedulesDirectClient client, C command, Class<R_IMPL> resultType, Class<R_OVER> resulTypetOverride) { StringBuilder url = new StringBuilder(client.getUrl()); url.append("/").append(command.getEndPoint()); String token = null;// www.ja v a 2 s . c o m if (command.getParameters() instanceof AuthenticatedBaseCommandParameter) token = ((AuthenticatedBaseCommandParameter) command.getParameters()).getToken(); org.springframework.http.HttpMethod httpMethod = null; switch (command.getMethod()) { case GET: Map<String, String> reqParams = command.getParameters().toRequestParameters(); if (reqParams != null) { url.append("?"); int i = 0; for (Map.Entry<String, String> entry : reqParams.entrySet()) { if (i > 0) url.append("&"); url.append(entry.getKey()).append("=").append(entry.getValue()); i++; } } httpMethod = org.springframework.http.HttpMethod.GET; break; case POST: { httpMethod = org.springframework.http.HttpMethod.POST; break; } case PUT: { httpMethod = org.springframework.http.HttpMethod.PUT; break; } case DELETE: { httpMethod = org.springframework.http.HttpMethod.DELETE; break; } } if (resulTypetOverride == null) { ResponseEntity<R_IMPL> res = restTemplate.exchange(url.toString(), httpMethod, getRequestEntity(client.getUserAgent(), command.getParameters(), token), resultType); if (res.getStatusCode() == HttpStatus.OK) { R result = res.getBody(); command.setResults(result); command.setStatus(CommandStatus.SUCCESS); } else { command.setStatus(CommandStatus.FAILURE); } } else { ResponseEntity<R_OVER> res = restTemplate.exchange(url.toString(), httpMethod, getRequestEntity(client.getUserAgent(), command.getParameters(), token), resulTypetOverride); if (res.getStatusCode() == HttpStatus.OK) { command.setStatus(CommandStatus.SUCCESS); } else { command.setStatus(CommandStatus.FAILURE); } return res.getBody(); } return null; }
From source file:org.energyos.espi.thirdparty.repository.impl.UsagePointRESTRepositoryImpl.java
private HttpEntity<String> getUsagePoints(Authorization authorization) { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("Authorization", "Bearer " + authorization.getAccessToken()); @SuppressWarnings({ "rawtypes", "unchecked" }) HttpEntity<?> requestEntity = new HttpEntity(requestHeaders); return template.exchange(authorization.getResourceURI(), HttpMethod.GET, requestEntity, String.class); }
From source file:com.greglturnquist.spring.social.ecobee.api.impl.ThermostatTemplateTest.java
@Test public void testGetThermostatSummary() throws Exception { final Selection selection = Selection.allThermostats(); final String selectionStr = UriUtils.encodeQueryParam(this.getObjectMapper().writeValueAsString(selection), "UTF-8"); mockServer.expect(requestTo("https://api.ecobee.com/1/thermostatSummary?json=" + selectionStr)) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(jsonResource("thermostatSummary"), MediaType.APPLICATION_JSON)); final ThermostatSummary thermostatSummary = ecobee.thermostatOperations().getThermostatSummary(); final List<ThermostatDetails> thermostatDetailsList = thermostatSummary.getParsedRevisionList(); assertThat(thermostatDetailsList.size(), equalTo(thermostatSummary.getThermostatCount())); final ThermostatDetails thermostatDetails1 = thermostatDetailsList.get(0); assertThat(thermostatDetails1.getIdentifier(), equalTo("123456789101")); assertThat(thermostatDetails1.getName(), equalTo("MyStat")); assertThat(thermostatDetails1.isConnected(), equalTo(true)); assertThat(thermostatDetails1.getThermostatRevision(), equalTo("071223012334")); assertThat(thermostatDetails1.getAlertsRevision(), equalTo("080102000000")); assertThat(thermostatDetails1.getRuntimeRevision(), equalTo("080102000000")); assertThat(thermostatDetails1.getIntervalRevision(), equalTo("080102000000")); final ThermostatDetails thermostatDetails2 = thermostatDetailsList.get(1); assertThat(thermostatDetails2.getIdentifier(), equalTo("123456789102")); assertThat(thermostatDetails2.getName(), equalTo("Room12")); assertThat(thermostatDetails2.isConnected(), equalTo(true)); assertThat(thermostatDetails2.getThermostatRevision(), equalTo("071223012334")); assertThat(thermostatDetails2.getAlertsRevision(), equalTo("080102000000")); assertThat(thermostatDetails2.getRuntimeRevision(), equalTo("080102000000")); assertThat(thermostatDetails2.getIntervalRevision(), equalTo("080102000000")); final ThermostatDetails thermostatDetails3 = thermostatDetailsList.get(2); assertThat(thermostatDetails3.getIdentifier(), equalTo("123456789103")); assertThat(thermostatDetails3.getName(), equalTo("")); assertThat(thermostatDetails3.isConnected(), equalTo(false)); assertThat(thermostatDetails3.getThermostatRevision(), equalTo("071223012334")); assertThat(thermostatDetails3.getAlertsRevision(), equalTo("080102000000")); assertThat(thermostatDetails3.getRuntimeRevision(), equalTo("080102000000")); assertThat(thermostatDetails3.getIntervalRevision(), equalTo("080102000000")); }