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