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.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(long groupId) {
039                    return getPortletDisplayTemplate().getDDMTemplateGroupId(groupId);
040            }
041    
042            public static String getDDMTemplateUuid(String displayStyle) {
043                    return getPortletDisplayTemplate().getDDMTemplateUuid(displayStyle);
044            }
045    
046            public static PortletDisplayTemplate getPortletDisplayTemplate() {
047                    PortalRuntimePermission.checkGetBeanProperty(
048                            PortletDisplayTemplate.class);
049    
050                    return _portletDisplayTemplate;
051            }
052    
053            public static long getPortletDisplayTemplateDDMTemplateId(
054                    long groupId, String displayStyle) {
055    
056                    return
057                            getPortletDisplayTemplate().getPortletDisplayTemplateDDMTemplateId(
058                                    groupId, displayStyle);
059            }
060    
061            public static Map<String, TemplateVariableGroup>
062                    getTemplateVariableGroups(String language) {
063    
064                    return getPortletDisplayTemplate().getTemplateVariableGroups(language);
065            }
066    
067            public static String renderDDMTemplate(
068                            PageContext pageContext, long ddmTemplateId, List<?> entries)
069                    throws Exception {
070    
071                    return getPortletDisplayTemplate().renderDDMTemplate(
072                            pageContext, ddmTemplateId, entries);
073            }
074    
075            public static String renderDDMTemplate(
076                            PageContext pageContext, long ddmTemplateId, List<?> entries,
077                            Map<String, Object> contextObjects)
078                    throws Exception {
079    
080                    return getPortletDisplayTemplate().renderDDMTemplate(
081                            pageContext, ddmTemplateId, entries, contextObjects);
082            }
083    
084            public void setPortletDisplayTemplate(
085                    PortletDisplayTemplate portletDisplayTemplate) {
086    
087                    PortalRuntimePermission.checkSetBeanProperty(getClass());
088    
089                    _portletDisplayTemplate = portletDisplayTemplate;
090            }
091    
092            private static PortletDisplayTemplate _portletDisplayTemplate;
093    
094    }