use of com.pratilipi.data.type.Blog in project pratilipi by Pratilipi.
the class PratilipiSite method createDataModelForBlogPage.
public Map<String, Object> createDataModelForBlogPage(Long blogId, Language language, boolean basicMode) throws InsufficientAccessException, UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
Blog blog = dataAccessor.getBlog(blogId);
BlogPostListApi.GetRequest request = new BlogPostListApi.GetRequest();
request.setBlogId(blogId);
request.setLangugage(language);
request.setState(BlogPostState.PUBLISHED);
BlogPostListApi.Response blogPostList = ApiRegistry.getApi(BlogPostListApi.class).get(request);
BlogPostData blogPostLanguage = new BlogPostData();
blogPostLanguage.setLanguage(language);
boolean hasAccessToAdd = BlogPostDataUtil.hasAccessToAddBlogPostData(blogPostLanguage);
Map<String, Object> dataModel = new HashMap<String, Object>();
if (// Blog
blogId.equals(5683739602452480L))
dataModel.put("title", SEOTitleUtil.getBlogPageTitle(language));
else if (// Author Interviews
blogId.equals(5197509039226880L))
dataModel.put("title", SEOTitleUtil.getAuthorInterviewPageTitle(language));
else
dataModel.put("title", blog.getTitle());
if (basicMode) {
dataModel.put("blogPostList", blogPostList.getBlogPostList());
} else {
Gson gson = new Gson();
dataModel.put("blogId", blogId);
dataModel.put("hasAccessToAdd", hasAccessToAdd);
dataModel.put("blogPostListJson", gson.toJson(blogPostList.getBlogPostList()));
dataModel.put("blogPostFilterJson", gson.toJson(request));
dataModel.put("blogPostListCursor", blogPostList.getCursor());
}
return dataModel;
}
Aggregations