@RequestMapping("/detail") public ModelAndView detail( @RequestParam("id") int id, @RequestParam(value = "message", required = false) String message) { ModelAndView result; try { Tutorial tutorial = tutorialService.findOne(id); String requestURI = "tutorial/detail.do?id=" + id; boolean canRegister = tutorialService.canRegister(id); boolean editable = tutorialService.canEdit(id); boolean canComment = commentService.canCommentTutorial(id); result = new ModelAndView("tutorial/detail"); result.addObject("tutorial", tutorial); result.addObject("requestURI", requestURI); result.addObject("canRegister", canRegister); result.addObject("canComment", canComment); result.addObject("editable", editable); if (message != null) { result.addObject("message", message); } } catch (DPNotFoundException e) { result = new ModelAndView("404"); } catch (Throwable e) { result = new ModelAndView("error"); } return result; }
@RequestMapping(value = "/delete", method = RequestMethod.GET) public ModelAndView create(@RequestParam Integer commentId) { ModelAndView result; Comment comment; int commentedEntityId; comment = commentService.findOne(commentId); commentedEntityId = comment.getCommentedEntity().getId(); try { commentService.delete(comment); result = new ModelAndView("redirect:../list.do?commentedEntityId=" + commentedEntityId); result.addObject("messageStatus", "comment.delete.ok"); } catch (Throwable oops) { result = new ModelAndView("redirect:../list.do?commentedEntityId=" + commentedEntityId); result.addObject("messageStatus", "comment.commit.error"); } return result; }