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:com.vinidsl.googleioextended.rest.BaseGet.java
@Override public T performRequest() { HttpEntity<T> requestEntity = new HttpEntity<>(getHeaders()); RestTemplate restTemplate = getRestTemplate(); ResponseEntity<T> requestResult = restTemplate.exchange(getUrl(), HttpMethod.GET, requestEntity, getResponseClass());//www .ja v a 2 s . c om T result = requestResult.getBody(); return result; }
From source file:com.javiermoreno.springboot.rest.CustomSecurityAdapter.java
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/public/**", "/views/**", "/errores/**").permitAll() .antMatchers(HttpMethod.GET, "/credentials/**").hasRole("USER") .antMatchers(HttpMethod.GET, "/private/**").hasRole("ADMIN") //.access("hasRole('ROLE_ADMIN')") .anyRequest().authenticated().and().httpBasic(); }
From source file:org.openbaton.nfvo.vnfm_reg.impl.sender.RestVnfmSender.java
private String get(String path, String url) { HttpEntity<String> requestEntity = new HttpEntity<>("", headers); ResponseEntity<String> responseEntity = rest.exchange(url + path, HttpMethod.GET, requestEntity, String.class); this.setStatus(responseEntity.getStatusCode()); return responseEntity.getBody(); }
From source file:cz.muni.fi.mushroomhunter.restclient.AllLocationSwingWorker.java
@Override protected List<LocationDto> doInBackground() throws Exception { String plainCreds = RestClient.USER_NAME + ":" + RestClient.PASSWORD; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); HttpEntity<String> request = new HttpEntity<>(headers); RestTemplate restTemplate = new RestTemplate(); ResponseEntity<LocationDto[]> responseEntity = restTemplate.exchange( RestClient.SERVER_URL + "pa165/rest/location/", HttpMethod.GET, request, LocationDto[].class); LocationDto[] locationDtoArray = responseEntity.getBody(); List<LocationDto> locationDtoList = new ArrayList<>(); locationDtoList.addAll(Arrays.asList(locationDtoArray)); return locationDtoList; }
From source file:org.zalando.github.spring.StatusesTemplateTest.java
@Test public void combinedStatuses() throws Exception { mockServer/* w ww . ja va2 s . co m*/ .expect(requestTo("https://api.github.com/repos/zalando-stups/blub/commits/abcdefgh1234567/status")) .andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(jsonResource("combinedStatus"), APPLICATION_JSON)); CombinedStatus status = statusesTemplate.getCombinedStatus("zalando-stups", "blub", "abcdefgh1234567"); Assertions.assertThat(status).isNotNull(); Assertions.assertThat(status.getTotalCount()).isEqualTo(2); Assertions.assertThat(status.getRepository().getId()).isEqualTo(1296269); }
From source file:com.pepaproch.gtswsdlclient.impl.AvailabilityCheckImpl.java
public AvailabilityResponse checkAvailabilityByPhone(String phoneNumber) { URI toUri = new AvailabilityCheckByPhoneQueryBuilderImpl( restContext.getBASE_URL() + AVAILABILITY_CHECK_PATH).buildQuery(phoneNumber).encode().toUri(); ResponseEntity<AvailabilityResponse> response = restContext.getRestTemplate().exchange(toUri, HttpMethod.GET, null, AvailabilityResponse.class); return response.getBody(); }
From source file:org.zalando.github.spring.UsersTemplatePublicKeyTest.java
@Test public void getPublicKeys() throws Exception { mockServer.expect(requestTo("https://api.github.com/user/keys")).andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(new ClassPathResource("listPublicKeys.json", getClass()), MediaType.APPLICATION_JSON)); List<ExtPubKey> publicKeyList = usersTemplate.listPublicKeys(); Assertions.assertThat(publicKeyList).isNotNull(); Assertions.assertThat(publicKeyList.size()).isEqualTo(1); Assertions.assertThat(publicKeyList.get(0).getKey()).isEqualTo("ssh-rsa AAA..."); }
From source file:top.zhacker.ms.reactor.spring.function.Client.java
public void printAllPeople() { URI uri = URI.create(String.format("http://%s:%d/person", Server.HOST, Server.PORT)); ClientRequest request = ClientRequest.method(HttpMethod.GET, uri).build(); Flux<Person> people = exchange.exchange(request).flatMapMany(response -> response.bodyToFlux(Person.class)); Mono<List<Person>> peopleList = people.collectList(); System.out.println(peopleList.block()); }
From source file:com.nobu.dvdrentalweb.test.restapi.MovieRestControllerTest.java
public void readTest() { HttpEntity<?> requestEntity = getHttpEntity(); ResponseEntity<Movie[]> responseEntity = restTemplate.exchange(URL, HttpMethod.GET, requestEntity, Movie[].class); Movie[] movie = responseEntity.getBody(); for (Movie movies : movie) { }//from w w w . ja va2s . c o m }
From source file:com.tenforce.lodms.extractors.views.CkanExtractFieldFactory.java
@Override public Field createField(Item item, Object propertyId, Component uiContext) { if ("baseUri".equals(propertyId)) { TextField uriField = new TextField("CKAN Url"); uriField.setRequired(true);// www .j a v a 2 s . com uriField.setRequiredError("CKAN Url is required!"); uriField.setWidth(350, VerticalLayout.UNITS_PIXELS); uriField.setDescription("Base url of the ckan portal."); uriField.setImmediate(true); uriField.addValidator(new AbstractStringValidator(null) { @Override protected boolean isValidString(String value) { try { new URIImpl(value); return true; } catch (Exception ex) { setErrorMessage("Invalid CKAN Url: " + ex.getMessage()); return false; } } }); return uriField; } else if ("httpMethod".equals(propertyId)) { Select selector = new Select("Http Method"); selector.addItem(HttpMethod.GET); selector.addItem(HttpMethod.POST); return selector; } else if ("publisher".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("The foaf:agent responsible for this catalog."); field.setRequired(true); return field; } else if ("title".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Title for this catalog."); field.setRequired(true); return field; } else if ("license".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("license for this catalog."); field.setRequired(true); return field; } else if ("description".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription("Description for this catalog."); field.setWidth(350, VerticalLayout.UNITS_PIXELS); field.setRequired(true); return field; } else if ("ignoredKeys".equals(propertyId)) { Field field = super.createField(item, propertyId, uiContext); field.setDescription( "A comma seperated list of attributes in the metadata that should be ignored by the extractor."); return field; } else if ("subjectPrefix".equals(propertyId)) { TextField subjectField = new TextField("Subject Prefix"); subjectField.setRequired(true); subjectField.setDescription("This prefix will be used to generate the subject url."); subjectField.setRequiredError("Subject Prefix is required!"); subjectField.setWidth(350, VerticalLayout.UNITS_PIXELS); return subjectField; } else if ("predicatePrefix".equals(propertyId)) { TextField predicateField = new TextField("Predicate Prefix"); predicateField.setRequired(true); predicateField.setDescription( "All json attributes will be prefixed with this string to generate a predicate."); predicateField.setRequiredError("Predicate Prefix is required!"); predicateField.setWidth(350, VerticalLayout.UNITS_PIXELS); return predicateField; } else if ("packageIds".equals(propertyId)) { TwinColSelect select = new TwinColSelect("Select catalog records to harvest"); select.setLeftColumnCaption("Available records"); select.setRightColumnCaption("Selected records"); select.setRows(20); select.setWidth(500, VerticalLayout.UNITS_PIXELS); return select; } else if ("allDatasets".equals(propertyId)) { CheckBox box = new CheckBox("harvest all datasets"); box.setImmediate(true); return box; } return super.createField(item, propertyId, uiContext); }