Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.CommentData


        ctx.put("commentForm",commentForm);
       
        // Either put a preview comment in to context
        if ( request.getAttribute("previewComments")!=null ) {
            ArrayList list = new ArrayList();
            CommentData cd = new CommentData();
            commentForm.copyTo(cd, request.getLocale());
            list.add(CommentDataWrapper.wrap(cd));
            ctx.put("previewComments",list);
        }
       
View Full Code Here


        ArrayList all = new ArrayList();
        ArrayList approvedList = new ArrayList();
        ArrayList spamList = new ArrayList();
        Iterator it = comments.iterator();
        while (it.hasNext()) {
            CommentData comment = (CommentData)it.next();
            all.add(comment.getId());
            if (comment.getApproved().booleanValue()) {
                approvedList.add(comment.getId());
            }           
            if (comment.getSpam().booleanValue()) {
                spamList.add(comment.getId());
            }
        }
        String[] idArray = (String[])all.toArray(
            new String[all.size()]);
        ids = Utilities.stringArrayToString(idArray,",");
View Full Code Here

            WebsiteData website = entry.getWebsite();
           
            // Construct our Comment object from the submitted data
            WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
            CommentFormEx cf = new CommentFormEx();
            CommentData comment = new CommentData();
            RequestUtils.populate(cf, request);
            cf.copyTo(comment, request.getLocale());
           
            comment.setWeblogEntry(entry);
            comment.setRemoteHost(request.getRemoteHost());
            comment.setPostTime(new java.sql.Timestamp(System.currentTimeMillis()));
           
            cf.setWeblogEntry(entry);
            cf.setPostTime(new java.sql.Timestamp(System.currentTimeMillis()));
           
            request.setAttribute("commentForm", cf);
            request.setAttribute("blogEntry", entry);
           
            if (preview) {
                message = "This is a comment preview only";
               
                // If comment contains blacklisted text, warn commenter
                SpamChecker checker = new SpamChecker();
                if (checker.checkComment(comment)) {
                   error = bundle.getString("commentServlet.previewMarkedAsSpam");
                   mLogger.debug("Comment marked as spam");
                }
                request.setAttribute("previewComments", "dummy");
                mLogger.debug("Comment is a preview");
               
            } else {
                if (this.authenticator.authenticate(comment, request)) {
                    mLogger.debug("Comment passed authentication");
                   
                    // 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");
                       mLogger.debug("Comment marked as spam");
                    }
                    
                    // If comment moderation is on, set comment as pending
                    if (website.getCommentModerationRequired()) {
                        comment.setPending(Boolean.TRUE);  
                        comment.setApproved(Boolean.FALSE);
                        //message = bundle.getString("commentServlet.submittedToModerator");
                    } else {
                        comment.setPending(Boolean.FALSE);  
                        comment.setApproved(Boolean.TRUE);
                    }
                   
                    mgr.saveComment(comment);
                    RollerFactory.getRoller().flush();
                    reindexEntry(entry);
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

            if (rses.isGlobalAdminUser()
                || (rreq.getWebsite()!=null && rses.isUserAuthorizedToAuthor(rreq.getWebsite())) ) {
                WeblogManager mgr= RollerFactory.getRoller().getWeblogManager();
               
                // delete all comments with delete box checked
                CommentData deleteComment = null;
                String[] deleteIds = queryForm.getDeleteComments();
                List deletedList = Arrays.asList(deleteIds);
                if (deleteIds != null && deleteIds.length > 0) {
                    for(int j=0; j < deleteIds.length; j++) {
                        deleteComment = mgr.getComment(deleteIds[j]);
                       
                        mgr.removeComment(deleteComment);
                    }
                }
               
                // Collect comments approved for first time, so we can send
                // out comment approved notifications later
                List approvedComments = new ArrayList();
               
                // loop through IDs of all comments displayed on page
                String[] ids = Utilities.stringToStringArray(queryForm.getIds(),",");
                List flushList = new ArrayList();
                for (int i=0; i<ids.length; i++) {                   
                    if (deletedList.contains(ids[i])) continue;                   
                    CommentData comment = mgr.getComment(ids[i]);
                   
                    // apply spam checkbox
                    List spamIds = Arrays.asList(queryForm.getSpamComments());
                    if (spamIds.contains(ids[i])) {
                        comment.setSpam(Boolean.TRUE);
                    } else {
                        comment.setSpam(Boolean.FALSE);
                    }
                   
                    // Only participate in comment review workflow if we're
                    // working within one specfic weblog. Global admins should
                    // be able to mark-as-spam and delete comments without
                    // interfering with moderation by bloggers.
                    if (rreq.getWebsite() != null) {
                       
                        // all comments reviewed, so they're no longer pending
                        if (comment.getPending() != null && comment.getPending().booleanValue()) {
                            comment.setPending(Boolean.FALSE);
                            approvedComments.add(comment);
                        }
                       
                        // apply pending checkbox
                        List approvedIds =
                            Arrays.asList(queryForm.getApprovedComments());
                        if (approvedIds.contains(ids[i])) {
                            comment.setApproved(Boolean.TRUE);
                           
                        } else {
                            comment.setApproved(Boolean.FALSE);
                        }
                    }
                    mgr.saveComment(comment);
                    flushList.add(comment);
                }
View Full Code Here

            List comments = getComments(
                website, entry, searchString, startDate, endDate,
                pending, approved, spam, true, 0, -1);
            int count = 0;
            for (Iterator it = comments.iterator(); it.hasNext();) {
                CommentData comment = (CommentData) it.next();
                removeComment(comment);
                count++;
            }
            return count;
       
View Full Code Here

            return;
        }

        Iterator iter = comments.iterator();
        while (iter.hasNext()) {
            CommentData comment = (CommentData)iter.next();
           
            // Send email notifications because a new comment has been approved
            CommentServlet.sendEmailNotification(comment, rootURL);
           
            // Send approval notification to author of approved comment
View Full Code Here

         */       
        public int getPendingCommentCount() {
            int count = 0;
            if (getWebsite() != null) {
                for (Iterator iter = comments.iterator(); iter.hasNext();) {
                    CommentData cd = (CommentData)iter.next();
                    if (cd.getPending().booleanValue()) count++;
                }
            }
            return count;
        }
View Full Code Here

        }
       
        public Date getEarliestDate() {
            Date date = null;
            if (comments.size() > 0) {
                CommentData earliest = (CommentData)comments.get(comments.size()-1);
                date = earliest.getPostTime();
            }
            return date;
        }
View Full Code Here

        }
       
        public Date getLatestDate() {
            Date date = null;
            if (comments.size() > 0) {
                CommentData latest = (CommentData)comments.get(0);
                date = latest.getPostTime();
            }
            return date;
        }
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.