/** PUT /telephones -> Updates an existing telephone. */ @RequestMapping( value = "/telephones", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Telephone> updateTelephone(@RequestBody Telephone telephone) throws URISyntaxException { log.debug("REST request to update Telephone : {}", telephone); if (telephone.getId() == null) { return createTelephone(telephone); } Telephone result = telephoneRepository.save(telephone); return ResponseEntity.ok() .headers(HeaderUtil.createEntityUpdateAlert("telephone", telephone.getId().toString())) .body(result); }
/** POST /telephones -> Create a new telephone. */ @RequestMapping( value = "/telephones", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<Telephone> createTelephone(@RequestBody Telephone telephone) throws URISyntaxException { log.debug("REST request to save Telephone : {}", telephone); if (telephone.getId() != null) { return ResponseEntity.badRequest() .header("Failure", "A new telephone cannot already have an ID") .body(null); } Telephone result = telephoneRepository.save(telephone); return ResponseEntity.created(new URI("/api/telephones/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert("telephone", result.getId().toString())) .body(result); }