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