Package evolaris.framework.blog.business

Examples of evolaris.framework.blog.business.BlogManager


    req.setAttribute("selectableSenders", senders);
   
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    req.setAttribute("selectableFragments", smsDbManager.getFragments(destinationGroup));
   
    BlogManager blogMgr = new BlogManager(locale, session);
    List<Blog> blogs = blogMgr.getBlogs(destinationGroup);
    for (Blog blog : blogs) { // fill cache
      blog.getName();
    }
    req.setAttribute("selectableBlogs", blogs);
   
View Full Code Here


      }
    }

    // blogs

    BlogManager blogManager = new BlogManager(locale, session);
    long[] sourceBlogIds = f.getSourceBlogIds();
    if (sourceBlogIds != null) {  // at least one mapping
      Blog personalBlog = new Blog();
      personalBlog.setId(-99);
      personalBlog.setName(this.getResources(req).getMessage("smssvc.personalBlog"));
      long[] selectedBlogIds = f.getSelectedBlogIds();
      for (int i = 0; i < sourceBlogIds.length; i++){
        long sourceBlogId = sourceBlogIds[i];
        Blog sourceBlog = sourceBlogId == -99 ? personalBlog : blogManager.getBlog(sourceBlogId);
        if (sourceBlog == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceBlogNotAvailableAnymore"),"blog #" + sourceBlogId + " not found",null,null);
        }
        if (sourceBlog.getId() != -99) {
          checkAccessRights(req, sourceBlog.getGroup());
        }
        long selectedBlogId = selectedBlogIds[i];
        if (selectedBlogId != -99 && selectedBlogId <= 0) {
          throw new InputException(getResources(req).getMessage(locale, "smssvc.BlogMappingSelectionMissing"),"sourceBlogId = " + sourceBlogId,null,null);
        }
        Blog selectedBlog = selectedBlogId == -99 ? personalBlog : blogManager.getBlog(selectedBlogId);
        if (selectedBlog == null) {
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedBlogNotAvaliableAnymore"),"blog #" + selectedBlogId + " not found",null,null);
        }
        if (selectedBlogId != -1) {
          checkAccessRights(req,selectedBlog.getGroup());
View Full Code Here

  /**
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Group group = this.getCurrentGroup(req);
    BlogManager mgr = new BlogManager(locale, session);
    List<Blog> blogs = mgr.getBlogs(group);
    List<BlogListEntry> entries = new ArrayList<BlogListEntry>();
    if (blogs != null) {
      for (Blog b : blogs) {
        BlogListEntry e = new BlogListEntry(b, mgr.countAuthors(b, null, null), b.getArticles().size(), mgr.countComments(b, null, null));
        entries.add(e);
      }
    }
    req.setAttribute("blogs", entries);
    return mapping.findForward("list");
View Full Code Here

    Group group = this.getCurrentGroup(req);
    checkAccessRights(req, group);
    formToBlog(f, blog);
    blog.setGroup(group);
    ensureUniqueCodePerGroup(blog, req);
    BlogManager mgr = new BlogManager(locale, session);
    mgr.createBlog(blog);
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": created blog `"+ blog.getCode() + "`");
    return mapping.findForward("created");
  }
View Full Code Here

  }

 
  public ActionForward edit(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp) {
    String idParam = req.getParameter("id");
    BlogManager mgr = new BlogManager(locale, session);
    Blog blog = mgr.getBlog(Long.parseLong(idParam));
    if (blog == null) {
      throw new InputException(getResources(req).getMessage(locale, "admin.BlogNotFound", idParam));
    }
    checkAccessRights(req, blog.getGroup());   
    blogToForm(blog, (BlogEnterOrEditForm)form);
View Full Code Here

   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward modify(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogEnterOrEditForm f = (BlogEnterOrEditForm)form;
    BlogManager mgr = new BlogManager(locale,session);
    Blog blog = mgr.getBlog(f.getId());
    if (blog == null) {
      throw new InputException(getResources(req).getMessage(locale, "admin.BlogNotFound", f.getId()));
    }
    checkAccessRights(req, blog.getGroup());
    formToBlog(f, blog);
    ensureUniqueCodePerGroup(blog, req);
    mgr.modifyBlog(blog);
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": modified blog `"+ blog.getCode() + "`");
    return mapping.findForward("modified");
  }
View Full Code Here

   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    String idParam = req.getParameter("id");
    BlogManager mgr = new BlogManager(locale, session);
    Blog blog = mgr.getBlog(Long.parseLong(idParam));
    if (blog == null) {
      throw new InputException(getResources(req).getMessage(locale, "admin.BlogNotFound",  idParam));
    }
    checkAccessRights(req, blog.getGroup());
    mgr.deleteBlog(blog);
    String code = blog.getCode();
    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": deleted blog `"+ code + "`");
    return mapping.findForward("deleted");
  }
View Full Code Here

  /**
   * view a blog specified by id or code
   */
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp, int selection) {
    BlogManager blogMgr = new BlogManager(locale, session);
    Blog blog = null;
    String idParam = req.getAttribute("id") != null ? (String)req.getAttribute("id") : req.getParameter("id"); // allow parameter injection
    String codeParam = req.getAttribute("code") != null ? (String)req.getAttribute("code") : req.getParameter("code");
    String groupParam = req.getAttribute("group_id") != null ? (String)req.getAttribute("group_id") : req.getParameter("group_id");
    String dateArchiveParam = req.getAttribute("datearchive") != null ? (String)req.getAttribute("datearchive") : req.getParameter("datearchive");
    String labelArchiveParam = req.getAttribute("labelarchive") != null ? (String)req.getAttribute("labelarchive") : req.getParameter("labelarchive");
    String unlabelledParam = req.getAttribute("unlabelled") != null ? (String)req.getAttribute("unlabelled") : req.getParameter("unlabelled");
    if (idParam != null) {
      blog = blogMgr.getBlog(Long.parseLong(idParam));
    } else if (codeParam != null && groupParam != null) {
      try {
        long groupId = Long.parseLong(groupParam);
        GroupManager groupMgr = new GroupManager(locale, session);
        Group group = groupMgr.getGroup(groupId);
        blog = blogMgr.getBlog(codeParam, group);
      } catch (Exception e) {
        blog = null;
      }
    } else {
      if (webUser != null) {
        blog = blogMgr.getBlog(webUser.getUsername(), webUser.getGroup());
      }
    }
    if (blog == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.BlogNotFound", idParam, codeParam));
    }
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!permissions.contains(PermissionManager.READ_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    req.setAttribute("blog", blog);   
    Collection<Article> articles = null;
    List<DisplayableArticle> displayArticles = new ArrayList<DisplayableArticle>();
    Date from = null, to = null;
    if (dateArchiveParam != null && dateArchiveParam.length() > 0) {
      Date archiveDate = new Date(Long.parseLong(dateArchiveParam));
      articles = blogMgr.getArchivedArticles(blog, archiveDate);
      SimpleDateFormat df = new SimpleDateFormat("yyyy");
      String yearStr = df.format(archiveDate);
      df = new SimpleDateFormat("MMMM");
      String monthStr = df.format(archiveDate);
      req.setAttribute("subheader", getLocalizedMessage("BloggingWeb", "blog.ArchiveForMonth", monthStr, yearStr));
      Calendar cal = Calendar.getInstance();
      df = new SimpleDateFormat("yyyy-MMMM");
      try {
        cal.setTime(df.parse(yearStr+"-"+monthStr));
        from = cal.getTime();
        cal.add(Calendar.MONTH, 1);
        to = cal.getTime();
      } catch (ParseException e) {
        from = to = null;
      }     
    } else if (labelArchiveParam != null && labelArchiveParam.length() > 0) {
      Label label = blogMgr.getLabel(blog, Long.parseLong(labelArchiveParam));
      articles = blogMgr.getArchivedArticles(blog, label);
      req.setAttribute("subheader", getLocalizedMessage("BloggingWeb", "blog.ArchiveForLabel", label.getLabel()));     
    } else if (unlabelledParam != null) {
      articles = blogMgr.getUnlabelledArticles(blog);
      req.setAttribute("subheader", getLocalizedMessage("BloggingWeb", "blog.ArchiveForUnlabelled"));     
    } else {
      articles = blog.getArticles();
    }
    for (Article a : articles) {
     
      boolean display = true;
     
      if(selection==BLOCKED) {
        if(isArticleBlocked(a) || isACommentBlocked(a)){
          display = true;
        } else {
          display = false;
        }
      }
     
      if(selection==NOT_REVIEWED){
        if(isArticleBlocked(a)){
          display = false;
        }else if(isArticleNotReviewed(a)){
          display = true;
        } else if(isACommentNotReviewed(a)){
          display = true;
        } else {
          display = false;
        }
      }
       
      if(selection==RELEASED){
        if(isArticleReleased(a)){
          display = true;
        } else {
          display = false;
        }
      }
     
      if(display){
        DisplayableArticle da = new DisplayableArticle(a, true)
        if (da.getTitle() == null || da.getTitle().trim().length()==0) {
          da.setTitle(getLocalizedMessage("BloggingWeb", "blog.noTitle"));
        }
        displayArticles.add(da);
      }

    }
    req.setAttribute("mayAddArticles", permissions.contains(PermissionManager.WRITE_PERMISSION));
    req.setAttribute("articleList", displayArticles);
    req.setAttribute("countArticles", displayArticles.size());
    req.setAttribute("countPosters", blogMgr.countAuthors(blog, from, to));
    req.setAttribute("countComments", blogMgr.countComments(blog, from, to));
    req.setAttribute("dateArchiveList", blogMgr.getArchives(blog));
    req.setAttribute("labelCloud", blogMgr.getLabelCloud(blog, webUser, null, 20));
   
    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

   * Create rss feed of this blog.
   * Based on anonymous user.
   * 
   */
  protected ActionForward rss(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    Blog blog = null;
    String idParam = req.getParameter("id");
    String codeParam = req.getParameter("code");
    String groupParam = req.getParameter("group_id");
    if (idParam != null) {
      blog = blogMgr.getBlog(Long.parseLong(idParam));
    } else if (codeParam != null && groupParam != null) {
      try {
        long groupId = Long.parseLong(groupParam);
        GroupManager groupMgr = new GroupManager(locale, session);
        Group group = groupMgr.getGroup(groupId);
        blog = blogMgr.getBlog(codeParam, group);
      } catch (Exception e) {
        blog = null;
      }
    }
    if (blog == null) {
View Full Code Here

   * Create rss feed of comments of this blog.
   * Based on anonymous user.
   * 
   */
  protected ActionForward commentRss(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    Blog blog = null;
    String idParam = req.getParameter("id");
    String codeParam = req.getParameter("code");
    String groupParam = req.getParameter("group_id");
    if (idParam != null) {
      blog = blogMgr.getBlog(Long.parseLong(idParam));
    } else if (codeParam != null && groupParam != null) {
      try {
        long groupId = Long.parseLong(groupParam);
        GroupManager groupMgr = new GroupManager(locale, session);
        Group group = groupMgr.getGroup(groupId);
        blog = blogMgr.getBlog(codeParam, group);
      } catch (Exception e) {
        blog = null;
      }
    }
    if (blog == null) {
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.