/** * Add a comment to a particular blog entry * * @param author Comment author * @param authorEmail Comment author e-mail * @param authorURL Comment author URL * @param userComment Comment * @param blogCommentsEnabled If comments are enabled or not * @param commentMetaData Metadata for the comment * @param blog {@link Blog} * @param entry {@link Entry} * @param httpServletRequest {@link HttpServletRequest} * @return BlogComment Entry */ private Comment addBlogComment( String author, String authorEmail, String authorURL, String userComment, boolean blogCommentsEnabled, Map commentMetaData, Blog blog, Entry entry, HttpServletRequest httpServletRequest) { Comment comment = null; if (blogCommentsEnabled) { try { comment = _fetcher.newComment(); comment.setBlogEntryId(entry.getId()); comment.setEntry(entry); comment.setAuthor(author); comment.setAuthorEmail(authorEmail); comment.setAuthorURL(authorURL); comment.setComment(userComment); comment.setCommentDate(new Date()); comment.setBlogId(blog.getId()); comment.setIp(httpServletRequest.getRemoteAddr()); if (commentMetaData.containsKey( CommentModerationPlugin.BLOJSOM_COMMENT_MODERATION_PLUGIN_APPROVED) && "true" .equals( commentMetaData.get( CommentModerationPlugin.BLOJSOM_COMMENT_MODERATION_PLUGIN_APPROVED))) { comment.setStatus(ResponseConstants.APPROVED_STATUS); } else { if ("true".equals(blog.getProperty(CommentModerationPlugin.COMMENT_MODERATION_ENABLED))) { comment.setStatus(ResponseConstants.NEW_STATUS); } else { comment.setStatus(ResponseConstants.APPROVED_STATUS); } } comment.setMetaData(commentMetaData); String commentParentID = BlojsomUtils.getRequestValue(COMMENT_PARENT_ID, httpServletRequest); if (!BlojsomUtils.checkNullOrBlank(commentParentID)) { try { comment.setParentId(Integer.valueOf(commentParentID)); } catch (NumberFormatException e) { } } _fetcher.saveComment(blog, comment); } catch (FetcherException e) { if (_logger.isErrorEnabled()) { _logger.error(e); } comment = null; } } return comment; }