Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.CommentData


            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


            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

            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

     * Convenience method for creating a comment.
     */
    public static CommentData setupComment(String content, WeblogEntryData entry)
            throws Exception {
       
        CommentData testComment = new CommentData();
        testComment.setName("test");
        testComment.setEmail("test");
        testComment.setUrl("test");
        testComment.setRemoteHost("foofoo");
        testComment.setContent("this is a test comment");
        testComment.setPostTime(new java.sql.Timestamp(new java.util.Date().getTime()));
        testComment.setWeblogEntry(entry);
        testComment.setPending(Boolean.FALSE);
        testComment.setApproved(Boolean.TRUE);
       
        // store testComment
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
        mgr.saveComment(testComment);
       
        // query for object
        CommentData comment = mgr.getComment(testComment.getId());
       
        if(comment == null)
            throw new RollerException("error setting up comment");
       
        return comment;
View Full Code Here

     */
    public static void teardownComment(String id) throws Exception {
       
        // lookup the comment
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
        CommentData comment = mgr.getComment(id);
       
        // remove the comment
        mgr.removeComment(comment);
    }
View Full Code Here

                // need to seperate comments in time
                // it took alot of trial & error to get this working!
                commentCalendar.setTime(now);
                commentCalendar.add(Calendar.HOUR, l);
                now = new Timestamp(commentCalendar.getTime().getTime());
                CommentData comment = new CommentData();
                comment.setWeblogEntry(wd);
                comment.setName("name"+l);
                comment.setEmail("test"+l+"@test.com");
                comment.setContent("This is my comment");
                comment.setPostTime(now);
                comment.setApproved(Boolean.TRUE);
                comment.setPending(Boolean.FALSE);
                comment.setSpam(Boolean.FALSE);
                comment.setNotify(Boolean.FALSE);
                wmgr.saveComment(comment);
                mCommentsCreated.add(comment);
                mLogger.debug("         Created comment ["
                        +comment.getId()+"]"+ comment.getName());
            }
           
            mCalendar.add(Calendar.DATE, -1);
        }
       
View Full Code Here

                boolean siteAllows = website.getAllowComments().booleanValue();
               
                if (entry!=null && siteAllows && entry.getCommentsStillAllowed()) {
                   
                    // Track trackbacks as comments
                    CommentData comment = new CommentData();
                    comment.setContent("[Trackback] "+excerpt);
                    comment.setName(blogName);
                    comment.setUrl(url);
                    comment.setWeblogEntry(entry);
                    comment.setNotify(Boolean.FALSE);
                    comment.setPostTime(new Timestamp(new Date().getTime()));
                   
                    // If comment contains blacklisted text, mark as spam
                    SpamChecker checker = new SpamChecker();
                    if (checker.checkTrackback(comment)) {
                       comment.setSpam(Boolean.TRUE);
                       logger.debug("Trackback blacklisted: "+comment.getUrl());
                       error = "REJECTED: trackback contains spam words";
                    }
                    // Else, if trackback verification is on...
                    else if (RollerRuntimeConfig.getBooleanProperty(
                           "site.trackbackVerification.enabled")) {
                       
                        // ...ensure trackbacker actually links to us
                        RollerContext rctx= RollerContext.getRollerContext();
                        String absurl = rctx.getAbsoluteContextUrl(req);
                        LinkbackExtractor linkback = new LinkbackExtractor(
                            comment.getUrl(), absurl + entry.getPermaLink());
                        if (linkback.getExcerpt() == null) {
                           comment.setPending(Boolean.TRUE);
                           comment.setApproved(Boolean.FALSE);
                           verified = false;
                           // if we can't verify trackback, then reject it
                           error = "REJECTED: trackback failed verification";
                           logger.debug("Trackback failed verification: "+comment.getUrl());
                        }
                    }
                   
                    if (error == null) {
                        // If comment moderation is on, set comment as pending
                        if (verified && website.getCommentModerationRequired()) {
                            comment.setPending(Boolean.TRUE);  
                            comment.setApproved(Boolean.FALSE);
                        } else if (verified) {
                            comment.setPending(Boolean.FALSE);  
                            comment.setApproved(Boolean.TRUE);
                        }

                        // save, commit, send response
                        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                        mgr.saveComment(comment);
                        RollerFactory.getRoller().flush();

                        // Clear all caches associated with comment
                        CacheManager.invalidate(comment);

                        // Send email notifications
                        RollerContext rc = RollerContext.getRollerContext();                               
                        String rootURL = rc.getAbsoluteContextUrl(req);
                        if (rootURL == null || rootURL.trim().length()==0) {
                            rootURL = RequestUtils.serverURL(req) + req.getContextPath();
                        }
                        CommentServlet.sendEmailNotification(comment, rootURL);

                        pw.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
                        pw.println("<response>");
                        pw.println("<error>0</error>");
                        if (comment.getPending().booleanValue()) {
                            pw.println("<message>Trackback sumitted to moderation</message>");
                        } else {
                            pw.println("<message>Trackback accepted</message>");
                        }
                        pw.println("</response>");
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.