Examples of CommentData


Examples of org.apache.roller.pojos.CommentData

     */
    public void testCommentCRUD() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        CommentData comment = new CommentData();
        comment.setName("test");
        comment.setEmail("test");
        comment.setUrl("test");
        comment.setRemoteHost("foofoo");
        comment.setContent("this is a test comment");
        comment.setPostTime(new java.sql.Timestamp(new java.util.Date().getTime()));
        comment.setWeblogEntry(testEntry);
        comment.setPending(Boolean.FALSE);
        comment.setApproved(Boolean.TRUE);
       
        // create a comment
        mgr.saveComment(comment);
        String id = comment.getId();
        TestUtils.endSession(true);
       
        // make sure comment was created
        comment = null;
        comment = mgr.getComment(id);
        assertNotNull(comment);
        assertEquals("this is a test comment", comment.getContent());
       
        // update a comment
        comment.setContent("testtest");
        mgr.saveComment(comment);
        TestUtils.endSession(true);
       
        // make sure comment was updated
        comment = null;
        comment = mgr.getComment(id);
        assertNotNull(comment);
        assertEquals("testtest", comment.getContent());
       
        // delete a comment
        mgr.removeComment(comment);
        TestUtils.endSession(true);
       
View Full Code Here

Examples of org.apache.roller.pojos.CommentData

       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
        List comments = null;
       
        // we need some comments to play with
        CommentData comment1 = TestUtils.setupComment("comment1", testEntry);
        CommentData comment2 = TestUtils.setupComment("comment2", testEntry);
        CommentData comment3 = TestUtils.setupComment("comment3", testEntry);
        TestUtils.endSession(true);
       
        // get all comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, null, null, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(3, comments.size());
       
        // get all comments for entry
        comments = null;
        comments = mgr.getComments(null, testEntry, null, null, null, null, null, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(3, comments.size());
       
        // make some changes
        comment3.setPending(Boolean.TRUE);
        comment3.setApproved(Boolean.FALSE);
        mgr.saveComment(comment3);
       
        // get pending comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, Boolean.TRUE, null, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(1, comments.size());
       
        // get approved comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, null, Boolean.TRUE, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(2, comments.size());
       
        // get comments with offset
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, null, null, null, false, 1, -1);
        assertNotNull(comments);
        assertEquals(2, comments.size());
       
        // remove test comments
        TestUtils.teardownComment(comment1.getId());
        TestUtils.teardownComment(comment2.getId());
        TestUtils.teardownComment(comment3.getId());
        TestUtils.endSession(true);
    }
View Full Code Here

Examples of org.apache.roller.pojos.CommentData

            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

Examples of org.apache.roller.pojos.CommentData

         */       
        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

Examples of org.apache.roller.pojos.CommentData

        }
       
        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

Examples of org.apache.roller.pojos.CommentData

        }
       
        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

Examples of org.apache.roller.pojos.CommentData

     * 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

Examples of org.apache.roller.pojos.CommentData

     */
    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

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

Examples of org.apache.roller.pojos.CommentData

            boolean verified = true;
           
            if (entry!=null && siteAllows && entry.getCommentsStillAllowed()) {
               
                // Track trackbacks as comments
                CommentData comment = new CommentData();
                comment.setContent("[Trackback] "+trackbackRequest.getExcerpt());
                comment.setName(trackbackRequest.getBlogName());
                comment.setUrl(trackbackRequest.getUrl());
                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
                    LinkbackExtractor linkback = new LinkbackExtractor(
                            comment.getUrl(), URLUtilities.getWeblogEntryURL(weblog, null, entry.getAnchor(), true));
                    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 && weblog.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
                    String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
                    if (rootURL == null || rootURL.trim().length()==0) {
                        rootURL = RequestUtils.serverURL(request) + request.getContextPath();
                    }
                    CommentServlet.sendEmailNotification(comment, rootURL);
                   
                    if(comment.getPending().booleanValue()) {
                        pw.println(this.getSuccessResponse("Trackback submitted to moderator"));
                    } else {
                        pw.println(this.getSuccessResponse("Trackback accepted"));
                    }
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.