Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.Comment


    }
   
    BlogManager blogMgr = new BlogManager(locale, session);
    String idParam = req.getParameter("id")!=null ? req.getParameter("id") : (String)req.getSession().getAttribute("id");
   
    Comment comment = blogMgr.getComment(Long.parseLong(idParam));
    if (comment == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.CommentNotFound", idParam));
    }
   
    Blog blog = blogMgr.getBlog(comment.getArticle().getBlog().getId());
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!permissions.contains(PermissionManager.READ_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
   
   
    comment.setReviewStatus(newStatus);
    blogMgr.modifyComment(comment);
   
    ActionForward fwd = mapping.findForward("statusChanged");
    ActionForward newFwd = new ActionForward(fwd);
   
    newFwd.setPath(fwd.getPath()+"&id=" + comment.getArticle().getId());
   
    return newFwd;
  }
View Full Code Here


    Set<Long> permissions = getPermissions(article.getBlog(), webUser);
    if (!permissions.contains(PermissionManager.ADD_COMMENT_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }   
    if (f.getContent() != null && f.getContent().trim().length() > 0) {
      Comment comment = blogMgr.addComment(article, f.getContent(), webUser);
      LOGGER.info("User "+UserManagerBase.toString(webUser)+" added comment #"+comment.getId()+" to article #"+article.getId()+" ("+article.getTitle()+") of blog #"+article.getBlog().getId()+" ("+article.getBlog().getName()+")");
    }
    ActionForward fwd = injectId(mapping.findForward("view"), f.getArticleId());
    return fwd;
  }
View Full Code Here

    if (webUser == null){
      throw new InputException(getResources(req).getMessage(locale, "blog.AnonymousEditingNotAllowed"));
    }
    BlogManager blogMgr = new BlogManager(locale, session);
    String idParam = req.getParameter("id");
    Comment comment = blogMgr.getComment(Long.parseLong(idParam));
    if (comment == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.CommentNotFound", idParam));
    }
    Set<Long> permissions = getPermissions(comment.getArticle().getBlog(), webUser);
    if (!permissions.contains(PermissionManager.WRITE_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    Long id = comment.getArticle().getId();
    blogMgr.deleteComment(comment);
    LOGGER.info("User "+UserManagerBase.toString(webUser)+" deleted comment #"+comment.getId()+" ("+comment.getContent()+") of article #"+comment.getArticle().getId()+" ("+comment.getArticle().getTitle()+") of blog #"+comment.getArticle().getBlog().getId()+" ("+comment.getArticle().getBlog().getName()+")");   
    return injectId(mapping.findForward("deleted"), id);
 
View Full Code Here

 
  // true if at least one comment of the article is blacklisted
  private boolean isACommentBlocked(Article a){
    Set<Comment> comments = a.getComments();
    for (Iterator iterator = comments.iterator(); iterator.hasNext();) {
      Comment comment = (Comment) iterator.next();
      if (comment.getReviewStatus() == BLOCKED){
        return true;
      }
    }
    return false;
  }
View Full Code Here

 
  // true if at all comment of the article is not reviewed
  private boolean isACommentNotReviewed(Article a){
    Set<Comment> comments = a.getComments();
    for (Iterator iterator = comments.iterator(); iterator.hasNext();) {
      Comment comment = (Comment) iterator.next();
      if (comment.getReviewStatus() == NOT_REVIEWED){
        return true;
      }
    }
    return false;
  }
View Full Code Here

 
  // true if at least one comment of the article is  released
  private boolean allCommentsReleased(Article a){
    Set<Comment> comments = a.getComments();
    for (Iterator iterator = comments.iterator(); iterator.hasNext();) {
      Comment comment = (Comment) iterator.next();
      if (comment.getReviewStatus() != RELEASED){
        return false;
      }
    }
    return true;
  }
View Full Code Here

    crit.add(Restrictions.eq("id", id));
    return (Comment)crit.uniqueResult();   
  }
 
  public Comment addComment(Article article, String content, User author) {
    Comment comment = new Comment();
    comment.setContent(content);
    comment.setAuthor(author);
    comment.setCreatedAt(new Date());
    comment.setArticle(article);
    session.saveOrUpdate(comment);
    article.getComments().add(comment);
    session.saveOrUpdate(article);
    return comment;
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.blog.datamodel.Comment

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.