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
41 public class BlogsEntryAssetRendererFactory extends BaseAssetRendererFactory {
42
43 public static final String CLASS_NAME = BlogsEntry.class.getName();
44
45 public static final String TYPE = "blog";
46
47 public AssetRenderer getAssetRenderer(long classPK)
48 throws PortalException, SystemException {
49
50 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(classPK);
51
52 return new BlogsEntryAssetRenderer(entry);
53 }
54
55 public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
56 throws PortalException, SystemException {
57
58 BlogsEntry entry = BlogsEntryServiceUtil.getEntry(groupId, urlTitle);
59
60 return new BlogsEntryAssetRenderer(entry);
61 }
62
63 public String getClassName() {
64 return CLASS_NAME;
65 }
66
67 public String getType() {
68 return TYPE;
69 }
70
71 public PortletURL getURLAdd(
72 LiferayPortletRequest liferayPortletRequest,
73 LiferayPortletResponse liferayPortletResponse) {
74
75 ThemeDisplay themeDisplay =
76 (ThemeDisplay)liferayPortletRequest.getAttribute(
77 WebKeys.THEME_DISPLAY);
78
79 PortletURL addAssetURL = null;
80
81 if (BlogsPermission.contains(
82 themeDisplay.getPermissionChecker(),
83 themeDisplay.getScopeGroupId(), ActionKeys.ADD_ENTRY)) {
84
85 addAssetURL = liferayPortletResponse.createRenderURL(
86 PortletKeys.BLOGS);
87
88 addAssetURL.setParameter("struts_action", "/blogs/edit_entry");
89 }
90
91 return addAssetURL;
92 }
93
94 protected String getIconPath(ThemeDisplay themeDisplay) {
95 return themeDisplay.getPathThemeImages() + "/blogs/blogs.png";
96 }
97
98 }