Package net.sourceforge.pebble.web.view.impl

Examples of net.sourceforge.pebble.web.view.impl.CommentConfirmationView


      // just send back a 404 - this is probably somebody looking for a way
      // to send comment spam ;-)
      log.info("ignoring saveComment with no related blog entry (spam) from " + request.getRemoteAddr());
      return new NotFoundView();
    } else if (!blogEntry.isCommentsEnabled()) {
      return new CommentConfirmationView();
    }

    comment = createComment(request, blogEntry);
    ValidationContext context = validateComment(comment);

    // are we previewing or adding the comment?
    String previewButton = I18n.getMessage(blog, "comment.previewButton");

    ContentDecoratorContext decoratorContext = new ContentDecoratorContext();
    decoratorContext.setView(ContentDecoratorContext.DETAIL_VIEW);
    decoratorContext.setMedia(ContentDecoratorContext.HTML_PAGE);

    Comment decoratedComment = (Comment)comment.clone();
    blog.getContentDecoratorChain().decorate(decoratorContext, decoratedComment);
    getModel().put("decoratedComment", decoratedComment);
    getModel().put("undecoratedComment", comment);
    getModel().put("rememberMe", rememberMe);
    getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
    getModel().put(Constants.COMMENT_KEY, comment);
    request.getSession().setAttribute("rememberMe", request.getParameter("rememberMe"));

    if (submitType == null || submitType.equalsIgnoreCase(previewButton) || context.hasErrors()) {
      return new CommentFormView();
    } else {
      CommentConfirmationStrategy strategy = blog.getCommentConfirmationStrategy();

      Comment clonedComment = (Comment)comment.clone();
      request.getSession().setAttribute(Constants.COMMENT_KEY, comment);

      if (strategy.confirmationRequired(clonedComment)) {
        strategy.setupConfirmation(request);
        return new ConfirmCommentView();
      } else {
        try {
          saveComment(request, response, blogEntry, comment);
          request.getSession().removeAttribute(Constants.COMMENT_KEY);
          return new CommentConfirmationView();
        } catch (BlogServiceException be) {
          log.error(be.getMessage(), be);
          throw new ServletException(be);
        }
      }
View Full Code Here


    if (blogEntry == null) {
      // just send back a 404 - this is probably somebody looking for a way
      // to send comment spam ;-)
      return new NotFoundView();
    } else if (!blogEntry.isCommentsEnabled()) {
      return new CommentConfirmationView();
    }

    ContentDecoratorContext decoratorContext = new ContentDecoratorContext();
    decoratorContext.setView(ContentDecoratorContext.DETAIL_VIEW);
    decoratorContext.setMedia(ContentDecoratorContext.HTML_PAGE);

    Comment decoratedComment = (Comment)comment.clone();
    blog.getContentDecoratorChain().decorate(decoratorContext, decoratedComment);
    getModel().put("decoratedComment", decoratedComment);
    getModel().put("undecoratedComment", comment);
    getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
    getModel().put(Constants.COMMENT_KEY, comment);

    CommentConfirmationStrategy strategy = blog.getCommentConfirmationStrategy();

    Comment clonedComment = (Comment)comment.clone();

    if (strategy.isConfirmed(request)) {
      try {
        saveComment(request, response, blogEntry, comment);
        request.getSession().removeAttribute(Constants.COMMENT_KEY);
        return new CommentConfirmationView();
      } catch (BlogServiceException be) {
        log.error(be.getMessage(), be);
        throw new ServletException(be);
      }
    } else {
View Full Code Here

    } else if (!blogEntry.isPublished() && !(SecurityUtils.isUserAuthorisedForBlog(blog))) {
      // the entry exists, but isn't yet published
      return new NotFoundView();
    } else if (!blogEntry.isCommentsEnabled()) {
      getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
      return new CommentConfirmationView();
    } else {
      getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);

      // is "remember me" set?
      Cookie rememberMe = CookieUtils.getCookie(request.getCookies(), "rememberMe");
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.web.view.impl.CommentConfirmationView

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.