Examples of WeblogEntryComment


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

            throws ServletException, IOException {
       
        Weblogger roller = WebloggerFactory.getWeblogger();
        try {
            WeblogManager wmgr = roller.getWeblogManager();
            WeblogEntryComment c = wmgr.getComment(request.getParameter("id"));
            String content = Utilities.escapeHTML(c.getContent());
            content = WordUtils.wrap(content, 72);
            content = StringEscapeUtils.escapeJavaScript(content);
            String json = "{ id: \"" + c.getId() + "\"," + "content: \"" + content + "\" }";
            response.setContentType("text/html; charset=utf-8");
            response.getWriter().print(json);
            response.flushBuffer();
            response.getWriter().flush();
            response.getWriter().close();
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

            // delete all comments with delete box checked
            List<String> deletes = Arrays.asList(getBean().getDeleteComments());
            if(deletes != null && deletes.size() > 0) {
                log.debug("Processing deletes - "+deletes.size());
               
                WeblogEntryComment deleteComment = null;
                for(String deleteId : deletes) {
                    deleteComment = wmgr.getComment(deleteId);
                   
                    // make sure comment is tied to action weblog
                    if(getActionWeblog().equals(deleteComment.getWeblogEntry().getWebsite())) {
                        flushList.add(deleteComment);
                        reindexList.add(deleteComment.getWeblogEntry());
                        wmgr.removeComment(deleteComment);
                    }
                }
            }
           
            // loop through IDs of all comments displayed on page
            List<String> approvedIds = Arrays.asList(getBean().getApprovedComments());
            List<String> spamIds = Arrays.asList(getBean().getSpamComments());
            log.debug(spamIds.size()+" comments marked as spam");
           
            // track comments approved via moderation
            List<WeblogEntryComment> approvedComments = new ArrayList();
           
            String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
            for (int i=0; i < ids.length; i++) {
                log.debug("processing id - "+ ids[i]);
               
                // if we already deleted it then skip forward
                if(deletes.contains(ids[i])) {
                    log.debug("Already deleted, skipping - "+ids[i]);
                    continue;
                }
               
                WeblogEntryComment comment = wmgr.getComment(ids[i]);
               
                // make sure comment is tied to action weblog
                if(getActionWeblog().equals(comment.getWeblogEntry().getWebsite())) {
                    // comment approvals and mark/unmark spam
                    if(approvedIds.contains(ids[i])) {
                        // if a comment was previously PENDING then this is
                        // it's first approval, so track it for notification
                        if(WeblogEntryComment.PENDING.equals(comment.getStatus())) {
                            approvedComments.add(comment);
                        }
                       
                        log.debug("Marking as approved - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.APPROVED);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());
                       
                    } else if(spamIds.contains(ids[i])) {
                        log.debug("Marking as spam - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.SPAM);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());

                    } else if(!WeblogEntryComment.DISAPPROVED.equals(comment.getStatus())) {
                        log.debug("Marking as disapproved - "+comment.getId());
                        comment.setStatus(WeblogEntryComment.DISAPPROVED);
                        wmgr.saveComment(comment);
                       
                        flushList.add(comment);
                        reindexList.add(comment.getWeblogEntry());
                    }
                }
            }
           
            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")) {
                   
                    WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
                    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

            // delete all comments with delete box checked
            List<String> deletes = Arrays.asList(getBean().getDeleteComments());
            if(deletes != null && deletes.size() > 0) {
                log.debug("Processing deletes - "+deletes.size());
               
                WeblogEntryComment deleteComment = null;
                for(String deleteId : deletes) {
                    deleteComment = wmgr.getComment(deleteId);
                    flushList.add(deleteComment.getWeblogEntry().getWebsite());
                    wmgr.removeComment(deleteComment);
                }
            }
           
            // loop through IDs of all comments displayed on page
            List spamIds = Arrays.asList(getBean().getSpamComments());
            log.debug(spamIds.size()+" comments marked as spam");
           
            String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
            for (int i=0; i < ids.length; i++) {
                log.debug("processing id - "+ ids[i]);
               
                // if we already deleted it then skip forward
                if(deletes.contains(ids[i])) {
                    log.debug("Already deleted, skipping - "+ids[i]);
                    continue;
                }
               
                WeblogEntryComment comment = wmgr.getComment(ids[i]);
               
                // mark/unmark spam
                if (spamIds.contains(ids[i]) &&
                        !WeblogEntryComment.SPAM.equals(comment.getStatus())) {
                    log.debug("Marking as spam - "+comment.getId());
                    comment.setStatus(WeblogEntryComment.SPAM);
                    wmgr.saveComment(comment);
                   
                    flushList.add(comment.getWeblogEntry().getWebsite());
                } else if(WeblogEntryComment.SPAM.equals(comment.getStatus())) {
                    log.debug("Marking as approved - "+comment.getId());
                    comment.setStatus(WeblogEntryComment.APPROVED);
                    wmgr.saveComment(comment);
                   
                    flushList.add(comment.getWeblogEntry().getWebsite());
                }
            }
           
            WebloggerFactory.getWeblogger().flush();
           
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(new Boolean(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;
                   
                    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();
View Full Code Here

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

        List<String> allComments = new ArrayList();
        List<String> spamList = new ArrayList();
       
        Iterator it = comments.iterator();
        while (it.hasNext()) {
            WeblogEntryComment comment = (WeblogEntryComment)it.next();
            allComments.add(comment.getId());
           
            if (WeblogEntryComment.SPAM.equals(comment.getStatus())) {
                spamList.add(comment.getId());
            }
        }
       
        String[] idArray = (String[]) allComments.toArray(new String[allComments.size()]);
        this.setIds(Utilities.stringArrayToString(idArray,","));
View Full Code Here

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

            // delete all comments with delete box checked
            List<String> deletes = Arrays.asList(getBean().getDeleteComments());
            if(deletes != null && deletes.size() > 0) {
                log.debug("Processing deletes - "+deletes.size());
               
                WeblogEntryComment deleteComment = null;
                for(String deleteId : deletes) {
                    deleteComment = wmgr.getComment(deleteId);
                    flushList.add(deleteComment.getWeblogEntry().getWebsite());
                    wmgr.removeComment(deleteComment);
                }
            }
           
            // loop through IDs of all comments displayed on page
            List spamIds = Arrays.asList(getBean().getSpamComments());
            log.debug(spamIds.size()+" comments marked as spam");
           
            String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
            for (int i=0; i < ids.length; i++) {
                log.debug("processing id - "+ ids[i]);
               
                // if we already deleted it then skip forward
                if(deletes.contains(ids[i])) {
                    log.debug("Already deleted, skipping - "+ids[i]);
                    continue;
                }
               
                WeblogEntryComment comment = wmgr.getComment(ids[i]);
               
                // mark/unmark spam
                if (spamIds.contains(ids[i]) &&
                        !WeblogEntryComment.SPAM.equals(comment.getStatus())) {
                    log.debug("Marking as spam - "+comment.getId());
                    comment.setStatus(WeblogEntryComment.SPAM);
                    wmgr.saveComment(comment);
                   
                    flushList.add(comment.getWeblogEntry().getWebsite());
                } else if(WeblogEntryComment.SPAM.equals(comment.getStatus())) {
                    log.debug("Marking as approved - "+comment.getId());
                    comment.setStatus(WeblogEntryComment.APPROVED);
                    wmgr.saveComment(comment);
                   
                    flushList.add(comment.getWeblogEntry().getWebsite());
                }
            }
           
            WebloggerFactory.getWeblogger().flush();
           
View Full Code Here

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

      log.debug("Sending notification email to all subscribers");

      // Get all the subscribers to this comment thread
      List comments = entry.getComments(true, true);
      for (Iterator it = comments.iterator(); it.hasNext();) {
        WeblogEntryComment comment = (WeblogEntryComment) it.next();
        if (!StringUtils.isEmpty(comment.getEmail())) {
          // If user has commented twice,
          // count the most recent notify setting
          if (commentObject.getApproved()) {
            if (comment.getNotify().booleanValue()) {
              // only add those with valid email
              if (comment.getEmail().matches(EMAIL_ADDR_REGEXP)) {
                log.info("Add to subscribers list : " + comment.getEmail());
                subscribers.add(comment.getEmail());
              }
            } else {
              // remove user who doesn't want to be notified
              log.info("Remove from subscribers list : " + comment.getEmail());
              subscribers.remove(comment.getEmail());
            }
          }
        }
      }
    } else {
View Full Code Here

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
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.