Search in sources :

Example 1 with Blog

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;
}
Also used : HashMap(java.util.HashMap) DataAccessor(com.pratilipi.data.DataAccessor) BlogPostListApi(com.pratilipi.api.impl.blogpost.BlogPostListApi) Gson(com.google.gson.Gson) BlogPostData(com.pratilipi.data.client.BlogPostData) JsonObject(com.google.gson.JsonObject) Blog(com.pratilipi.data.type.Blog)

Aggregations

Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 BlogPostListApi (com.pratilipi.api.impl.blogpost.BlogPostListApi)1 DataAccessor (com.pratilipi.data.DataAccessor)1 BlogPostData (com.pratilipi.data.client.BlogPostData)1 Blog (com.pratilipi.data.type.Blog)1 HashMap (java.util.HashMap)1