use of com.pratilipi.data.client.BlogPostData 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;
}
use of com.pratilipi.data.client.BlogPostData in project pratilipi by Pratilipi.
the class BlogPostApi method post.
@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
BlogPostData blogPostData = new BlogPostData(request.blogPostId);
blogPostData.setBlogId(request.blogId);
blogPostData.setTitle(request.title);
blogPostData.setTitleEn(request.titleEn);
blogPostData.setContent(request.content);
blogPostData.setLanguage(request.language);
blogPostData.setState(request.state);
blogPostData = BlogPostDataUtil.saveBlogPostData(blogPostData);
return new Response(blogPostData);
}
use of com.pratilipi.data.client.BlogPostData in project pratilipi by Pratilipi.
the class BlogPostDataUtil method createBlogPostDataList.
public static List<BlogPostData> createBlogPostDataList(List<BlogPost> blogPostList) {
List<Long> blogIdList = new ArrayList<>();
for (BlogPost blogPost : blogPostList) blogIdList.add(blogPost.getId());
Map<Long, Page> blogPostPages = DataAccessorFactory.getDataAccessor().getPages(PageType.BLOG_POST, blogIdList);
List<BlogPostData> blogPostDataList = new ArrayList<>();
for (BlogPost blogPost : blogPostList) blogPostDataList.add(createBlogPostData(blogPost, blogPostPages.get(blogPost.getId())));
return blogPostDataList;
}
use of com.pratilipi.data.client.BlogPostData in project pratilipi by Pratilipi.
the class BlogPostApi method get.
@Get
public Response get(GetRequest request) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
BlogPost blogPost = dataAccessor.getBlogPost(request.blogPostId);
BlogPostData blogPostData = BlogPostDataUtil.createBlogPostData(blogPost);
return new Response(blogPostData);
}
use of com.pratilipi.data.client.BlogPostData in project pratilipi by Pratilipi.
the class BlogPostListApi method get.
@Get
public Response get(GetRequest request) throws InsufficientAccessException {
BlogPostFilter blogPostFilter = new BlogPostFilter();
blogPostFilter.setBlogId(request.blogId);
blogPostFilter.setLanguage(request.language);
blogPostFilter.setState(request.state);
DataListCursorTuple<BlogPostData> blogPostDataListCursorTuple = BlogPostDataUtil.getBlogPostDataList(blogPostFilter, request.cursor, 0, request.resultCount == null ? 10 : request.resultCount);
return new Response(blogPostDataListCursorTuple.getDataList(), blogPostDataListCursorTuple.getCursor());
}
Aggregations