Example #1
0
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public @ResponseBody String delete(@PathVariable("id") Long id) {
   if (dao.exists(id)) {
     dao.delete(id);
     return "200 OK";
   } else {
     return "ID NOT FOUND : " + id;
   }
 }
Example #2
0
 @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
 public @ResponseBody String update(@PathVariable("id") Long id, @RequestBody Message e) {
   if (dao.exists(id)) {
     dao.save(e);
     return "200 OK";
   } else {
     return create(e);
   }
 }
Example #3
0
 @RequestMapping(method = RequestMethod.POST)
 public @ResponseBody String create(@RequestBody Message e) {
   try {
     dao.save(e);
   } catch (Exception ex) {
     return "Failed: " + ex.getMessage();
   }
   return "200 OK";
 }
Example #4
0
 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
 public @ResponseBody Message read(@PathVariable("id") Long id) {
   return dao.findOne(id);
 }