Examples of WeblogEntryComment


Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

            if (comments != null) {
                StringBuffer commentEmailBuf = new StringBuffer();
                StringBuffer commentContentBuf = new StringBuffer();
                StringBuffer commentNameBuf = new StringBuffer();
                for (Iterator cItr = comments.iterator(); cItr.hasNext();) {
                    WeblogEntryComment comment = (WeblogEntryComment) cItr.next();
                    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();
                commentContent = commentContentBuf.toString();
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

     */
    public void testCommentCRUD() throws Exception {
       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        WeblogEntryComment comment = new WeblogEntryComment();
        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(TestUtils.getManagedWeblogEntry(testEntry));
        comment.setStatus(WeblogEntryComment.APPROVED);
       
        // 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.weblogger.pojos.WeblogEntryComment

        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
        List comments = null;
       
        // we need some comments to play with
        testEntry = TestUtils.getManagedWeblogEntry(testEntry);
        WeblogEntryComment comment1 = TestUtils.setupComment("comment1", testEntry);
        WeblogEntryComment comment2 = TestUtils.setupComment("comment2", testEntry);
        WeblogEntryComment comment3 = TestUtils.setupComment("comment3", testEntry);
        TestUtils.endSession(true);
       
        // get all comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(3, comments.size());
       
        // get all comments for entry
        testEntry = TestUtils.getManagedWeblogEntry(testEntry);
        comments = null;
        comments = mgr.getComments(null, testEntry, null, null, null, null, false, 0, -1);
        assertNotNull(comments);
        assertEquals(3, comments.size());
       
        // make some changes
        comment3 = mgr.getComment(comment3.getId());
        comment3.setStatus(WeblogEntryComment.PENDING);
        mgr.saveComment(comment3);
        TestUtils.endSession(true);
       
        // get pending comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, WeblogEntryComment.PENDING, false, 0, -1);
        assertNotNull(comments);
        assertEquals(1, comments.size());
       
        // get approved comments
        comments = null;
        comments = mgr.getComments(null, null, null, null, null, WeblogEntryComment.APPROVED, false, 0, -1);
        assertNotNull(comments);
        assertEquals(2, comments.size());
       
        // get comments with offset
        comments = null;
        comments = mgr.getComments(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.weblogger.pojos.WeblogEntryComment

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

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

     * Convenience method for creating a comment.
     */
    public static WeblogEntryComment setupComment(String content, WeblogEntry entry)
            throws Exception {
       
        WeblogEntryComment testComment = new WeblogEntryComment();
        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(getManagedWeblogEntry(entry));
        testComment.setStatus(WeblogEntryComment.APPROVED);
       
        // store testComment
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
        mgr.saveComment(testComment);
       
        // flush to db
        WebloggerFactory.getWeblogger().flush();
       
        // query for object
        WeblogEntryComment comment = mgr.getComment(testComment.getId());
       
        if(comment == null)
            throw new WebloggerException("error setting up comment");
       
        return comment;
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

     */
    public static void teardownComment(String id) throws Exception {
       
        // lookup the comment
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
        WeblogEntryComment comment = mgr.getComment(id);
       
        // remove the comment
        mgr.removeComment(comment);
       
        // flush to db
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

                        weblog, null, null, startDate, null, WeblogEntryComment.APPROVED, true, offset, length + 1);
               
                // wrap the results
                int count = 0;
                for (Iterator it = entries.iterator(); it.hasNext();) {
                    WeblogEntryComment comment = (WeblogEntryComment) it.next();
                    if (count++ < length) {
                        results.add(WeblogEntryCommentWrapper.wrap(comment, urlStrategy));
                    } else {
                        more = true;
                    }
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

        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
        WeblogEntryComment comment = new WeblogEntryComment();
        comment.setName(commentRequest.getName());
        comment.setEmail(commentRequest.getEmail());
        comment.setUrl(commentRequest.getUrl());
        comment.setContent(commentRequest.getContent());
        comment.setNotify(Boolean.valueOf(commentRequest.isNotify()));
        comment.setWeblogEntry(entry);
        comment.setRemoteHost(request.getRemoteHost());
        comment.setPostTime(new Timestamp(System.currentTimeMillis()));
       
        // set comment content-type depending on if html is allowed
        if(WebloggerRuntimeConfig.getBooleanProperty("users.comments.htmlenabled")) {
            comment.setContentType("text/html");
        } else {
            comment.setContentType("text/plain");
        }
       
        // set whatever comment plugins are configured
        comment.setPlugins(WebloggerRuntimeConfig.getProperty("users.comments.plugins"));
       
        WeblogEntryCommentForm cf = new WeblogEntryCommentForm();
        cf.setData(comment);
        if (preview) {
            cf.setPreview(comment);
        }
       
        I18nMessages messageUtils = I18nMessages.getMessages(commentRequest.getLocaleInstance());
       
        // check if comments are allowed for this entry
        // this checks site-wide settings, weblog settings, and entry settings
        if(!entry.getCommentsStillAllowed() || !entry.isPublished()) {
            error = messageUtils.getString("comments.disabled");
           
        // if this is a real comment post then authenticate request
        } else if(!preview && !this.authenticator.authenticate(request)) {
            error = messageUtils.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;
        }
       
        int validationScore = commentValidationManager.validateComment(comment, messages);
        log.debug("Comment Validation score: " + validationScore);
       
        if (!preview) {
           
            if (validationScore == 100 && weblog.getCommentModerationRequired()) {
                // Valid comments go into moderation if required
                comment.setStatus(WeblogEntryComment.PENDING);
                message = messageUtils.getString("commentServlet.submittedToModerator");
            } else if (validationScore == 100) {
                // else they're approved
                comment.setStatus(WeblogEntryComment.APPROVED);
                message = messageUtils.getString("commentServlet.commentAccepted");
            } else {
                // Invalid comments are marked as spam
                log.debug("Comment marked as spam");
                comment.setStatus(WeblogEntryComment.SPAM);
                error = messageUtils.getString("commentServlet.commentMarkedAsSpam");
               
                // add specific error messages if they exist
                if(messages.getErrorCount() > 0) {
                    Iterator errors = messages.getErrors();
                    RollerMessage errorKey = null;
                   
                    StringBuilder buf = new StringBuilder();
                    buf.append("<ul>");
                    while(errors.hasNext()) {
                        errorKey = (RollerMessage)errors.next();
                       
                        buf.append("<li>");
                        if(errorKey.getArgs() != null) {
                            buf.append(messageUtils.getString(errorKey.getKey(), errorKey.getArgs()));
                        } else {
                            buf.append(messageUtils.getString(errorKey.getKey()));
                        }
                        buf.append("</li>");
                    }
                    buf.append("</ul>");
                   
                    error += buf.toString();
                }
               
            }
           
            try {              
                if(!WeblogEntryComment.SPAM.equals(comment.getStatus()) ||
                        !WebloggerRuntimeConfig.getBooleanProperty("comments.ignoreSpam.enabled")) {
                   
                    WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
                    mgr.saveComment(comment);
                    WebloggerFactory.getWeblogger().flush();
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

            // check if trackbacks are allowed for this entry
            // this checks site-wide settings, weblog settings, and entry settings
            if (entry != null && entry.getCommentsStillAllowed() && entry.isPublished()) {
               
                // Track trackbacks as comments
                WeblogEntryComment comment = new WeblogEntryComment();
                comment.setContent("[Trackback] "+trackbackRequest.getExcerpt());
                comment.setName(trackbackRequest.getBlogName());
                comment.setUrl(trackbackRequest.getUrl());
                comment.setWeblogEntry(entry);
                comment.setRemoteHost(request.getRemoteHost());
                comment.setNotify(Boolean.FALSE);
                comment.setPostTime(new Timestamp(new Date().getTime()));
               
                // run new trackback through validators
                int validationScore = commentValidationManager.validateComment(comment, messages);
                logger.debug("Comment Validation score: " + validationScore);
               
                if (validationScore == 100 && weblog.getCommentModerationRequired()) {
                    // Valid comments go into moderation if required
                    comment.setStatus(WeblogEntryComment.PENDING);
                } else if (validationScore == 100) {
                    // else they're approved
                    comment.setStatus(WeblogEntryComment.APPROVED);
                } else {
                    // Invalid comments are marked as spam
                    comment.setStatus(WeblogEntryComment.SPAM);
                }
               
                // save, commit, send response
                if(!WeblogEntryComment.SPAM.equals(comment.getStatus()) ||
                        !WebloggerRuntimeConfig.getBooleanProperty("trackbacks.ignoreSpam.enabled")) {
                   
                    WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
                    mgr.saveComment(comment);
                    WebloggerFactory.getWeblogger().flush();
                   
                    // only invalidate the cache if comment isn't moderated
                    if(!weblog.getCommentModerationRequired()) {
                        // Clear all caches associated with comment
                        CacheManager.invalidate(comment);
                    }
                   
                    // Send email notifications
                    MailUtil.sendEmailNotification(comment, messages,
                            I18nMessages.getMessages(trackbackRequest.getLocaleInstance()),
                            validationScore == 100);
                   
                    if(WeblogEntryComment.PENDING.equals(comment.getStatus())) {
                        pw.println(this.getSuccessResponse("Trackback submitted to moderator"));
                    } else {
                        pw.println(this.getSuccessResponse("Trackback accepted"));
                    }
                }
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogEntryComment

    public void testAutoFormatPlugin() {
       
        PluginManager pmgr = WebloggerFactory.getWeblogger().getPluginManager();
       
        // setup test comment
        WeblogEntryComment comment = new WeblogEntryComment();
        comment.setContent(convertLinesStart);
        comment.setPlugins("AutoFormat Plugin");
       
        // reformat
        String output = pmgr.applyCommentPlugins(comment, comment.getContent());
       
        // make sure it turned out how we planned
        assertEquals(convertLinesFormatted, output);       
    }
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.