Example usage for org.springframework.http HttpMethod GET

List of usage examples for org.springframework.http HttpMethod GET

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod GET.

Prototype

HttpMethod GET

To view the source code for org.springframework.http HttpMethod GET.

Click Source Link

Usage

From source file:net.eusashead.hateoas.response.argumentresolver.EntityController.java

@RequestMapping(method = RequestMethod.OPTIONS)
public ResponseEntity<Entity> options(OptionsResponseBuilder<Entity> builder) {
    return builder.allow(HttpMethod.GET, HttpMethod.HEAD).entity(new Entity("foo")).build();
}

From source file:org.zalando.github.spring.TeamsTemplateTest.java

@Test
public void listTeams() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/teams?per_page=25"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listTeams.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Team> teamList = teamsTemplate.listTeams("zalando-stups");

    Assertions.assertThat(teamList).isNotNull();
    Assertions.assertThat(teamList.size()).isEqualTo(1);
}

From source file:com.apress.prospringintegration.customadapters.inbound.pollerdriven.StockPollingMessageSource.java

protected Stock getStockInformationFor(final String symbol) {
    String url = String.format(this.stockServiceUrl, symbol);
    Stock stock = restTemplate.execute(url, HttpMethod.GET, null, new ResponseExtractor<Stock>() {
        @Override/*w w  w .  ja v  a 2s.  c  o m*/
        public Stock extractData(ClientHttpResponse clientHttpResponse) throws IOException {
            String fragPattern = String.format(jsonFragmentTemplate, symbol, symbol);
            String bodyAsText = IOUtils.toString(clientHttpResponse.getBody());

            int indexOfMatch = bodyAsText.indexOf(fragPattern);

            if (indexOfMatch != -1) {
                String sectionContainingPrice = bodyAsText.substring(indexOfMatch);
                Matcher matcher = symbolSize.matcher(sectionContainingPrice);

                StringBuilder stringBuilder = new StringBuilder();

                while (matcher.find()) {
                    stringBuilder.append(matcher.group(1)).append(".").append(matcher.group(2));
                }

                String response = stringBuilder.toString();
                Float fl = Float.parseFloat(response);

                return new Stock(symbol, fl);
            }

            return null;
        }
    });

    return stock;
}

From source file:fi.helsinki.opintoni.integration.pagemetadata.SpringPageMetaDataHttpClient.java

@Override
public Optional<String> getPageBody(String pageUrl) {
    Optional<String> pageBody = Optional.empty();
    try {/*from   ww  w . j av  a2 s.  c o m*/
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Lists.newArrayList(MediaType.TEXT_HTML));
        headers.add(USER_AGENT_KEY, USER_AGENT);
        HttpEntity<String> entity = new HttpEntity<>(PARAMETERS_KEY, headers);

        ResponseEntity<String> response = metaDataRestTemplate.exchange(pageUrl, HttpMethod.GET, entity,
                String.class);
        if (response.getStatusCode().equals(HttpStatus.OK)) {
            pageBody = Optional.ofNullable(response.getBody());
        }
    } catch (Exception e) {
    }

    return pageBody;

}

From source file:id.co.teleanjar.ppobws.restclient.RestClientService.java

public User getUser(String username) {
    RestTemplate restTemplate = new RestTemplate();

    //User user = restTemplate.getForObject("http://localhost:8080/ppobws/api/user?username=" + username, User.class);

    String uri = "http://localhost:8080/ppobws/api/user?username=" + username;

    ResponseEntity<User> respEntity = restTemplate.exchange(uri, HttpMethod.GET,
            new HttpEntity<String>(createHeaders("superuser", "passwordku")), User.class);

    return respEntity.getBody();
}

From source file:customer.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/customer/**").hasRole("CUSTOMER_VIEW")
            .antMatchers(HttpMethod.POST, "/api/customer/**").hasRole("CUSTOMER_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/customer/**").hasRole("CUSTOMER_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/customer/**").hasRole("CUSTOMER_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:pl.hycom.jira.plugins.gitlab.integration.dao.CommitRepository.java

@Override
public List<Commit> getNewCommits(ConfigEntity configEntity, int perPage, int pageNumber) {
    HttpEntity<?> requestEntity = new HttpEntity<>(
            new TemplateFactory().getHttpHeaders().setAuth(configEntity.getClientId()).build());
    ResponseEntity<List<Commit>> response = new TemplateFactory().getRestTemplate().exchange(
            configEntity.getLink() + COMMIT_URL, HttpMethod.GET, requestEntity,
            new ParameterizedTypeReference<List<Commit>>() {
            }, configEntity.getLink(), Integer.toString(perPage), Integer.toString(pageNumber));

    return response.getBody();
}

From source file:fi.helsinki.opintoni.server.WebPageServer.java

public void expectMetaDataRequest() {
    server.expect(requestTo(OpenGraphSampleData.URL)).andExpect(method(HttpMethod.GET))
            .andRespond(withSuccess(SampleDataFiles.toText("pagemetadata/document.html"), MediaType.TEXT_HTML));
}

From source file:mynotesrzd.springboot.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/mynotes/**").hasRole("MYNOTES_VIEW")
            .antMatchers(HttpMethod.POST, "/api/mynotes/**").hasRole("MYNOTES_CREATE")
            .antMatchers(HttpMethod.DELETE, "/api/mynotes/**").hasRole("MYNOTES_DELETE")
            .antMatchers(HttpMethod.PUT, "/api/mynotes/**").hasRole("MYNOTES_UPDATE")
            .antMatchers(HttpMethod.GET, "/api/user/**").hasRole("USER_VIEW").antMatchers("/lib/**").permitAll()
            .antMatchers("/scripts/**").permitAll().anyRequest().authenticated().and().formLogin()
            .loginPage("/login.html").defaultSuccessUrl("/").loginProcessingUrl("/login").permitAll().and()
            .logout().permitAll().and().csrf().disable();
}

From source file:org.zalando.github.spring.OrganizationTemplateTest.java

@Test
public void listAllOrganizations() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/organizations?per_page=100"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listOrgas.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Organization> emailList = usersTemplate.listAllOranizations();

    Assertions.assertThat(emailList).isNotNull();
    Assertions.assertThat(emailList.size()).isEqualTo(1);
}