1
14
15 package com.liferay.portlet.blogs.asset;
16
17 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
18 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
19 import com.liferay.portal.security.permission.ActionKeys;
20 import com.liferay.portal.theme.ThemeDisplay;
21 import com.liferay.portal.util.PortletKeys;
22 import com.liferay.portal.util.WebKeys;
23 import com.liferay.portlet.asset.model.AssetRenderer;
24 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
25 import com.liferay.portlet.blogs.model.BlogsEntry;
26 import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
27 import com.liferay.portlet.blogs.service.BlogsEntryServiceUtil;
28 import com.liferay.portlet.blogs.service.permission.BlogsPermission;
29
30 import javax.portlet.PortletURL;
31
32
38 public class BlogsEntryAssetRendererFactory extends BaseAssetRendererFactory {
39
40 public static final String CLASS_NAME = BlogsEntry.class.getName();
41
42 public static final String TYPE = "blog";
43
44 public AssetRenderer getAssetRenderer(long classPK) throws Exception {
45 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(classPK);
46
47 return new BlogsEntryAssetRenderer(entry);
48 }
49
50 public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
51 throws Exception {
52
53 BlogsEntry entry = BlogsEntryServiceUtil.getEntry(groupId, urlTitle);
54
55 return new BlogsEntryAssetRenderer(entry);
56 }
57
58 public String getClassName() {
59 return CLASS_NAME;
60 }
61
62 public String getType() {
63 return TYPE;
64 }
65
66 public PortletURL getURLAdd(
67 LiferayPortletRequest liferayPortletRequest,
68 LiferayPortletResponse liferayPortletResponse) {
69
70 ThemeDisplay themeDisplay =
71 (ThemeDisplay)liferayPortletRequest.getAttribute(
72 WebKeys.THEME_DISPLAY);
73
74 PortletURL addAssetURL = null;
75
76 if (BlogsPermission.contains(
77 themeDisplay.getPermissionChecker(),
78 themeDisplay.getScopeGroupId(), ActionKeys.ADD_ENTRY)) {
79
80 addAssetURL = liferayPortletResponse.createRenderURL(
81 PortletKeys.BLOGS);
82
83 addAssetURL.setParameter("struts_action", "/blogs/edit_entry");
84 }
85
86 return addAssetURL;
87 }
88
89 }