| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  |  | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  |  | 
            
  
    | 19 |  |  | 
            
  
    | 20 |  |  | 
            
  
    | 21 |  |  | 
            
  
    | 22 |  |  | 
            
  
    | 23 |  |  | 
            
  
    | 24 |  |  | 
            
  
    | 25 |  |  | 
            
  
    | 26 |  |  | 
            
  
    | 27 |  |  | 
            
  
    | 28 |  |  | 
            
  
    | 29 |  |  | 
            
  
    | 30 |  |  | 
            
  
    | 31 |  |  | 
            
  
    | 32 |  | package net.sourceforge.pebble.web.action; | 
            
  
    | 33 |  |  | 
            
  
    | 34 |  | import net.sourceforge.pebble.Constants; | 
            
  
    | 35 |  | import net.sourceforge.pebble.api.decorator.ContentDecoratorContext; | 
            
  
    | 36 |  | import net.sourceforge.pebble.domain.*; | 
            
  
    | 37 |  | import net.sourceforge.pebble.util.CookieUtils; | 
            
  
    | 38 |  | import net.sourceforge.pebble.util.SecurityUtils; | 
            
  
    | 39 |  | import net.sourceforge.pebble.web.view.NotFoundView; | 
            
  
    | 40 |  | import net.sourceforge.pebble.web.view.View; | 
            
  
    | 41 |  | import net.sourceforge.pebble.web.view.impl.CommentConfirmationView; | 
            
  
    | 42 |  | import net.sourceforge.pebble.web.view.impl.CommentFormView; | 
            
  
    | 43 |  | import org.apache.commons.logging.Log; | 
            
  
    | 44 |  | import org.apache.commons.logging.LogFactory; | 
            
  
    | 45 |  |  | 
            
  
    | 46 |  | import javax.servlet.ServletException; | 
            
  
    | 47 |  | import javax.servlet.http.Cookie; | 
            
  
    | 48 |  | import javax.servlet.http.HttpServletRequest; | 
            
  
    | 49 |  | import javax.servlet.http.HttpServletResponse; | 
            
  
    | 50 |  |  | 
            
  
    | 51 |  |  | 
            
  
    | 52 |  |  | 
            
  
    | 53 |  |  | 
            
  
    | 54 |  | @author | 
            
  
    | 55 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 46 (46) | Complexity: 10 | Complexity Density: 0,3 |  | 
  
  
    | 56 |  | public class ReplyToBlogEntryAction extends AbstractCommentAction { | 
            
  
    | 57 |  |  | 
            
  
    | 58 |  |  | 
            
  
    | 59 |  | private static final Log log = LogFactory.getLog(ViewBlogEntryAction.class); | 
            
  
    | 60 |  |  | 
            
  
    | 61 |  |  | 
            
  
    | 62 |  |  | 
            
  
    | 63 |  |  | 
            
  
    | 64 |  | @param | 
            
  
    | 65 |  | @param | 
            
  
    | 66 |  | @return | 
            
  
    | 67 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 45 (45) | Complexity: 10 | Complexity Density: 0,3 |  | 
  
  
    | 68 | 0 |  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {... | 
            
  
    | 69 | 0 | Blog blog = (Blog)getModel().get(Constants.BLOG_KEY); | 
            
  
    | 70 | 0 | String entryId = request.getParameter("entry"); | 
            
  
    | 71 |  |  | 
            
  
    | 72 | 0 | BlogService service = new BlogService(); | 
            
  
    | 73 | 0 | BlogEntry blogEntry = null; | 
            
  
    | 74 | 0 | if (entryId != null) { | 
            
  
    | 75 | 0 | try { | 
            
  
    | 76 | 0 | blogEntry = service.getBlogEntry(blog, entryId); | 
            
  
    | 77 |  | } catch (BlogServiceException e) { | 
            
  
    | 78 | 0 | throw new ServletException(e); | 
            
  
    | 79 |  | } | 
            
  
    | 80 |  | } | 
            
  
    | 81 |  |  | 
            
  
    | 82 | 0 | if (blogEntry == null) { | 
            
  
    | 83 |  |  | 
            
  
    | 84 |  |  | 
            
  
    | 85 |  |  | 
            
  
    | 86 | 0 | return new NotFoundView(); | 
            
  
    | 87 | 0 | } else if (!blogEntry.isPublished() && !(SecurityUtils.isUserAuthorisedForBlog(blog))) { | 
            
  
    | 88 |  |  | 
            
  
    | 89 | 0 | return new NotFoundView(); | 
            
  
    | 90 | 0 | } else if (!blogEntry.isCommentsEnabled()) { | 
            
  
    | 91 | 0 | getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry); | 
            
  
    | 92 | 0 | return new CommentConfirmationView(); | 
            
  
    | 93 |  | } else { | 
            
  
    | 94 | 0 | getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry); | 
            
  
    | 95 |  |  | 
            
  
    | 96 |  |  | 
            
  
    | 97 | 0 | Cookie rememberMe = CookieUtils.getCookie(request.getCookies(), "rememberMe"); | 
            
  
    | 98 | 0 | if (rememberMe != null) { | 
            
  
    | 99 | 0 | getModel().put("rememberMe", "true"); | 
            
  
    | 100 |  | } | 
            
  
    | 101 |  |  | 
            
  
    | 102 | 0 | ContentDecoratorContext decoratorContext = new ContentDecoratorContext(); | 
            
  
    | 103 | 0 | decoratorContext.setView(ContentDecoratorContext.DETAIL_VIEW); | 
            
  
    | 104 | 0 | decoratorContext.setMedia(ContentDecoratorContext.HTML_PAGE); | 
            
  
    | 105 | 0 | Comment comment = createBlankComment(blog, blogEntry, request); | 
            
  
    | 106 | 0 | Comment decoratedComment = (Comment)comment.clone(); | 
            
  
    | 107 | 0 | blog.getContentDecoratorChain().decorate(decoratorContext, decoratedComment); | 
            
  
    | 108 | 0 | getModel().put("decoratedComment", decoratedComment); | 
            
  
    | 109 | 0 | getModel().put("undecoratedComment", comment); | 
            
  
    | 110 |  |  | 
            
  
    | 111 |  |  | 
            
  
    | 112 | 0 | String parentCommentId = request.getParameter("comment"); | 
            
  
    | 113 | 0 | if (parentCommentId != null && parentCommentId.length() > 0) { | 
            
  
    | 114 | 0 | Comment parentComment = blogEntry.getComment(Long.parseLong(parentCommentId)); | 
            
  
    | 115 | 0 | blog.getContentDecoratorChain().decorate(decoratorContext, parentComment); | 
            
  
    | 116 | 0 | getModel().put("parentComment", parentComment); | 
            
  
    | 117 |  | } | 
            
  
    | 118 |  |  | 
            
  
    | 119 | 0 | return new CommentFormView(); | 
            
  
    | 120 |  | } | 
            
  
    | 121 |  | } | 
            
  
    | 122 |  |  | 
            
  
    | 123 |  | } |