*/
@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);