001: package com.sun.portal.desktop;
002:
003: import java.util.*;
004: import java.util.logging.Logger;
005: import java.util.logging.Level;
006: import java.text.*;
007: import java.net.*;
008: import java.io.*;
009: import javax.servlet.*;
010: import javax.servlet.http.*;
011:
012: import com.sun.portal.desktop.context.DesktopAppContext;
013: import com.sun.portal.desktop.util.I18n;
014: import com.sun.portal.desktop.util.NSStringBuffer;
015: import com.sun.portal.desktop.util.PIParser;
016: import com.sun.portal.log.common.PortalLogger;
017:
018: /**
019: * A DesktopRequest encapsulates the HttpServletRequest that is passed
020: * to the provider, hiding and redefining those methods that are
021: * inappropriate to be called by a provider.
022: */
023:
024: public class DesktopPortletRequest implements HttpServletRequest {
025: private DesktopRequest dreq;
026: private Hashtable portletParams;
027:
028: public DesktopPortletRequest(DesktopRequest request,
029: Hashtable portletParams) {
030: dreq = request;
031: this .portletParams = portletParams;
032: }
033:
034: /* HttpServletRequest methods */
035:
036: public Map getParameterMap() {
037: return portletParams;
038: }
039:
040: public String getAuthType() {
041: return dreq.getAuthType();
042: }
043:
044: public String getContextPath() {
045: return dreq.getContextPath();
046: }
047:
048: public Cookie[] getCookies() {
049: return dreq.getCookies();
050: }
051:
052: public long getDateHeader(String name) {
053: return dreq.getDateHeader(name);
054: }
055:
056: public String getHeader(String name) {
057: return dreq.getHeader(name);
058: }
059:
060: public Enumeration getHeaderNames() {
061: return dreq.getHeaderNames();
062: }
063:
064: public Enumeration getHeaders(String name) {
065: return dreq.getHeaders(name);
066: }
067:
068: public int getIntHeader(String name) {
069: return dreq.getIntHeader(name);
070: }
071:
072: public String getMethod() {
073: return dreq.getMethod();
074: }
075:
076: public String getPathInfo() {
077: return dreq.getPathInfo();
078: }
079:
080: public String getPathTranslated() {
081: return dreq.getPathTranslated();
082: }
083:
084: public String getQueryString() {
085: return dreq.getQueryString();
086: }
087:
088: public String getRemoteUser() {
089: return dreq.getRemoteUser();
090: }
091:
092: public String getRequestedSessionId() {
093: return dreq.getRequestedSessionId();
094: }
095:
096: public String getRequestURI() {
097: return dreq.getRequestURI();
098: }
099:
100: public String getServletPath() {
101: return dreq.getServletPath();
102: }
103:
104: public HttpSession getSession() {
105: return dreq.getSession();
106: }
107:
108: public HttpSession getSession(boolean create) {
109: return dreq.getSession(create);
110: }
111:
112: public java.security.Principal getUserPrincipal() {
113: return dreq.getUserPrincipal();
114: }
115:
116: public boolean isRequestedSessionIdFromCookie() {
117: return dreq.isRequestedSessionIdFromCookie();
118: }
119:
120: /**
121: * @deprecated
122: */
123: public boolean isRequestedSessionIdFromUrl() {
124: return dreq.isRequestedSessionIdFromUrl();
125: }
126:
127: public boolean isRequestedSessionIdFromURL() {
128: return dreq.isRequestedSessionIdFromURL();
129: }
130:
131: public boolean isRequestedSessionIdValid() {
132: return dreq.isRequestedSessionIdValid();
133: }
134:
135: public boolean isUserInRole(String role) {
136: return dreq.isUserInRole(role);
137: }
138:
139: /* ServletRequest methods */
140:
141: public Object getAttribute(String name) {
142: return dreq.getAttribute(name);
143: }
144:
145: public Enumeration getAttributeNames() {
146: return dreq.getAttributeNames();
147: }
148:
149: public String getCharacterEncoding() {
150: return dreq.getCharacterEncoding();
151: }
152:
153: public int getContentLength() {
154: return dreq.getContentLength();
155: }
156:
157: public String getContentType() {
158: return dreq.getContentType();
159: }
160:
161: public ServletInputStream getInputStream() throws IOException {
162: return dreq.getInputStream();
163: }
164:
165: public Locale getLocale() {
166: return dreq.getLocale();
167: }
168:
169: public Enumeration getLocales() {
170: return dreq.getLocales();
171: }
172:
173: public String getParameter(String name) {
174: String values[] = (String[]) portletParams.get(name);
175: if (values != null && values.length >= 1) {
176: return values[0];
177: }
178: return null;
179: }
180:
181: public Enumeration getParameterNames() {
182: return portletParams.keys();
183: }
184:
185: public String[] getParameterValues(String name) {
186: return (String[]) portletParams.get(name);
187: }
188:
189: public String getProtocol() {
190: return dreq.getProtocol();
191: }
192:
193: public synchronized BufferedReader getReader() throws IOException {
194: return dreq.getReader();
195: }
196:
197: /**
198: * @deprecated As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(String) instead.
199: */
200: public String getRealPath(String path) {
201: return dreq.getRealPath(path);
202:
203: }
204:
205: public String getRemoteAddr() {
206: return dreq.getRemoteAddr();
207: }
208:
209: public String getRemoteHost() {
210: return dreq.getRemoteHost();
211: }
212:
213: public RequestDispatcher getRequestDispatcher(String path) {
214: return dreq.getRequestDispatcher(path);
215: }
216:
217: public String getScheme() {
218: return dreq.getScheme();
219: }
220:
221: public String getServerName() {
222: return dreq.getServerName();
223: }
224:
225: public int getServerPort() {
226: return dreq.getServerPort();
227: }
228:
229: public boolean isSecure() {
230: return dreq.isSecure();
231: }
232:
233: public void removeAttribute(String name) {
234: dreq.removeAttribute(name);
235: }
236:
237: public void setAttribute(String name, Object o) {
238: dreq.setAttribute(name, o);
239: }
240:
241: /*
242: * Added as part of upgradation to servlet2.3 spec
243: */
244:
245: public StringBuffer getRequestURL() {
246: return dreq.getRequestURL();
247: }
248:
249: public void setCharacterEncoding(String env)
250: throws UnsupportedEncodingException {
251: dreq.setCharacterEncoding(env);
252: }
253:
254: }
|