001
014
015 package com.liferay.portlet.layoutconfiguration.util.velocity;
016
017 import com.liferay.portal.kernel.util.Validator;
018 import com.liferay.portal.model.PortletConstants;
019 import com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil;
020
021 import java.util.Map;
022
023 import javax.portlet.RenderRequest;
024 import javax.portlet.RenderResponse;
025
026 import javax.servlet.ServletContext;
027 import javax.servlet.http.HttpServletRequest;
028 import javax.servlet.http.HttpServletResponse;
029
030
034 public class PortletLogic extends RuntimeLogic {
035
036 public PortletLogic(
037 ServletContext servletContext, HttpServletRequest request,
038 HttpServletResponse response, String portletId) {
039
040 this(servletContext, request, response, null, null);
041
042 _portletId = portletId;
043 }
044
045 public PortletLogic(
046 ServletContext servletContext, HttpServletRequest request,
047 HttpServletResponse response, RenderRequest renderRequest,
048 RenderResponse renderResponse) {
049
050 _servletContext = servletContext;
051 _request = request;
052 _response = response;
053 _renderRequest = renderRequest;
054 _renderResponse = renderResponse;
055 }
056
057 public String processContent(Map<String, String> attributes)
058 throws Exception {
059
060 String rootPortletId = attributes.get("name");
061 String instanceId = attributes.get("instance");
062 String queryString = attributes.get("queryString");
063
064 String portletId = _portletId;
065
066 if (portletId == null) {
067 portletId = rootPortletId;
068
069 if (Validator.isNotNull(instanceId)) {
070 portletId += PortletConstants.INSTANCE_SEPARATOR + instanceId;
071 }
072 }
073
074 return RuntimePortletUtil.processPortlet(
075 _servletContext, _request, _response, _renderRequest,
076 _renderResponse, portletId, queryString, false);
077 }
078
079 private ServletContext _servletContext;
080 private HttpServletRequest _request;
081 private HttpServletResponse _response;
082 private RenderRequest _renderRequest;
083 private RenderResponse _renderResponse;
084 private String _portletId;
085
086 }