001
014
015 package com.liferay.portlet.messageboards.asset;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.security.permission.PermissionChecker;
020 import com.liferay.portal.theme.ThemeDisplay;
021 import com.liferay.portlet.asset.model.AssetRenderer;
022 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
023 import com.liferay.portlet.messageboards.model.MBMessage;
024 import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
025 import com.liferay.portlet.messageboards.service.permission.MBMessagePermission;
026
027
033 public class MBMessageAssetRendererFactory extends BaseAssetRendererFactory {
034
035 public static final String CLASS_NAME = MBMessage.class.getName();
036
037 public static final String TYPE = "message";
038
039 @Override
040 public AssetRenderer getAssetRenderer(long classPK, int type)
041 throws PortalException, SystemException {
042
043 MBMessage message = MBMessageLocalServiceUtil.getMessage(classPK);
044
045 return new MBMessageAssetRenderer(message);
046 }
047
048 @Override
049 public String getClassName() {
050 return CLASS_NAME;
051 }
052
053 @Override
054 public String getType() {
055 return TYPE;
056 }
057
058 @Override
059 public boolean hasPermission(
060 PermissionChecker permissionChecker, long classPK, String actionId)
061 throws Exception {
062
063 return MBMessagePermission.contains(
064 permissionChecker, classPK, actionId);
065 }
066
067 @Override
068 public boolean isCategorizable() {
069 return false;
070 }
071
072 @Override
073 public boolean isLinkable() {
074 return _LINKABLE;
075 }
076
077 @Override
078 protected String getIconPath(ThemeDisplay themeDisplay) {
079 return themeDisplay.getPathThemeImages() + "/common/conversation.png";
080 }
081
082 private static final boolean _LINKABLE = true;
083
084 }