001
014
015 package com.liferay.portlet.blogs.asset;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
020 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.PortletKeys;
024 import com.liferay.portal.util.WebKeys;
025 import com.liferay.portlet.asset.model.AssetRenderer;
026 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
027 import com.liferay.portlet.blogs.model.BlogsEntry;
028 import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
029 import com.liferay.portlet.blogs.service.BlogsEntryServiceUtil;
030 import com.liferay.portlet.blogs.service.permission.BlogsPermission;
031
032 import javax.portlet.PortletURL;
033
034
038 public class BlogsEntryAssetRendererFactory extends BaseAssetRendererFactory {
039
040 public static final String CLASS_NAME = BlogsEntry.class.getName();
041
042 public static final String TYPE = "blog";
043
044 public AssetRenderer getAssetRenderer(long classPK, int type)
045 throws PortalException, SystemException {
046
047 BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(classPK);
048
049 return new BlogsEntryAssetRenderer(entry);
050 }
051
052 public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
053 throws PortalException, SystemException {
054
055 BlogsEntry entry = BlogsEntryServiceUtil.getEntry(groupId, urlTitle);
056
057 return new BlogsEntryAssetRenderer(entry);
058 }
059
060 public String getClassName() {
061 return CLASS_NAME;
062 }
063
064 public String getType() {
065 return TYPE;
066 }
067
068 public PortletURL getURLAdd(
069 LiferayPortletRequest liferayPortletRequest,
070 LiferayPortletResponse liferayPortletResponse) {
071
072 ThemeDisplay themeDisplay =
073 (ThemeDisplay)liferayPortletRequest.getAttribute(
074 WebKeys.THEME_DISPLAY);
075
076 PortletURL addAssetURL = null;
077
078 if (BlogsPermission.contains(
079 themeDisplay.getPermissionChecker(),
080 themeDisplay.getScopeGroupId(), ActionKeys.ADD_ENTRY)) {
081
082 addAssetURL = liferayPortletResponse.createRenderURL(
083 PortletKeys.BLOGS);
084
085 addAssetURL.setParameter("struts_action", "/blogs/edit_entry");
086 }
087
088 return addAssetURL;
089 }
090
091 protected String getIconPath(ThemeDisplay themeDisplay) {
092 return themeDisplay.getPathThemeImages() + "/blogs/blogs.png";
093 }
094
095 }