1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.portlet.LiferayRenderResponse;
20  import com.liferay.portal.theme.PortletDisplay;
21  import com.liferay.portal.theme.ThemeDisplay;
22  import com.liferay.portal.util.WebKeys;
23  
24  import java.util.Collection;
25  
26  import javax.portlet.PortletMode;
27  import javax.portlet.PortletRequest;
28  
29  import javax.servlet.http.HttpServletResponse;
30  
31  /**
32   * <a href="RenderResponseImpl.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   * @author Eduardo Lundgren
36   */
37  public class RenderResponseImpl
38      extends MimeResponseImpl implements LiferayRenderResponse {
39  
40      public String getLifecycle() {
41          return PortletRequest.RENDER_PHASE;
42      }
43  
44      public String getResourceName() {
45          return _resourceName;
46      }
47  
48      public String getTitle() {
49          return _title;
50      }
51  
52      public Boolean getUseDefaultTemplate() {
53          return _useDefaultTemplate;
54      }
55  
56      public void setResourceName(String resourceName) {
57          _resourceName = resourceName;
58      }
59  
60      public void setNextPossiblePortletModes(
61          Collection<PortletMode> portletModes) {
62      }
63  
64      public void setTitle(String title) {
65          _title = title;
66  
67          // See LEP-2188
68  
69          ThemeDisplay themeDisplay =
70              (ThemeDisplay)_portletRequestImpl.getAttribute(
71                  WebKeys.THEME_DISPLAY);
72  
73          PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
74  
75          portletDisplay.setTitle(_title);
76      }
77  
78      public void setUseDefaultTemplate(Boolean useDefaultTemplate) {
79          _useDefaultTemplate = useDefaultTemplate;
80      }
81  
82      protected RenderResponseImpl() {
83          if (_log.isDebugEnabled()) {
84              _log.debug("Creating new instance " + hashCode());
85          }
86      }
87  
88      protected void init(
89          PortletRequestImpl portletRequestImpl, HttpServletResponse response,
90          String portletName, long companyId, long plid) {
91  
92          super.init(portletRequestImpl, response, portletName, companyId, plid);
93  
94          _portletRequestImpl = portletRequestImpl;
95      }
96  
97      protected void recycle() {
98          if (_log.isDebugEnabled()) {
99              _log.debug("Recycling instance " + hashCode());
100         }
101 
102         super.recycle();
103 
104         _portletRequestImpl = null;
105         _title = null;
106         _useDefaultTemplate = null;
107         _resourceName = null;
108     }
109 
110     private static Log _log = LogFactoryUtil.getLog(RenderResponseImpl.class);
111 
112     private PortletRequestImpl _portletRequestImpl;
113     private String _title;
114     private Boolean _useDefaultTemplate;
115     private String _resourceName;
116 
117 }