Package evolaris.framework.blog.business

Examples of evolaris.framework.blog.business.BlogManager


    BlogCommandEntry commandEntry = new BlogCommandEntry();
    Group group = groupFromSession(req);
    checkAccessRights(req, group);
    commandEntry.setGroup(group);
    if (f.getBlogId() > 0) {
      BlogManager blogMgr = new BlogManager(locale, session);
      Blog blog = blogMgr.getBlog(f.getBlogId());
      if (blog == null) {
        throw new InputException(resources.getMessage(locale, "smssvc.selectedBlogNotFound"));
      }
      commandEntry.setBlog(blog);
    } else {
View Full Code Here


    checkAccessRights(req, blogCommandEntry.getGroup());
    commandEntryManager.evict(blogCommandEntry)// do not modify in this session yet (might be erroneous)

    blogCommandEntry.setSortLabel(f.getSortLabel());
    if (f.getBlogId() > 0) {
      BlogManager blogMgr = new BlogManager(locale, session);
      Blog blog = blogMgr.getBlog(f.getBlogId());
      if (blog == null) {
        throw new InputException(resources.getMessage(locale, "smssvc.selectedBlogNotFound"));
      }     
      blogCommandEntry.setBlog(blog);
    } else {
View Full Code Here

    setCommandEntryInRequest(req, blogCommandEntry);
    return mapping.findForward("modified");
  }

  private List<Blog> getBlogList(Group group) {
    BlogManager blogMgr = new BlogManager(locale, session);
    List<Blog> blogs = blogMgr.getBlogs(group);
    for (Iterator<Blog> it = blogs.iterator(); it.hasNext(); ) {
      Blog b = it.next();
      if (b.getCode().startsWith("personalblog_")) {
        it.remove();
      }
View Full Code Here

  /**
   * view a list of blogs
   */ 
  protected ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    Group group = getGroupParam(req);
    List<Blog> blogs = blogMgr.getBlogs(webUser, group);
    List<DisplayableBlog> entries = new ArrayList<DisplayableBlog>();
    for (Blog b : blogs) {
      DisplayableBlog e = new DisplayableBlog(b.getId(), b.getName(), b.getDescription());
      entries.add(e);
    }       
    req.setAttribute("entries", entries);   
    req.setAttribute("labelCloud", blogMgr.getLabelCloud(null, webUser, group, 20))// top 20 for sidebar
    return mapping.findForward("list");
  }
View Full Code Here

  /**
   * view tag cloud for all blogs
   * TODO only get Labels for blogs, the user is allowed to see
   */
  protected ActionForward cloud(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    Group group = getGroupParam(req);
    req.setAttribute("labelCloud", blogMgr.getLabelCloud(null, webUser, group, Integer.MAX_VALUE))// get all labels
    return mapping.findForward("cloud");
  }
View Full Code Here

   
    if(!req.isUserInRole("blog_reviewer")){
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
   
    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());
View Full Code Here

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

  /**
   * view an article specified by id
   */
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp, boolean viewReleasedCommentsOnly) {
    BlogManager blogMgr = new BlogManager(locale, session);
    String idParam = req.getParameter("id");
    Article article = blogMgr.getArticle(Long.parseLong(idParam));
   
    if (article == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.ArticleNotFound", idParam));
    }
    Blog blog = blogMgr.getBlog(article.getBlog().getId());
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!permissions.contains(PermissionManager.READ_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    req.setAttribute("blog", blog);
    req.getSession().setAttribute("blogCode", blog.getCode())// for fckeditor ...
    DisplayableArticle da = new DisplayableArticle(article, true);
    if (da.getTitle() == null || da.getTitle().trim().length()==0) {
      da.setTitle(getLocalizedMessage("BloggingWeb", "blog.noTitle"));
    }
    req.setAttribute("article", da);
    // anonymous users must not edit existing entries,
    // users with WRITE permission may edit their own articles only,
    // users with EDIT_OTHERS permission may also edit articles of others   
    req.setAttribute("mayEditArticle", webUser != null && ((article.getAuthor() != null && webUser.getId() == article.getAuthor().getId() && permissions.contains(PermissionManager.WRITE_PERMISSION)) ||  permissions.contains(PermissionManager.EDIT_OTHERS_PERMISSION)));
    req.setAttribute("mayAddComment", permissions.contains(PermissionManager.ADD_COMMENT_PERMISSION));
    if (article.getAuthor() != null) {
      session.load(User.class, article.getAuthor().getId());
    }
    List<DisplayableComment> comments = new ArrayList<DisplayableComment>();
    for (Comment c : article.getComments()) {
      if(viewReleasedCommentsOnly && c.getReviewStatus() != 1){
       
      } else {
        DisplayableComment dc = new DisplayableComment(c);
        comments.add(dc);
      }
    }
    da.setCommentCount(comments.size());
    req.setAttribute("commentList", comments);
    req.setAttribute("dateArchiveList", blogMgr.getArchives(blog));
    req.setAttribute("labelCloud", blogMgr.getLabelCloud(blog, webUser, null, 20));
    req.setAttribute("previousarticle", blogMgr.getPreviousArticle(article));   
    req.setAttribute("nextarticle", blogMgr.getNextArticle(article));
   
    try {
      req.setAttribute("articleRssUrl", getBaseUrl(req)+"/viewBlog.do?method=rss&id="+blog.getId());
      req.setAttribute("commentRssUrl", getBaseUrl(req)+"/viewBlog.do?method=commentrss&id="+blog.getId());
    } catch (Exception e) {
View Full Code Here

    return mapping.findForward("view");
  }

  public ActionForward addComment(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogArticleCommentForm f = (BlogArticleCommentForm)form;
    BlogManager blogMgr = new BlogManager(locale, session);
    Article article = blogMgr.getArticle(f.getArticleId());
    if (article == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.ArticleNotFound", f.getArticleId()));
    }
    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

 
  public ActionForward deleteComment(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    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

TOP

Related Classes of evolaris.framework.blog.business.BlogManager

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.