* @throws NotFoundException when topic, branch or post not found
*/
@RequestMapping(value = "/posts/{postId}/edit", method = RequestMethod.POST)
public ModelAndView update(@Valid @ModelAttribute PostDto postDto, BindingResult result,
@PathVariable(POST_ID) Long postId) throws NotFoundException {
Post post = postService.get(postId);
if (result.hasErrors()) {
return new ModelAndView("topic/editPost")
.addObject(TOPIC_ID, post.getTopic().getId())
.addObject(POST_ID, postId);
}
postService.updatePost(post, postDto.getBodyText());
return new ModelAndView("redirect:/posts/" + postId);
}