001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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.kernel.portlet.LiferayPortletRequest;
020    import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
021    import com.liferay.portal.security.permission.PermissionChecker;
022    import com.liferay.portal.theme.ThemeDisplay;
023    import com.liferay.portlet.asset.model.AssetRenderer;
024    import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
025    import com.liferay.portlet.messageboards.model.MBMessage;
026    import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
027    import com.liferay.portlet.messageboards.service.permission.MBMessagePermission;
028    
029    import javax.portlet.PortletURL;
030    
031    /**
032     * @author Julio Camarero
033     * @author Juan Fernández
034     * @author Raymond Augé
035     */
036    public class MBMessageAssetRendererFactory extends BaseAssetRendererFactory {
037    
038            public static final String CLASS_NAME = MBMessage.class.getName();
039    
040            public static final String TYPE = "message";
041    
042            public AssetRenderer getAssetRenderer(long classPK, int type)
043                    throws PortalException, SystemException {
044    
045                    MBMessage message = MBMessageLocalServiceUtil.getMessage(classPK);
046    
047                    return new MBMessageAssetRenderer(message);
048            }
049    
050            public String getClassName() {
051                    return CLASS_NAME;
052            }
053    
054            public String getType() {
055                    return TYPE;
056            }
057    
058            public PortletURL getURLAdd(
059                    LiferayPortletRequest liferayPortletRequest,
060                    LiferayPortletResponse liferayPortletResponse) {
061    
062                    return null;
063            }
064    
065            public boolean hasPermission(
066                            PermissionChecker permissionChecker, long classPK, String actionId)
067                    throws Exception {
068    
069                    return MBMessagePermission.contains(
070                            permissionChecker, classPK, actionId);
071            }
072    
073            protected String getIconPath(ThemeDisplay themeDisplay) {
074                    return themeDisplay.getPathThemeImages() + "/common/conversation.png";
075            }
076    
077    }