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.layoutconfiguration.util;
016    
017    import com.liferay.portal.model.Portlet;
018    import com.liferay.portlet.layoutconfiguration.util.xml.RuntimeLogic;
019    
020    import javax.portlet.RenderRequest;
021    import javax.portlet.RenderResponse;
022    
023    import javax.servlet.ServletContext;
024    import javax.servlet.http.HttpServletRequest;
025    import javax.servlet.http.HttpServletResponse;
026    import javax.servlet.jsp.JspWriter;
027    import javax.servlet.jsp.PageContext;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     * @author Raymond Augé
032     * @author Shuyang Zhou
033     */
034    public class RuntimePortletUtil {
035    
036            public static RuntimePortlet getRuntimePortlet() {
037                    return _runtimePortlet;
038            }
039    
040            public static String processCustomizationSettings(
041                            ServletContext servletContext, HttpServletRequest request,
042                            HttpServletResponse response, PageContext pageContext,
043                            String velocityTemplateId, String velocityTemplateContent)
044                    throws Exception {
045    
046                    return getRuntimePortlet().processCustomizationSettings(
047                            servletContext, request, response, pageContext, velocityTemplateId,
048                            velocityTemplateContent);
049            }
050    
051            public static String processPortlet(
052                            ServletContext servletContext, HttpServletRequest request,
053                            HttpServletResponse response, Portlet portlet, String queryString,
054                            String columnId, Integer columnPos, Integer columnCount,
055                            String path, boolean writeOutput)
056                    throws Exception {
057    
058                    return getRuntimePortlet().processPortlet(
059                            servletContext, request, response, portlet, queryString, columnId,
060                            columnPos, columnCount, path, writeOutput);
061            }
062    
063            public static String processPortlet(
064                            ServletContext servletContext, HttpServletRequest request,
065                            HttpServletResponse response, RenderRequest renderRequest,
066                            RenderResponse renderResponse, Portlet portlet, String portletId,
067                            String queryString, String columnId, Integer columnPos,
068                            Integer columnCount, String path, boolean writeOutput)
069                    throws Exception {
070    
071                    return getRuntimePortlet().processPortlet(
072                            servletContext, request, response, renderRequest, renderResponse,
073                            portlet, portletId, queryString, columnId, columnPos, columnCount,
074                            path, writeOutput);
075            }
076    
077            public static String processPortlet(
078                            ServletContext servletContext, HttpServletRequest request,
079                            HttpServletResponse response, RenderRequest renderRequest,
080                            RenderResponse renderResponse, String portletId, String queryString,
081                            boolean writeOutput)
082                    throws Exception {
083    
084                    return getRuntimePortlet().processPortlet(
085                            servletContext, request, response, renderRequest, renderResponse,
086                            portletId, queryString, writeOutput);
087            }
088    
089            public static String processPortlet(
090                            ServletContext servletContext, HttpServletRequest request,
091                            HttpServletResponse response, RenderRequest renderRequest,
092                            RenderResponse renderResponse, String portletId, String queryString,
093                            String columnId, Integer columnPos, Integer columnCount,
094                            boolean writeOutput)
095                    throws Exception {
096    
097                    return getRuntimePortlet().processPortlet(
098                            servletContext, request, response, renderRequest, renderResponse,
099                            portletId, queryString, columnId, columnPos, columnCount,
100                            writeOutput);
101            }
102    
103            public static void processTemplate(
104                            ServletContext servletContext, HttpServletRequest request,
105                            HttpServletResponse response, PageContext pageContext,
106                            JspWriter jspWriter, String velocityTemplateId,
107                            String velocityTemplateContent)
108                    throws Exception {
109    
110                    getRuntimePortlet().processTemplate(
111                            servletContext, request, response, pageContext, jspWriter,
112                            velocityTemplateId, velocityTemplateContent);
113            }
114    
115            public static void processTemplate(
116                            ServletContext servletContext, HttpServletRequest request,
117                            HttpServletResponse response, PageContext pageContext,
118                            JspWriter jspWriter, String portletId, String velocityTemplateId,
119                            String velocityTemplateContent)
120                    throws Exception {
121    
122                    getRuntimePortlet().processTemplate(
123                            servletContext, request, response, pageContext, jspWriter,
124                            portletId, velocityTemplateId, velocityTemplateContent);
125            }
126    
127            public static String processXML(
128                            HttpServletRequest request, String content,
129                            RuntimeLogic runtimeLogic)
130                    throws Exception {
131    
132                    return getRuntimePortlet().processXML(request, content, runtimeLogic);
133            }
134    
135            public void setRuntimePortlet(RuntimePortlet runtimePortlet) {
136                    _runtimePortlet = runtimePortlet;
137            }
138    
139            private static RuntimePortlet _runtimePortlet;
140    
141    }