001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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.theme.ThemeDisplay;
022    import com.liferay.portlet.asset.model.AssetRenderer;
023    import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
024    import com.liferay.portlet.messageboards.model.MBMessage;
025    import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
026    
027    import javax.portlet.PortletURL;
028    
029    /**
030     * @author Julio Camarero
031     * @author Juan Fernández
032     */
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            public AssetRenderer getAssetRenderer(long classPK, int type)
040                    throws PortalException, SystemException {
041    
042                    MBMessage message = MBMessageLocalServiceUtil.getMessage(classPK);
043    
044                    return new MBMessageAssetRenderer(message);
045            }
046    
047            public String getClassName() {
048                    return CLASS_NAME;
049            }
050    
051            public String getType() {
052                    return TYPE;
053            }
054    
055            public PortletURL getURLAdd(
056                    LiferayPortletRequest liferayPortletRequest,
057                    LiferayPortletResponse liferayPortletResponse) {
058    
059                    return null;
060            }
061    
062            protected String getIconPath(ThemeDisplay themeDisplay) {
063                    return themeDisplay.getPathThemeImages() + "/common/conversation.png";
064            }
065    
066    }