Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.Article


    }
   
    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());
   
    return newFwd;
  }
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);
View Full Code Here

  }

  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 void _testAddLabel() {
    GroupManager grp = new GroupManager(Locale.getDefault(), session);
    Blog b = mgr.getBlog("tstblg1", grp.getGroup("administrator"));
    Article a = b.getArticles().iterator().next();
    mgr.setLabels(a, "test");
    for (Label l : a.getLabels()) {
      System.out.println(l.getLabel());
      for (Article aa : l.getArticles()) {
        System.out.println("--"+aa.getTitle());
      }
    }
View Full Code Here

    template.setGameType("Action");
    GameHiber game = new GameHiber();
    game.setName("title a");
    game.setDescription("content");
   
    Article a = dbManager.createGameBlogArticle(game, null, new String[] {template.getGameType(), "additional label 1", "additional label 2"});
   
    assertTrue(a != null && a.getId() > 0);
  }
View Full Code Here

   * @param labels An array of labels, used to tag the article. 
   * @return
   */
  public Article createGameBlogArticle(GameHiber game, User author, String[] labels) {
    Blog gameBlog = getGameBlog();
    Article article = new Article();
    article.setTitle(game.getName());
    article.setContent(game.getDescription());
    article.setAuthor(author);
    article.setCreatedAt(new Date());
    article.setBlog(gameBlog);
    gameBlog.getArticles().add(article);
    session.save(article);
    session.saveOrUpdate(gameBlog);
   
    // attach labels
    article.setLabels(new HashSet<Label>());
    if (labels != null && labels.length > 0) {
      for (String s : labels) {
        s = s.replaceAll("[\"',;]", "")// cleanup label
        Label label = getLabel(gameBlog, s);
        if (label == null) {
          label = new Label();
          label.setLabel(s);
          label.setBlog(article.getBlog());
          label.getArticles().add(article);
          addLabel(gameBlog, label);
        }
        article.getLabels().add(label);
        label.getArticles().add(article);
      }   
      session.update(article);   
    }
    return article;   
View Full Code Here

      try {
        //read the game types from articles
        Query qa=hibernateSession.createQuery("select o from Article o where o.id=:id");
        qa.setParameter("id",Long.parseLong(toAdd.getGameType()));
        for (Iterator iter3 = qa.iterate(); iter3.hasNext();) {
          Article a=(Article)iter3.next();
          toAdd.setGameTypeArticle(a);
        }
      } catch (Exception e) {
      }
     
View Full Code Here

    try {
      //read the game types from articles
      Query qa=hibernateSession.createQuery("select o from Article o where o.id=:id");
      qa.setParameter("id",Long.parseLong(newOne.getBasedOnTemplate().getGameType()));
      for (Iterator iter3 = qa.iterate(); iter3.hasNext();) {
        Article a=(Article)iter3.next();
        newOne.setGameType(newOne.getBasedOnTemplate().getName()+" ("+a.getTitle()+")");
        newOne.setGameTypeDescription(a.getContent());
      }
    } catch (Exception e) {
    }
   
    return newOne;
View Full Code Here

      try {
        //read the game types from articles
        Query qa=hibernateSession.createQuery("select o from Article o where o.id=:id");
        qa.setParameter("id",Long.parseLong(newOne.getBasedOnTemplate().getGameType()));
        for (Iterator iter3 = qa.iterate(); iter3.hasNext();) {
          Article a=(Article)iter3.next();
          newOne.setGameType(newOne.getBasedOnTemplate().getName()+" ("+a.getTitle()+")");
          newOne.setGameTypeDescription(a.getContent());
        }
      } catch (Exception e) {
      }
     
      ret.add(newOne);
View Full Code Here

      try {
        //read the game types from articles
        Query qa=hibernateSession.createQuery("select o from Article o where o.id=:id");
        qa.setParameter("id",Long.parseLong(newOne.getBasedOnTemplate().getGameType()));
        for (Iterator iter3 = qa.iterate(); iter3.hasNext();) {
          Article a=(Article)iter3.next();
          newOne.setGameType(newOne.getBasedOnTemplate().getName()+" ("+a.getTitle()+")");
          newOne.setGameTypeDescription(a.getContent());
        }
      } catch (Exception e) {
      }
     
      ret.add(newOne);
View Full Code Here

TOP

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

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.