Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.Article


    }
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!permissions.contains(PermissionManager.WRITE_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    Article article = new Article();
    article.setTitle(f.getTitle());
    article.setContent(f.getContent());
    article.setAuthor(webUser);
    article.setCreatedAt(new Date());   
    article = blogMgr.addArticle(blog, article);
    blogMgr.setLabels(article, f.getLabels());
    blogMgr.updateArticle(article);
    LOGGER.info("User "+UserManagerBase.toString(webUser)+" added article #"+article.getId()+" ("+article.getTitle()+") to blog #"+blog.getId()+" ("+blog.getName()+")");
    return injectId(mapping.findForward("added"), f.getBlogId());
 
View Full Code Here


    }
    BlogArticleForm f = (BlogArticleForm)form;
    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())// fetch blog, so we have it after session is closed
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!((article.getAuthor() != null && webUser.getId() == article.getAuthor().getId() && permissions.contains(PermissionManager.WRITE_PERMISSION))
        || permissions.contains(PermissionManager.EDIT_OTHERS_PERMISSION))) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    req.getSession().setAttribute("blog", blog);
    req.getSession().setAttribute("blogCode", blog.getCode())// for fckeditor ...
    req.getSession().setAttribute("labels", blog.getLabels().toArray());   
    f.setArticleId(article.getId());
    f.setBlogId(article.getBlog().getId());
    f.setTitle(article.getTitle());
    f.setLabels(labelSetToString(article.getLabels()));
    f.setContent(article.getContent());   
    return mapping.findForward("edit");
  }
View Full Code Here

    if (webUser == null){
      throw new InputException(getResources(req).getMessage(locale, "blog.AnonymousEditingNotAllowed"));
    }
    BlogArticleForm f = (BlogArticleForm)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 (!((article.getAuthor() != null && webUser.getId() == article.getAuthor().getId() && permissions.contains(PermissionManager.WRITE_PERMISSION))
        || permissions.contains(PermissionManager.EDIT_OTHERS_PERMISSION))) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
   
    article.setTitle(f.getTitle());
    article.setContent(f.getContent());
    article.setModifiedBy(webUser);
    article.setModifiedAt(new Date());
    blogMgr.setLabels(article, f.getLabels());
    blogMgr.updateArticle(article);
    LOGGER.info("User "+UserManagerBase.toString(webUser)+" modified article #"+article.getId()+" ("+article.getTitle()+") of blog #"+article.getBlog().getId()+" ("+article.getBlog().getName()+")");
    return injectId(mapping.findForward("modified"), f.getArticleId());
  }
View Full Code Here

    if (webUser == null){
      throw new InputException(getResources(req).getMessage(locale, "blog.AnonymousEditingNotAllowed"));
    }
    BlogArticleForm f = (BlogArticleForm)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 (!((article.getAuthor() != null && webUser.getId() == article.getAuthor().getId() && permissions.contains(PermissionManager.WRITE_PERMISSION))
        || permissions.contains(PermissionManager.EDIT_OTHERS_PERMISSION))) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
   
    blogMgr.deleteArticle(article);
    LOGGER.info("User "+UserManagerBase.toString(webUser)+" deleted article #"+article.getId()+" ("+article.getTitle()+", "+article.getContent()+") of blog #"+article.getBlog().getId()+" ("+article.getBlog().getName()+")");
    return injectId(mapping.findForward("deleted"), f.getBlogId());
  }
View Full Code Here

      if (bl!=null) {
        //read the game types from articles
        Query qa=session.createQuery("select o from Article o where o.blog.id=:id");
        qa.setParameter("id",bl.getId());
        for (Iterator iter = qa.iterate(); iter.hasNext();) {
          Article a=(Article)iter.next();
          form.getGameTypeArticles().add(a);
        }
      }
     
      form.setMyUserId(webUser.getId());
View Full Code Here

    BlogManager blogMgr = new BlogManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    List<DisplayableApplicationType> entries = new ArrayList<DisplayableApplicationType>();
    for (Long id : searchResults) {
      Article blogArticle = blogMgr.getArticle(id);
      DisplayableApplicationType entry = new DisplayableApplicationType(blogArticle);
      Label label = blogMgr.getLabel(gameBlog, blogArticle.getTitle());
      Collection<Article> gameList = label != null ? blogMgr.getArchivedArticles(gameBlog, label) : null;
      entry.setGameCount(gameList != null ? gameList.size() : 0);
      entries.add(entry);
    }
    req.setAttribute("articleList", entries);
View Full Code Here

    super.view(mapping, form, req, resp);
    List<DisplayableArticle> displayArticles = (List<DisplayableArticle>)req.getAttribute("articleList");
    List<DisplayableApplicationType> gameStyles = new ArrayList<DisplayableApplicationType>();
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    for (DisplayableArticle a : displayArticles) {
      Article blogArticle = blogMgr.getArticle(a.getId());
      DisplayableApplicationType entry = new DisplayableApplicationType(blogArticle);
      Label label = blogMgr.getLabel(gameBlog, blogArticle.getTitle());
      Collection<Article> gameList = label != null ? blogMgr.getArchivedArticles(gameBlog, label) : null;
      entry.setGameCount(gameList != null ? gameList.size() : 0);
      gameStyles.add(entry);
    }
    Collections.sort(gameStyles, new Comparator<DisplayableApplicationType>() {
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    String idParam = req.getParameter("id");
    Article article = blogMgr.getArticle(Long.parseLong(idParam));
    if (article == null) {
      throw new InputException(getResources(req).getMessage(locale, "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(getResources(req).getMessage("um.insufficientRights"));
    }
    req.setAttribute("blog", blog);
    DisplayableArticle displayableArticle = new DisplayableArticle(article, true)
    req.setAttribute("article", displayableArticle);
    req.setAttribute("mayEditArticle", permissions.contains(PermissionManager.WRITE_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()) {
      DisplayableComment dc = new DisplayableComment(c);
      comments.add(dc);
    }
    req.setAttribute("commentList", comments);

    // list of game instances
    Blog gameBlog = blogMgr.getBlog("mgblgameinstances", blog.getGroup());
    List<DisplayableArticle> gameList = new ArrayList<DisplayableArticle>();
    Label label = blogMgr.getLabel(gameBlog, article.getTitle());
    if (label == null) {
      // do some self healing magic ...
      label = new Label();
      label.setLabel(article.getTitle());
      blogMgr.addLabel(gameBlog, label);
    }
    Collection<Article> gameArticles = blogMgr.getArchivedArticles(gameBlog, label);
    for (Article gameArticle : gameArticles) {
      DisplayableArticle entry = new DisplayableArticle(gameArticle);
View Full Code Here

    session.saveOrUpdate(article);
    return comment;
  }
 
  public void deleteComment(Comment comment) {
    Article article = comment.getArticle();
    article.getComments().remove(comment);
    session.saveOrUpdate(article);
    session.delete(comment);
  }
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.