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