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.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.theme.ThemeDisplay;
024    
025    import javax.portlet.PortletRequest;
026    import javax.portlet.PortletURL;
027    
028    /**
029     * @author Jorge Ferrer
030     * @author Juan Fernández
031     * @author Raymond Augé
032     */
033    public abstract class BaseAssetRendererFactory implements AssetRendererFactory {
034    
035            public AssetRenderer getAssetRenderer(long classPK)
036                    throws PortalException, SystemException {
037    
038                    return getAssetRenderer(classPK, TYPE_LATEST_APPROVED);
039            }
040    
041            /**
042             * @throws PortalException
043             * @throws SystemException
044             */
045            public AssetRenderer getAssetRenderer(long groupId, String urlTitle)
046                    throws PortalException, SystemException {
047    
048                    return null;
049            }
050    
051            public long getClassNameId() {
052                    return _classNameId;
053            }
054    
055            public String getIconPath(PortletRequest portletRequest) {
056                    ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
057                            WebKeys.THEME_DISPLAY);
058    
059                    return getIconPath(themeDisplay);
060            }
061    
062            public String getPortletId() {
063                    return _portletId;
064            }
065    
066            public PortletURL getURLAdd(
067                    LiferayPortletRequest liferayPortletRequest,
068                    LiferayPortletResponse liferayPortletResponse) {
069    
070                    return null;
071            }
072    
073            public boolean hasPermission(
074                            PermissionChecker permissionChecker, long classPK, String actionId)
075                    throws Exception {
076    
077                    return true;
078            }
079    
080            public boolean isSelectable() {
081                    return true;
082            }
083    
084            public void setClassNameId(long classNameId) {
085                    _classNameId = classNameId;
086            }
087    
088            public void setPortletId(String portletId) {
089                    _portletId = portletId;
090            }
091    
092            protected String getIconPath(ThemeDisplay themeDisplay) {
093                    return themeDisplay.getPathThemeImages() + "/common/page.png";
094            }
095    
096            private long _classNameId;
097            private String _portletId;
098    
099    }