001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet;
016    
017    import com.liferay.portal.kernel.portlet.LiferayRenderResponse;
018    import com.liferay.portal.theme.PortletDisplay;
019    import com.liferay.portal.theme.ThemeDisplay;
020    import com.liferay.portal.util.WebKeys;
021    
022    import java.util.Collection;
023    
024    import javax.portlet.PortletMode;
025    import javax.portlet.PortletRequest;
026    
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     * @author Eduardo Lundgren
032     */
033    public class RenderResponseImpl
034            extends MimeResponseImpl implements LiferayRenderResponse {
035    
036            @Override
037            public String getLifecycle() {
038                    return PortletRequest.RENDER_PHASE;
039            }
040    
041            public String getResourceName() {
042                    return _resourceName;
043            }
044    
045            public String getTitle() {
046                    return _title;
047            }
048    
049            public Boolean getUseDefaultTemplate() {
050                    return _useDefaultTemplate;
051            }
052    
053            @Override
054            public void setNextPossiblePortletModes(
055                    Collection<PortletMode> portletModes) {
056            }
057    
058            @Override
059            public void setResourceName(String resourceName) {
060                    _resourceName = resourceName;
061            }
062    
063            @Override
064            public void setTitle(String title) {
065                    _title = title;
066    
067                    // See LEP-2188
068    
069                    ThemeDisplay themeDisplay =
070                            (ThemeDisplay)_portletRequestImpl.getAttribute(
071                                    WebKeys.THEME_DISPLAY);
072    
073                    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
074    
075                    portletDisplay.setTitle(_title);
076            }
077    
078            public void setUseDefaultTemplate(Boolean useDefaultTemplate) {
079                    _useDefaultTemplate = useDefaultTemplate;
080            }
081    
082            @Override
083            protected void init(
084                    PortletRequestImpl portletRequestImpl, HttpServletResponse response,
085                    String portletName, long companyId, long plid) {
086    
087                    super.init(portletRequestImpl, response, portletName, companyId, plid);
088    
089                    _portletRequestImpl = portletRequestImpl;
090            }
091    
092            private PortletRequestImpl _portletRequestImpl;
093            private String _resourceName;
094            private String _title;
095            private Boolean _useDefaultTemplate;
096    
097    }