Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.CommentData


            if (comments != null) {
                StringBuffer commentEmailBuf = new StringBuffer();
                StringBuffer commentContentBuf = new StringBuffer();
                StringBuffer commentNameBuf = new StringBuffer();
                for (Iterator cItr = comments.iterator(); cItr.hasNext();) {
                    CommentData comment = (CommentData) cItr.next();
                    if (comment.getSpam() == null || !comment.getSpam().booleanValue()) {
                        if (comment.getContent() != null) {
                            commentContentBuf.append(comment.getContent());
                            commentContentBuf.append(",");
                        }
                        if (comment.getEmail() != null) {
                            commentEmailBuf.append(comment.getEmail());
                            commentEmailBuf.append(",");
                        }
                        if (comment.getName() != null) {
                            commentNameBuf.append(comment.getName());
                            commentNameBuf.append(",");
                        }
                    }
                }
                commentEmail = commentEmailBuf.toString();
View Full Code Here


        log.debug("Doing comment posting for entry = "+entry.getPermaLink());
       
        // collect input from request params and construct new comment object
        // fields: name, email, url, content, notify
        // TODO: data validation on collected comment data
        CommentData comment = new CommentData();
        comment.setName(commentRequest.getName());
        comment.setEmail(commentRequest.getEmail());
        comment.setUrl(commentRequest.getUrl());
        comment.setContent(commentRequest.getContent());
        comment.setNotify(new Boolean(commentRequest.isNotify()));
        comment.setWeblogEntry(entry);
        comment.setRemoteHost(request.getRemoteHost());
        comment.setPostTime(new Timestamp(System.currentTimeMillis()));
       
        WeblogEntryCommentForm cf = new WeblogEntryCommentForm();
        cf.setData(comment);
       
        // check if site is allowing comments
        if(!RollerRuntimeConfig.getBooleanProperty("users.comments.enabled")) {
            // TODO: i18n
            error = "Comments are disabled for this site.";
       
        // check if weblog and entry are allowing comments
        } else if(!weblog.getAllowComments().booleanValue() ||
                !entry.getCommentsStillAllowed()) {
            // TODO: i18n
            error = "Comments not allowed on this entry";
       
        // make sure comment authentication passed
        } else if(!this.authenticator.authenticate(request)) {
            error = bundle.getString("error.commentAuthFailed");
            log.debug("Comment failed authentication");
        }
       
        // bail now if we have already found an error
        if(error != null) {
            cf.setError(error);
            request.setAttribute("commentForm", cf);
            RequestDispatcher dispatcher = request.getRequestDispatcher(dispatch_url);
            dispatcher.forward(request, response);
            return;
        }
       
       
        if (preview) {
            // TODO: i18n
            message = "This is a comment preview only";
            cf.setPreview(comment);
           
            // If comment contains blacklisted text, warn commenter
            SpamChecker checker = new SpamChecker();
            if (checker.checkComment(comment)) {
                error = bundle.getString("commentServlet.previewMarkedAsSpam");
                log.debug("Comment marked as spam");
            }
            log.debug("Comment is a preview");
           
        } else {
            // If comment contains blacklisted text, mark as spam
            SpamChecker checker = new SpamChecker();
            if (checker.checkComment(comment)) {
                comment.setSpam(Boolean.TRUE);
                error = bundle.getString("commentServlet.commentMarkedAsSpam");
                log.debug("Comment marked as spam");
            }
           
            // If comment moderation is on, set comment as pending
            if (weblog.getCommentModerationRequired()) {
                comment.setPending(Boolean.TRUE);
                comment.setApproved(Boolean.FALSE);
                message = bundle.getString("commentServlet.submittedToModerator");
            } else {
                comment.setPending(Boolean.FALSE);
                comment.setApproved(Boolean.TRUE);
            }
           
            try {
                WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                mgr.saveComment(comment);
View Full Code Here

            }
           
            // Get all the subscribers to this comment thread
            Set subscribers = new TreeSet();
            for (Iterator it = comments.iterator(); it.hasNext();) {
                CommentData comment = (CommentData) it.next();
                if (!StringUtils.isEmpty(comment.getEmail())) {
                    // If user has commented twice,
                    // count the most recent notify setting
                    if (comment.getNotify().booleanValue()) {
                        // only add those with valid email
                        if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
                            subscribers.add(comment.getEmail());
                        }
                    } else {
                        // remove user who doesn't want to be notified
                        subscribers.remove(comment.getEmail());
                    }
                }
            }
           
            // Form array of commenter addrs
View Full Code Here

                    entries.remove(entries.size() - 1);
                }
               
                // wrap the results
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    CommentData comment = (CommentData) it.next();
                    results.add(CommentDataWrapper.wrap(comment));
                }
               
            } catch (Exception e) {
                log.error("ERROR: fetching comment list", e);
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.CommentData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.