001    /**
002     * Copyright (c) 2000-2012 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.portletdisplaytemplate.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.theme.ThemeDisplay;
019    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
020    
021    import java.util.List;
022    import java.util.Map;
023    
024    import javax.servlet.jsp.PageContext;
025    
026    /**
027     * @author Eduardo Garcia
028     */
029    public class PortletDisplayTemplateUtil {
030    
031            public static DDMTemplate fetchDDMTemplate(
032                    long groupId, String displayStyle) {
033    
034                    return getPortletDisplayTemplate().fetchDDMTemplate(
035                            groupId, displayStyle);
036            }
037    
038            public static long getDDMTemplateGroupId(ThemeDisplay themeDisplay) {
039                    return getPortletDisplayTemplate().getDDMTemplateGroupId(themeDisplay);
040            }
041    
042            public static PortletDisplayTemplate getPortletDisplayTemplate() {
043                    PortalRuntimePermission.checkGetBeanProperty(
044                            PortletDisplayTemplate.class);
045    
046                    return _portletDisplayTemplate;
047            }
048    
049            public static long getPortletDisplayTemplateDDMTemplateId(
050                    ThemeDisplay themeDisplay, String displayStyle) {
051    
052                    return
053                            getPortletDisplayTemplate().getPortletDisplayTemplateDDMTemplateId(
054                                    themeDisplay, displayStyle);
055            }
056    
057            public static String renderDDMTemplate(
058                            PageContext pageContext, long ddmTemplateId, List<?> entries)
059                    throws Exception {
060    
061                    return getPortletDisplayTemplate().renderDDMTemplate(
062                            pageContext, ddmTemplateId, entries);
063            }
064    
065            public static String renderDDMTemplate(
066                            PageContext pageContext, long ddmTemplateId, List<?> entries,
067                            Map<String, Object> contextObjects)
068                    throws Exception {
069    
070                    return getPortletDisplayTemplate().renderDDMTemplate(
071                            pageContext, ddmTemplateId, entries, contextObjects);
072            }
073    
074            public void setPortletDisplayTemplate(
075                    PortletDisplayTemplate portletDisplayTemplate) {
076    
077                    PortalRuntimePermission.checkSetBeanProperty(getClass());
078    
079                    _portletDisplayTemplate = portletDisplayTemplate;
080            }
081    
082            private static PortletDisplayTemplate _portletDisplayTemplate;
083    
084    }