Blog blog = (Blog)publicBlogs.get(0);
return new RedirectView(blog.getUrl());
} else {
getModel().put(Constants.BLOG_ENTRIES, abstractBlog.getRecentBlogEntries());
return new BlogEntriesView();
}
} else {
Blog blog = (Blog)abstractBlog;
int page = 1;
try {
page = Integer.parseInt(request.getParameter("page"));
} catch (NumberFormatException nfe) {
page = 1;
}
boolean publishedOnly = true;
if (SecurityUtils.isUserAuthorisedForBlog(blog)) {
publishedOnly = false;
}
getModel().put(Constants.MONTHLY_BLOG, blog.getBlogForThisMonth());
getModel().put("displayMode", "page");
getModel().put("page", page);
Pageable<String> pageable;
if (publishedOnly) {
pageable = new Pageable<String>(blog.getBlogEntryIndex().getPublishedBlogEntries());
} else {
pageable = new Pageable<String>(blog.getBlogEntryIndex().getBlogEntries());
}
pageable.setPageSize(blog.getRecentBlogEntriesOnHomePage());
pageable.setPage(page);
List<String> blogEntryIds = pageable.getListForPage();
List<BlogEntry> blogEntries = blog.getBlogEntries(blogEntryIds);
getModel().put(Constants.BLOG_ENTRIES, blogEntries);
getModel().put("pageable", pageable);
return new BlogEntriesView();
}
}