@RequestParam(value = "previewpicture", required = false) CommonsMultipartFile file)
throws PostControllerException, PostServiceException, ImageConverterException {
ParamUtility.checkStringNotNullOrEmpty(null, type, "type");
ParamUtility.checkNotNull(null, post, "post");
Post originalPost = getPostService().getPost(id);
if (originalPost == null) {
throw new PostControllerException("Cannot find Post with the id: " + id);
}
deletePreviewFile(originalPost);
originalPost.setTitle(post.getTitle());
if (file != null) {
File outputFile = saveFile(file, true);
originalPost.setPreview(outputFile.getName());
}
originalPost.setContent(post.getContent());
originalPost.setModificationDate(new Date());
getPostService().updatePost(originalPost);
return redirectToViewPosts(type);
}