001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }