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.security.permission.PermissionChecker;
023 import com.liferay.portal.security.permission.ResourceActionsUtil;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.PortalUtil;
026 import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
027
028 import java.util.Locale;
029 import java.util.Map;
030
031 import javax.portlet.PortletRequest;
032 import javax.portlet.PortletURL;
033
034
040 public abstract class BaseAssetRendererFactory implements AssetRendererFactory {
041
042 public AssetEntry getAssetEntry(long assetEntryId)
043 throws PortalException, SystemException {
044
045 return AssetEntryLocalServiceUtil.getEntry(assetEntryId);
046 }
047
048 public AssetEntry getAssetEntry(String className, long classPK)
049 throws PortalException, SystemException {
050
051 return AssetEntryLocalServiceUtil.getEntry(className, classPK);
052 }
053
054 public AssetRenderer getAssetRenderer(long classPK)
055 throws PortalException, SystemException {
056
057 return getAssetRenderer(classPK, TYPE_LATEST_APPROVED);
058 }
059
060 @SuppressWarnings("unused")
061 public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
062 throws PortalException, SystemException {
063
064 return null;
065 }
066
067 public long getClassNameId() {
068 return PortalUtil.getClassNameId(_className);
069 }
070
071 public Map<Long, String> getClassTypes(long[] groupId, Locale locale)
072 throws Exception {
073
074 return null;
075 }
076
077 public String getIconPath(PortletRequest portletRequest) {
078 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
079 WebKeys.THEME_DISPLAY);
080
081 return getIconPath(themeDisplay);
082 }
083
084 public String getPortletId() {
085 return _portletId;
086 }
087
088 public String getTypeName(Locale locale, boolean hasSubtypes) {
089 return ResourceActionsUtil.getModelResource(locale, getClassName());
090 }
091
092 @SuppressWarnings("unused")
093 public PortletURL getURLAdd(
094 LiferayPortletRequest liferayPortletRequest,
095 LiferayPortletResponse liferayPortletResponse)
096 throws PortalException, SystemException {
097
098 return null;
099 }
100
101 public boolean hasPermission(
102 PermissionChecker permissionChecker, long classPK, String actionId)
103 throws Exception {
104
105 return _PERMISSION;
106 }
107
108 public boolean isCategorizable() {
109 return true;
110 }
111
112 public boolean isLinkable() {
113 return _LINKABLE;
114 }
115
116 public boolean isSelectable() {
117 return _SELECTABLE;
118 }
119
120 public void setClassName(String className) {
121 _className = className;
122 }
123
124 public void setPortletId(String portletId) {
125 _portletId = portletId;
126 }
127
128 protected long getControlPanelPlid(ThemeDisplay themeDisplay)
129 throws PortalException, SystemException {
130
131 return PortalUtil.getControlPanelPlid(themeDisplay.getCompanyId());
132 }
133
134 protected String getIconPath(ThemeDisplay themeDisplay) {
135 return themeDisplay.getPathThemeImages() + "/common/page.png";
136 }
137
138 private static final boolean _LINKABLE = false;
139
140 private static final boolean _PERMISSION = true;
141
142 private static final boolean _SELECTABLE = true;
143
144 private String _className;
145 private String _portletId;
146
147 }