001
014
015 package com.liferay.portlet.asset.model;
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.kernel.util.WebKeys;
022 import com.liferay.portal.model.Group;
023 import com.liferay.portal.model.GroupConstants;
024 import com.liferay.portal.security.permission.PermissionChecker;
025 import com.liferay.portal.service.GroupLocalServiceUtil;
026 import com.liferay.portal.service.LayoutLocalServiceUtil;
027 import com.liferay.portal.theme.ThemeDisplay;
028 import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
029
030 import javax.portlet.PortletRequest;
031 import javax.portlet.PortletURL;
032
033
039 public abstract class BaseAssetRendererFactory implements AssetRendererFactory {
040
041 public AssetEntry getAssetEntry(long assetEntryId)
042 throws PortalException, SystemException {
043
044 return AssetEntryLocalServiceUtil.getEntry(assetEntryId);
045 }
046
047 public AssetEntry getAssetEntry(String className, long classPK)
048 throws PortalException, SystemException {
049
050 return AssetEntryLocalServiceUtil.getEntry(className, classPK);
051 }
052
053 public AssetRenderer getAssetRenderer(long classPK)
054 throws PortalException, SystemException {
055
056 return getAssetRenderer(classPK, TYPE_LATEST_APPROVED);
057 }
058
059 @SuppressWarnings("unused")
060 public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
061 throws PortalException, SystemException {
062
063 return null;
064 }
065
066 public long getClassNameId() {
067 return _classNameId;
068 }
069
070 public String getIconPath(PortletRequest portletRequest) {
071 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
072 WebKeys.THEME_DISPLAY);
073
074 return getIconPath(themeDisplay);
075 }
076
077 public String getPortletId() {
078 return _portletId;
079 }
080
081 @SuppressWarnings("unused")
082 public PortletURL getURLAdd(
083 LiferayPortletRequest liferayPortletRequest,
084 LiferayPortletResponse liferayPortletResponse)
085 throws PortalException, SystemException {
086
087 return null;
088 }
089
090 public boolean hasPermission(
091 PermissionChecker permissionChecker, long classPK, String actionId)
092 throws Exception {
093
094 return true;
095 }
096
097 public boolean isSelectable() {
098 return true;
099 }
100
101 public void setClassNameId(long classNameId) {
102 _classNameId = classNameId;
103 }
104
105 public void setPortletId(String portletId) {
106 _portletId = portletId;
107 }
108
109 protected long getControlPanelPlid(ThemeDisplay themeDisplay)
110 throws PortalException, SystemException {
111
112 Group controlPanelGroup = GroupLocalServiceUtil.getGroup(
113 themeDisplay.getCompanyId(), GroupConstants.CONTROL_PANEL);
114
115 return LayoutLocalServiceUtil.getDefaultPlid(
116 controlPanelGroup.getGroupId(), true);
117 }
118
119 protected String getIconPath(ThemeDisplay themeDisplay) {
120 return themeDisplay.getPathThemeImages() + "/common/page.png";
121 }
122
123 private long _classNameId;
124 private String _portletId;
125
126 }