001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: HttpPresentationRequest.java,v 1.2 2006-06-15 13:40:47 sinisa Exp $
022: */
023:
024: package com.lutris.appserver.server.httpPresentation;
025:
026: import java.util.Enumeration;
027:
028: import javax.servlet.http.Cookie;
029: import javax.servlet.http.HttpServletRequest;
030:
031: /**
032: * Object passed to presentation objects that is used to access HTTP request
033: * data.
034: */
035: public interface HttpPresentationRequest {
036: /**
037: * Returns the original HttpServletRequest.
038: */
039: public HttpServletRequest getHttpServletRequest();
040:
041: /**
042: * Returns the size of the request entity data, or -1 if not known. Same
043: * as the CGI variable CONTENT_LENGTH.
044: */
045: public int getContentLength() throws HttpPresentationException;
046:
047: /**
048: * Returns the Internet Media Type of the request entity data, or null if
049: * not known. Same as the CGI variable CONTENT_TYPE.
050: */
051: public String getContentType() throws HttpPresentationException;
052:
053: /**
054: * Returns the protocol and version of the request as a string of
055: * the form <code><protocol>/<major version>.<minor
056: * version></code>. Same as the CGI variable SERVER_PROTOCOL.
057: */
058: public String getProtocol() throws HttpPresentationException;
059:
060: /**
061: * Returns the scheme of the URL used in this request, for example
062: * "http", "https", or "ftp". Different schemes have different
063: * rules for constructing URLs, as noted in RFC 1738. The URL used
064: * to create a request may be reconstructed using this scheme, the
065: * server name and port, and additional information such as URIs.
066: */
067: public String getScheme();
068:
069: /**
070: * Returns the host name of the server that received the request.
071: * Same as the CGI variable SERVER_NAME.
072: */
073: public String getServerName();
074:
075: /**
076: * Returns the port number on which this request was received.
077: * Same as the CGI variable SERVER_PORT.
078: */
079: public int getServerPort();
080:
081: /**
082: * Returns the IP address of the agent that sent the request. Same as the
083: * CGI variable REMOTE_ADDR.
084: */
085: public String getRemoteAddr() throws HttpPresentationException;
086:
087: /**
088: * Returns the fully qualified host name of the agent that sent the
089: * request. Same as the CGI variable REMOTE_HOST.
090: */
091: public String getRemoteHost() throws HttpPresentationException;
092:
093: /**
094: * Returns an input stream for reading the request body.
095: */
096: public HttpPresentationInputStream getInputStream()
097: throws HttpPresentationException;
098:
099: /**
100: * Returns a string containing the lone value of the specified query
101: * parameter, or null if the parameter does not exist. Presentation
102: * writers should use this method only when they are sure that there is
103: * only one value for the parameter. If the parameter has (or could have)
104: * multiple values, then use getParameterValues. If a multiple valued
105: * parameter name is passed as an argument, the return value is
106: * implementation dependent.
107: *
108: * @param name the name of the parameter whose value is required.
109: * @see HttpPresentationRequest#getParameterValues
110: */
111: public String getParameter(String name)
112: throws HttpPresentationException;
113:
114: /**
115: * Returns the values of the specified query parameter for the request as
116: * an array of strings, or a 0 length array if the named parameter does
117: * not exist.
118: *
119: * @param name the name of the parameter whose value is required.
120: */
121: public String[] getParameterValues(String name)
122: throws HttpPresentationException;
123:
124: /**
125: * Returns the parameter names for this request as an enumeration
126: * of strings, or an empty enumeration if there are no parameters.
127: */
128: public Enumeration getParameterNames()
129: throws HttpPresentationException;
130:
131: //Omitted: public Object getAttribute(String name);
132:
133: /**
134: * Returns the method with which the request was made. The returned
135: * value can be "GET", "HEAD", "POST", or an extension method. Same
136: * as the CGI variable REQUEST_METHOD.
137: */
138: public String getMethod() throws HttpPresentationException;
139:
140: /**
141: * Returns the request URI as a URL.
142: */
143: public String getRequestURI() throws HttpPresentationException;
144:
145: /**
146: * Returns the presentation URI.
147: */
148: public String getPresentationURI() throws HttpPresentationException;
149:
150: /**
151: * Returns the part of the request URI that refers to the application
152: * object being invoked. Analogous to the CGI variable SCRIPT_NAME.
153: *
154: * @deprecated This method was named in a confusing manner; it
155: * returns the application, not presentation object path. Use
156: * <A HREF="getApplicationPath.html">getApplicationPath()</A>.
157: */
158: public String getPresentationPath()
159: throws HttpPresentationException;
160:
161: /**
162: * Returns the part of the request URI that refers to the presentation
163: * object being invoked.
164: */
165: public String getPresentationObjectPath()
166: throws HttpPresentationException;
167:
168: /**
169: * Returns the part of the request URI after the presentation
170: * manager servlet, upto and including the presentation object .po,
171: * but not any path info.
172: */
173: public String getPresentationObjectRelativePath()
174: throws HttpPresentationException;
175:
176: /**
177: * Returns the part of the request URI that refers to the application.
178: * Analogous to the CGI variable SCRIPT_NAME.
179: */
180: public String getApplicationPath() throws HttpPresentationException;
181:
182: /**
183: * Returns optional extra path information following the presentation
184: * path, but immediately preceding the query string. Returns null if
185: * not specified. Same as the CGI variable PATH_INFO.
186: */
187: public String getPathInfo() throws HttpPresentationException;
188:
189: /**
190: * Returns extra path information translated to a real path. Returns
191: * null if no extra path information specified. Same as the CGI variable
192: * PATH_TRANSLATED.
193: */
194: public String getPathTranslated() throws HttpPresentationException;
195:
196: /**
197: * Returns the query string part of the presentation URI, or null if none.
198: * Same as the CGI variable QUERY_STRING.
199: */
200: public String getQueryString() throws HttpPresentationException;
201:
202: /**
203: * Returns the name of the user making this request, or null if not
204: * known. The user name is set with HTTP authentication. Whether
205: * the user name will continue to be sent with each subsequent
206: * communication is browser-dependent. Same as the CGI variable
207: * REMOTE_USER.
208: */
209: public String getRemoteUser() throws HttpPresentationException;
210:
211: /**
212: * Returns the authentication scheme of the request, or null if none.
213: * Same as the CGI variable AUTH_TYPE.
214: */
215: public String getAuthType() throws HttpPresentationException;
216:
217: /**
218: * Gets the array of cookies found in this request.
219: *
220: * @return The array of cookies found in this request.
221: */
222: public Cookie[] getCookies() throws HttpPresentationException;
223:
224: /**
225: * Indicates whether client submitted their session id through a cookie
226: * @return true if client submitted their sessionId via a cookie,
227: * false otherwise
228: */
229: public boolean isRequestedSessionIdFromCookie()
230: throws HttpPresentationException;
231:
232: /*
233: * set the flag indicating whether the sessionId came from a cookie
234: * @param isFromCookie boolean indicating whether sessionId came
235: * from cookie
236: */
237: public void setRequestedSessionIdFromCookie(boolean isFromCookie)
238: throws HttpPresentationException;
239:
240: /**
241: * Indicates whether client submitted their sessionId through a
242: * rewritten url
243: * @return true if client submitted their sessionId via a rewritten url,
244: * false otherwise
245: */
246: public boolean isRequestedSessionIdFromUrl()
247: throws HttpPresentationException;
248:
249: /*
250: * set the flag indicating whether the sessionId came from a url
251: * @param isFromUrl boolean indicating whether sessionId came from url
252: */
253: public void setRequestedSessionIdFromUrl(boolean isFromUrl)
254: throws HttpPresentationException;
255:
256: /**
257: * Returns the value of a header field, or null if not known.
258: * The case of the header field name is ignored.
259: * @param name the case-insensitive header field name
260: */
261: public String getHeader(String name)
262: throws HttpPresentationException;
263:
264: /**
265: * Returns the value of an integer header field, or -1 if not found.
266: * The case of the header field name is ignored.
267: * @param name the case-insensitive header field name
268: */
269: public int getIntHeader(String name)
270: throws HttpPresentationException;
271:
272: /**
273: * Returns the value of a date header field, or -1 if not found.
274: * The case of the header field name is ignored.
275: * @param name the case-insensitive header field name
276: */
277: public long getDateHeader(String name)
278: throws HttpPresentationException;
279:
280: /**
281: * Returns an enumeration of strings representing the header names
282: * for this request. Some server implementations do not allow headers
283: * to be accessed in this way, in which case this method will return null.
284: */
285: public Enumeration getHeaderNames()
286: throws HttpPresentationException;
287:
288: /**
289: * Get the URI path for a file in the application. This converts a path
290: * to the file part of the URL. It adds in the reference to application
291: * servlet.
292: *
293: * @param file File with in the application. Currently this must
294: * be a path relative to the presentation prefix.
295: * @return The file path portion of the URL, starting with
296: * a <CODE>/</CODE>.
297: */
298: public String getAppFileURIPath(String file)
299: throws HttpPresentationException;
300: }
|