/** * POST /addresses { "text": "text of the address" } * * <p>Creates a new address. * * @param json * @return json containing the id of the newly created address */ @RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json") public ResponseEntity<String> createFromJson(@RequestBody String json) { Address createdAddress = addresses.save(Address.fromJsonToAddress(json)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/text"); return new ResponseEntity<String>( "{\"id\":" + createdAddress.getId() + "}", headers, HttpStatus.CREATED); }
/** * PUT /addresses/ { "id": id, "title": "text of address", idDone: true|false } * * <p>Updates an existing address. * * @param json full json representation of the address to update * @return */ @RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json") public ResponseEntity<String> updateFromJson(@RequestBody String json) { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/text"); if (addresses.save(Address.fromJsonToAddress(json)) == null) { return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND); } return new ResponseEntity<String>(headers, HttpStatus.OK); }