1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.portlet.LiferayRenderResponse;
26  import com.liferay.portal.theme.PortletDisplay;
27  import com.liferay.portal.theme.ThemeDisplay;
28  import com.liferay.portal.util.WebKeys;
29  
30  import java.util.Collection;
31  
32  import javax.portlet.PortletMode;
33  import javax.portlet.PortletRequest;
34  
35  import javax.servlet.http.HttpServletResponse;
36  
37  import org.apache.commons.logging.Log;
38  import org.apache.commons.logging.LogFactory;
39  
40  /**
41   * <a href="RenderResponseImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * @author Brian Wing Shun Chan
44   *
45   */
46  public class RenderResponseImpl
47      extends MimeResponseImpl implements LiferayRenderResponse {
48  
49      public String getLifecycle() {
50          return PortletRequest.RENDER_PHASE;
51      }
52  
53      public String getResourceName() {
54          return _resourceName;
55      }
56  
57      public String getTitle() {
58          return _title;
59      }
60  
61      public Boolean getUseDefaultTemplate() {
62          return _useDefaultTemplate;
63      }
64  
65      public void setResourceName(String resourceName) {
66          _resourceName = resourceName;
67      }
68  
69      public void setNextPossiblePortletModes(
70          Collection<PortletMode> portletModes) {
71      }
72  
73      public void setTitle(String title) {
74          _title = title;
75  
76          // See LEP-2188
77  
78          ThemeDisplay themeDisplay =
79              (ThemeDisplay)_portletRequestImpl.getAttribute(
80                  WebKeys.THEME_DISPLAY);
81  
82          PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
83  
84          portletDisplay.setTitle(_title);
85      }
86  
87      public void setUseDefaultTemplate(Boolean useDefaultTemplate) {
88          _useDefaultTemplate = useDefaultTemplate;
89      }
90  
91      protected RenderResponseImpl() {
92          if (_log.isDebugEnabled()) {
93              _log.debug("Creating new instance " + hashCode());
94          }
95      }
96  
97      protected void init(
98          PortletRequestImpl portletRequestImpl, HttpServletResponse response,
99          String portletName, long companyId, long plid) {
100 
101         super.init(portletRequestImpl, response, portletName, companyId, plid);
102 
103         _portletRequestImpl = portletRequestImpl;
104     }
105 
106     protected void recycle() {
107         if (_log.isDebugEnabled()) {
108             _log.debug("Recycling instance " + hashCode());
109         }
110 
111         super.recycle();
112 
113         _portletRequestImpl = null;
114         _title = null;
115         _useDefaultTemplate = null;
116         _resourceName = null;
117     }
118 
119     private static Log _log = LogFactory.getLog(RenderResponseImpl.class);
120 
121     private PortletRequestImpl _portletRequestImpl;
122     private String _title;
123     private Boolean _useDefaultTemplate;
124     private String _resourceName;
125 
126 }