Package evolaris.framework.blog.datamodel

Examples of evolaris.framework.blog.datamodel.Blog


 
  public ActionForward enterArticle(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogArticleForm f = (BlogArticleForm)form;
    BlogManager blogMgr = new BlogManager(locale, session);
    Long id = Long.parseLong(req.getParameter("id"));
    Blog blog = blogMgr.getBlog(id);
    if (blog == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.BlogNotFound", id, ""));
    }
    Set<Long> permissions = getPermissions(blog, webUser);
    if (!permissions.contains(PermissionManager.WRITE_PERMISSION)) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.insufficientRights"));
    }
    f.setBlogId(id);
    req.getSession().setAttribute("blog", blog);
    req.getSession().setAttribute("blogCode", blog.getCode())// for fckeditor ...
    req.getSession().setAttribute("labels", blog.getLabels().toArray());
    return mapping.findForward("enter");
 
View Full Code Here


 
 
  public ActionForward addArticle(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogArticleForm f = (BlogArticleForm)form;
    BlogManager blogMgr = new BlogManager(locale, session);
    Blog blog = blogMgr.getBlog(f.getBlogId());
    if (blog == null) {
      throw new InputException(getLocalizedMessage("BloggingWeb", "blog.BlogNotFound", f.getBlogId(), ""));
    }
    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

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

      AddNewGameTemplateForm form=(AddNewGameTemplateForm)af;
      form.reset();
     
     
      //find blog with code "mgblgamestyles"
      Blog bl=null;
      Query q=session.createQuery("select o from Blog o where o.code=:code");
      q.setParameter("code","mgblgamestyles");
      for (Iterator iter = q.iterate(); iter.hasNext();) {
        bl=(Blog)iter.next();
      }
      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);
        }
      }
View Full Code Here

    }
   
    GroupManager groupMgr = new GroupManager(locale, session);
    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());
View Full Code Here

  @SuppressWarnings("unchecked")
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    GroupManager groupMgr = new GroupManager(locale, session);
    BlogManager blogMgr = new BlogManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog gameStyleBlog = blogMgr.getBlog("mgblgamestyles", mgblGroup);
    if (req.getParameter("id") == null) {
      req.setAttribute("id", Long.toString(gameStyleBlog.getId()));
    }
    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;
View Full Code Here

  @SuppressWarnings("unchecked")
  protected ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    BlogManager blogMgr = new BlogManager(locale, session);
    GroupManager groupMgr = new GroupManager(locale, session);
    Group mgblGroup = groupMgr.getGroup("mgbl");
    Blog blog = blogMgr.getBlog("mgblgameinstances", mgblGroup);
    req.setAttribute("id", Long.toString(blog.getId()));
   
    // inject labelarchive param if mgblpresetlabel is there
    String labelArchiveParam = req.getParameter("labelarchive");
    if (labelArchiveParam == null) {  // try mgblPresetLabel
      String presetLabelString = (String)req.getSession().getAttribute("mgblPresetLabel");
      if (presetLabelString != null) {
        Label presetLabel = blogMgr.getLabel(blog, presetLabelString);
        if (presetLabel != null) {
          labelArchiveParam = Long.toString(presetLabel.getId());
          req.setAttribute("labelarchive", labelArchiveParam);
        }
      }
    }
   
    ActionForward fwd = super.view(mapping, form, req, resp);

    if (labelArchiveParam != null && labelArchiveParam.length() > 0) {
      Label label = blogMgr.getLabel(blog, Long.parseLong(labelArchiveParam));
      req.getSession().setAttribute("mgblPresetLabel", label.getLabel());
      Blog gameStyleBlog = blogMgr.getBlog("mgblgamestyles", blog.getGroup());
      req.getSession().removeAttribute("mgblCurrentGameStyle");
      req.getSession().removeAttribute("mgblCurrentGameStyleBelongsToSearchResult");
      for (Article style : gameStyleBlog.getArticles()) {
        if (label.getLabel().equals(style.getTitle())) {
          req.getSession().setAttribute("mgblCurrentGameStyle", new DisplayableArticle(style));
          List<Long> searchResults = (List<Long>)req.getSession().getAttribute("mgblSearchResults");
          if (searchResults != null && searchResults.contains(style.getId())) {
            req.getSession().setAttribute("mgblCurrentGameStyleBelongsToSearchResult", Boolean.TRUE);
View Full Code Here

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

    session.saveOrUpdate(article);
  }
 
  public void deleteArticle(Article article) {
    setLabels(article, "")// remove all labels from this article
    Blog blog = article.getBlog();
    blog.getArticles().remove(article);
    session.saveOrUpdate(blog);
    session.delete(article);
  }
View Full Code Here

TOP

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

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.