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