Examples of WeblogEntryCommentForm


Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

            initData.put("requestParameters", request.getParameterMap());
            initData.put("weblogRequest", pageRequest);
            initData.put("pageContext", pageContext);
           
            // if this was a comment posting, check for comment form
            WeblogEntryCommentForm commentForm =
                    (WeblogEntryCommentForm) request.getAttribute("commentForm");
            if(commentForm != null) {
                initData.put("commentForm", commentForm);
            }
           
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

        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 comments are allowed for this entry
        // this checks site-wide settings, weblog settings, and entry settings
        if(!entry.getCommentsStillAllowed() || !entry.isPublished()) {
            error = bundle.getString("comments.disabled");
       
        // 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);
                RollerFactory.getRoller().flush();
               
                // only re-index/invalidate the cache if comment isn't moderated
                if(!weblog.getCommentModerationRequired()) {
                    reindexEntry(entry);
                   
                    // 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();
                }
                sendEmailNotification(comment, rootURL);
               
                // comment was successful, clear the comment form
                cf = new WeblogEntryCommentForm();
               
            } catch (RollerException re) {
                log.error("Error saving comment", re);
                error = re.getMessage();
            }
        }
       

        // the work has been done, now send the user back to the entry page
        if (error != null)
            cf.setError(error);
        if (message != null)
            cf.setMessage(message);
        request.setAttribute("commentForm", cf);
       
        log.debug("comment processed, forwarding to "+dispatch_url);
        RequestDispatcher dispatcher =
                request.getRequestDispatcher(dispatch_url);
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

        ctx.put("isCommentPage",     Boolean.TRUE);
        ctx.put("escapeHtml",        new Boolean(escapeHtml) );
        ctx.put("autoformat",        new Boolean(autoFormat) );
       
        // Make sure comment form object is available in context
        WeblogEntryCommentForm commentForm =
                (WeblogEntryCommentForm) request.getAttribute("commentForm");
        if ( commentForm == null ) {
            commentForm = new WeblogEntryCommentForm();
           
            // Set fields to spaces to please Velocity
            commentForm.setName("");
            commentForm.setEmail("");
            commentForm.setUrl("");
            commentForm.setContent("");
        }
        ctx.put("commentForm",commentForm);
       
        // Either put a preview comment in to context
        if(commentForm.isPreview()) {
            ArrayList list = new ArrayList();
            list.add(commentForm.getPreviewComment());
            ctx.put("previewComments", list);
        }
       
        if (entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
            ctx.put("entry", WeblogEntryDataWrapper.wrap(entry));
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

     * @return Comment form object
     */
    public WeblogEntryCommentForm getCommentForm() {
       
        if(commentForm == null) {
            commentForm = new WeblogEntryCommentForm();
        }
        return commentForm;
    }
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

        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);
                RollerFactory.getRoller().flush();
               
                reindexEntry(entry);
               
                // 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();
                }
                sendEmailNotification(comment, rootURL);
               
                // comment was successful, clear the comment form
                cf = new WeblogEntryCommentForm();
               
            } catch (RollerException re) {
                log.error("Error saving comment", re);
                error = re.getMessage();
            }
        }
       

        // the work has been done, now send the user back to the entry page
        if (error != null)
            cf.setError(error);
        if (message != null)
            cf.setMessage(message);
        request.setAttribute("commentForm", cf);
       
        log.debug("comment processed, forwarding to "+dispatch_url);
        RequestDispatcher dispatcher =
                request.getRequestDispatcher(dispatch_url);
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

            initData.put("requestParameters", request.getParameterMap());
            initData.put("weblogRequest", pageRequest);
            initData.put("pageContext", pageContext);
           
            // if this was a comment posting, check for comment form
            WeblogEntryCommentForm commentForm =
                    (WeblogEntryCommentForm) request.getAttribute("commentForm");
            if(commentForm != null) {
                initData.put("commentForm", commentForm);
            }
           
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

     * @return Comment form object
     */
    public WeblogEntryCommentForm getCommentForm() {
       
        if(commentForm == null) {
            commentForm = new WeblogEntryCommentForm();
        }
        return commentForm;
    }
View Full Code Here

Examples of org.apache.roller.ui.rendering.util.WeblogEntryCommentForm

        ctx.put("isCommentPage",     Boolean.TRUE);
        ctx.put("escapeHtml",        new Boolean(escapeHtml) );
        ctx.put("autoformat",        new Boolean(autoFormat) );
       
        // Make sure comment form object is available in context
        WeblogEntryCommentForm commentForm =
                (WeblogEntryCommentForm) request.getAttribute("commentForm");
        if ( commentForm == null ) {
            commentForm = new WeblogEntryCommentForm();
           
            // Set fields to spaces to please Velocity
            commentForm.setName("");
            commentForm.setEmail("");
            commentForm.setUrl("");
            commentForm.setContent("");
        }
        ctx.put("commentForm",commentForm);
       
        // Either put a preview comment in to context
        if(commentForm.isPreview()) {
            ArrayList list = new ArrayList();
            list.add(commentForm.getPreviewComment());
            ctx.put("previewComments", list);
        }
       
        if (entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
            ctx.put("entry", WeblogEntryDataWrapper.wrap(entry));
View Full Code Here

Examples of org.apache.roller.weblogger.ui.rendering.util.WeblogEntryCommentForm

        }
       
        // 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;
                   
                    StringBuffer buf = new StringBuffer();
                    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")) {
                   
                    WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
                    mgr.saveComment(comment);
                    WebloggerFactory.getWeblogger().flush();
                   
                    // Send email notifications only to subscribers if comment is 100% valid
                    boolean notifySubscribers = (validationScore == 100);
                    MailUtil.sendEmailNotification(comment, messages, messageUtils, notifySubscribers);
                   
                    // only re-index/invalidate the cache if comment isn't moderated
                    if(!weblog.getCommentModerationRequired()) {
                        IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
                       
                        // remove entry before (re)adding it, or in case it isn't Published
                        manager.removeEntryIndexOperation(entry);
                       
                        // if published, index the entry
                        if (entry.isPublished()) {
                            manager.addEntryIndexOperation(entry);
                        }
                       
                        // Clear all caches associated with comment
                        CacheManager.invalidate(comment);
                    }
                   
                    // comment was successful, clear the comment form
                    cf = new WeblogEntryCommentForm();
                }
               
            } catch (WebloggerException re) {
                log.error("Error saving comment", re);
                error = re.getMessage();
            }
        }
       
       
        // the work has been done, now send the user back to the entry page
        if (error != null) {
            cf.setError(error);
        }
        if (message != null) {
            cf.setMessage(message);
        }
        request.setAttribute("commentForm", cf);
       
        log.debug("comment processed, forwarding to "+dispatch_url);
        RequestDispatcher dispatcher =
View Full Code Here

Examples of org.apache.roller.weblogger.ui.rendering.util.WeblogEntryCommentForm

            // define url strategy
            initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy());

            // if this was a comment posting, check for comment form
            WeblogEntryCommentForm commentForm = (WeblogEntryCommentForm) request.getAttribute("commentForm");
            if (commentForm != null) {
                initData.put("commentForm", commentForm);
            }

            // Load models for pages
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.