List of usage examples for org.springframework.http HttpHeaders HttpHeaders
public HttpHeaders()
From source file:monkeys.web.BananasController.java
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<Banana>> getAllBananas() { List<Banana> monkeyList = (List<Banana>) bananaRepository.findAll(); HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(monkeyList, headers, HttpStatus.OK); }
From source file:com.opensearchserver.hadse.cluster.ClusterTest.java
@Test public void t01_get() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); RestTemplate template = new RestTemplate(); ResponseEntity<NodeItem[]> entity = template.exchange("http://localhost:8080/_cluster", HttpMethod.GET, null, NodeItem[].class); assertTrue(entity.getBody().length >= 1); assertEquals(HttpStatus.OK, entity.getStatusCode()); }
From source file:edu.infsci2560.services.BlogsService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Blog>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:edu.fing.tagsi.db4o.business.TrackingController.java
public void Registrar(Envio envio) { RestTemplate restTemplate = new RestTemplate(); RequestTrackingAddPackage req = new RequestTrackingAddPackage(envio.getId().toString(), envio.getCliente().getId().toString(), envio.getDestino().getId().toString(), envio.getFechaEnvio(), false);//from w w w. ja va2 s. c o m HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<RequestTrackingAddPackage> entity = new HttpEntity<>(req, headers); restTemplate.postForObject(ConfigController.getInstance().getURLAddTracking(), entity, void.class); }
From source file:edu.infsci2560.services.FriendService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Friend>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:com.recursivechaos.clearent.service.ClearentService.java
public Transaction postTransaction(Transaction transaction) { RestTemplate restTemplate = new RestTemplate(); ResponseEntity<Response> responseEntity; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.set("api-key", gatewayProperties.getKey()); HttpEntity<String> request = new HttpEntity<>(transaction.toString(), headers); try {/* w w w . j ava 2 s. c om*/ responseEntity = restTemplate.postForEntity(gatewayProperties.getUrl() + "/transactions", request, Response.class); } catch (HttpClientErrorException he) { logger.error("Gateway Request Failed: {}", he.getLocalizedMessage()); logger.error(he.getResponseBodyAsString()); throw new GatewayException(he.getLocalizedMessage()); } assert responseEntity != null; return responseEntity.getBody().getPayload().getTransaction(); }
From source file:edu.infsci2560.services.DvdsService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Dvd>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.BookService.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Iterable<Book>> list() { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findAll(), headers, HttpStatus.OK); }
From source file:org.jnrain.mobile.accounts.kbs.KBSLogoutRequest.java
@Override public SimpleReturnCode loadDataFromNetwork() throws Exception { MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(); // request body intentionally empty HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpEntity<MultiValueMap<String, String>> req = new HttpEntity<MultiValueMap<String, String>>(params, headers);//from ww w. j ava 2 s. c o m return getRestTemplate().postForObject( /* "http://rhymin.jnrain.com/api/logout/", */ "http://bbs.jnrain.com/rainstyle/apilogout.php", req, SimpleReturnCode.class); }
From source file:com.opensearchserver.hadse.index.IndexTest.java
@Test public void t01_deleteIndex() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); RestTemplate template = new RestTemplate(); ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.DELETE, null, String.class); assertNotNull(entity);//from ww w . ja v a 2 s . c o m HttpStatus res = entity.getStatusCode(); assertNotNull(res); switch (res) { case OK: assertEquals(HttpStatus.OK, res); break; case NOT_FOUND: assertEquals(HttpStatus.NOT_FOUND, res); break; default: fail("Unexpected result: " + res); break; } }