@RequestMapping(value = "/person/{personId}", method = RequestMethod.POST) @ResponseBody public Person updatePerson( @PathVariable int personId, @RequestParam(value = "firstname", required = true) String firstname, @RequestParam(value = "lastname", required = true) String lastname, @RequestParam(value = "email", required = true) String email, @RequestParam(value = "description", required = false) String description, @RequestParam(value = "street", required = false) String street, @RequestParam(value = "city", required = false) String city, @RequestParam(value = "state", required = false) String state, @RequestParam(value = "zip", required = false) String zip, @RequestParam(value = "orgId", required = false) Integer orgId) { if (firstname == "" || lastname == "" || email == "") { throw new InvalidParameterException(); } Person person = new Person(firstname, lastname, email); person.setId(personId); person.setDescription(description); Address address = new Address(street, city, state, zip); person.setAddress(address); if (orgId != null) { Organization org = new Organization(); org.setId(orgId); person.setOrg(org); } personService.update(person); return person; }
@RequestMapping(value = "/person/{personId}", method = RequestMethod.DELETE) @ResponseBody public Person deletePerson(@PathVariable int personId) { Person person = new Person(); person.setId(personId); personService.delete(person); return person; }