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