001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet;
022:
023: import java.util.Locale;
024:
025: import javax.portlet.ActionResponse;
026: import javax.portlet.PortletResponse;
027: import javax.portlet.RenderResponse;
028:
029: import javax.servlet.http.HttpServletResponse;
030: import javax.servlet.http.HttpServletResponseWrapper;
031:
032: /**
033: * <a href="PortletServletResponse.java.html"><b><i>View Source</i></b></a>
034: *
035: * @author Brian Wing Shun Chan
036: *
037: */
038: public class PortletServletResponse extends HttpServletResponseWrapper {
039:
040: public PortletServletResponse(HttpServletResponse res,
041: PortletResponse portletResponse) {
042:
043: super (res);
044:
045: _portletResponse = portletResponse;
046:
047: if (_portletResponse instanceof ActionResponse) {
048: _action = true;
049: } else {
050: _action = false;
051: }
052: }
053:
054: public String encodeRedirectUrl(String url) {
055: return encodeRedirectURL(url);
056: }
057:
058: public String encodeRedirectURL(String url) {
059: return null;
060: }
061:
062: public String encodeUrl(String path) {
063: return encodeURL(path);
064: }
065:
066: public String encodeURL(String path) {
067: if (_action) {
068: throw new UnsupportedOperationException();
069: } else {
070: RenderResponse res = (RenderResponse) _portletResponse;
071:
072: return res.encodeURL(path);
073: }
074: }
075:
076: public Locale getLocale() {
077: if (_action) {
078: return null;
079: } else {
080: RenderResponse res = (RenderResponse) _portletResponse;
081:
082: return res.getLocale();
083: }
084: }
085:
086: public int getBufferSize() {
087: if (_action) {
088: return 0;
089: } else {
090: RenderResponse res = (RenderResponse) _portletResponse;
091:
092: return res.getBufferSize();
093: }
094: }
095:
096: public boolean isCommitted() {
097: if (_action) {
098: return false;
099: } else {
100: RenderResponse res = (RenderResponse) _portletResponse;
101:
102: return res.isCommitted();
103: }
104: }
105:
106: private PortletResponse _portletResponse;
107: private boolean _action;
108:
109: }
|