Source Code Cross Referenced for Request.java in  » GIS » GeoServer » org » vfny » geoserver » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.vfny.geoserver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver;
006:
007:        import org.vfny.geoserver.servlets.AbstractService;
008:        import org.vfny.geoserver.util.Requests;
009:        import javax.servlet.http.HttpServletRequest;
010:
011:        /**
012:         * Defines a general Request type and provides accessor methods for universal
013:         * request information.
014:         * <p>
015:         * Also provides access to the HttpRequest that spawned this GeoServer Request.
016:         * This HttpRequest is most often used to lookup information stored in the
017:         * Web Container (such as the GeoServer Global information).
018:         * </p>
019:         *
020:         * @author Rob Hranac, TOPP
021:         * @author Chris Holmes, TOPP
022:         * @author Gabriel Roldan
023:         * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
024:         * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
025:         * @version $Id: Request.java 7522 2007-09-12 22:00:10Z saul.farber $
026:         */
027:        abstract public class Request {
028:            /**
029:             * HttpServletRequest responsible for generating this GeoServer Request.
030:             */
031:            protected HttpServletRequest httpServletRequest;
032:
033:            /**
034:             * The service type of the request.  In other words, is it a WMS
035:             * or a WFS.  This is a standard element of a request.  It now has
036:             * a practical purpose in GeoServer, as a GetCapabilities request
037:             * can be WMS or WFS, this element tells which it is.
038:             */
039:            protected String service;
040:
041:            /** Request type */
042:            protected String request = "";
043:
044:            /** Request version */
045:            protected String version = "";
046:
047:            /** service reference */
048:            protected AbstractService serviceRef;
049:
050:            /** reference to the base Url that this request was called with.
051:             * Note that this is a complete duplicate of info in the above HttpServletRequest
052:             * object, and is mainly a forward-thinking field that's going to stick around when
053:             * the above HttpServletRequest goes away.
054:             */
055:            protected String baseUrl;
056:
057:            /**
058:             * ServiceType,RequestType,ServiceRef constructor.
059:             *
060:             * @param serviceType Name of hte service (example, WFS)
061:             * @param requestType Name of the request (example, GetCapabilties)
062:             * @param serviceRef The servlet for the request.
063:             */
064:            protected Request(String serviceType, String requestType,
065:                    AbstractService serviceRef) {
066:                this .service = serviceType;
067:                this .request = requestType;
068:                this .serviceRef = serviceRef;
069:            }
070:
071:            /**
072:             * Set the baseUrl that this request was called with.
073:             */
074:            public void setBaseUrl(String s) {
075:                baseUrl = s;
076:            }
077:
078:            /**
079:             * Gets the base url that made this request.  This is used to return the
080:             * referenced schemas and whatnot relative to the request.
081:             * @return The base portion of the url that the client used to make the request.
082:             */
083:            public String getBaseUrl() {
084:                return baseUrl;
085:            }
086:
087:            /**
088:             * Gets requested service.
089:             *
090:             * @return The requested service.
091:             */
092:            public String getService() {
093:                return this .service;
094:            }
095:
096:            /**
097:             * Gets requested service.
098:             *
099:             * @param service The requested service.
100:             */
101:            public void setService(String service) {
102:                this .service = service;
103:            }
104:
105:            /**
106:             * Gets requested request type.
107:             * <p>
108:             * TODO: Could this bre renamed getType() for clarity?
109:             * </p>
110:             * <p>
111:             * Um, no.  getType() is less clear.  getRequest makes sense because
112:             * this is directly modeled off of the XML and KVP Requests that a
113:             * wfs or wms makes, and they all contain an element called Request.
114:             *
115:             * @return The name of the request.
116:             */
117:            public String getRequest() {
118:                return this .request;
119:            }
120:
121:            /**
122:             * Sets requested request type.
123:             *
124:             * @param reqeust The type of request.
125:             */
126:            public void setRequest(String requestType) {
127:                this .request = requestType;
128:            }
129:
130:            /**
131:             * Return version type.
132:             *
133:             * @return The request type version.
134:             */
135:            public String getVersion() {
136:                return this .version;
137:            }
138:
139:            /**
140:             * Sets version type.
141:             *
142:             * @param version The request type version.
143:             */
144:            public void setVersion(String version) {
145:                this .version = version;
146:            }
147:
148:            /**
149:             * Sets the reference to the service.
150:             */
151:            public void setServiceRef(AbstractService serviceRef) {
152:                this .serviceRef = serviceRef;
153:            }
154:
155:            /**
156:             * @return the reference the service.
157:             */
158:            public AbstractService getServiceRef() {
159:                return serviceRef;
160:            }
161:
162:            public boolean equals(Object o) {
163:                if (!(o instanceof  Request)) {
164:                    return false;
165:                }
166:
167:                Request req = (Request) o;
168:                boolean equals = true;
169:                equals = ((request == null) ? (req.getRequest() == null)
170:                        : request.equals(req.getRequest()))
171:                        && equals;
172:                equals = ((version == null) ? (req.getVersion() == null)
173:                        : version.equals(req.getVersion()))
174:                        && equals;
175:                equals = ((service == null) ? (req.getService() == null)
176:                        : service.equals(req.getService()))
177:                        && equals;
178:
179:                return equals;
180:            }
181:
182:            /**
183:             * Generate a hashCode based on this Request Object.
184:             */
185:            public int hashCode() {
186:                int result = 17;
187:                result = (23 * result)
188:                        + ((request == null) ? 0 : request.hashCode());
189:                result = (23 * result)
190:                        + ((request == null) ? 0 : version.hashCode());
191:                result = (23 * result)
192:                        + ((request == null) ? 0 : service.hashCode());
193:
194:                return result;
195:            }
196:
197:            /**
198:             * Retrive the ServletRequest that generated this GeoServer request.
199:             * <p>
200:             * The ServletRequest is often used to:
201:             * </p>
202:             * <ul>
203:             * <li>Access the Sesssion and WebContainer by execute opperations
204:             *     </li>
205:             * <li>Of special importance is the use of the ServletRequest to locate the GeoServer Application
206:             *     </li>
207:             * </p>
208:             * <p>
209:             * This method is called by AbstractServlet during the processing of a Request.
210:             * </p>
211:             * @return The HttpServletRequest responsible for generating this SerivceRequest
212:             */
213:            public HttpServletRequest getHttpServletRequest()
214:                    throws ClassCastException {
215:                return httpServletRequest;
216:            }
217:
218:            //JD: delete this
219:            //	public WMS getWMS(){
220:            //		WMS vp = Requests.getWMS( getHttpServletRequest() );
221:            //		return vp;
222:            //	}
223:            //	
224:            //	public WFS getWFS(){
225:            //		WFS vp = Requests.getWFS( getHttpServletRequest() );
226:            //		return vp;
227:            //	}
228:            public String getRootDir() {
229:                throw new IllegalArgumentException(
230:                        "getRootDir -- functionality removed - please verify that its okay with geoserver_data_dir");
231:
232:                //return httpServletRequest.getSession().getServletContext().getRealPath("/");
233:            }
234:
235:            /**
236:             * Gets the url that schemas should be referenced from.  For now this will
237:             * always be local, if we bring back schemaBaseUrl as a param then that will
238:             * be possible too.  So it is just baseUrl plus data/capabilities, which
239:             * is where we store the schemas now.
240:             *
241:             * @return the base url of the schemas.  Will be getBaseUrl() + data/capabilities.
242:             */
243:            public String getSchemaBaseUrl() {
244:                return Requests.getSchemaBaseUrl(getHttpServletRequest(),
245:                        serviceRef.getGeoServer());
246:            }
247:
248:            /**
249:             * Whether this request was sent through one of the dispatchers, or if
250:             * it went directly through the servlet.  This is used by the capabilities
251:             * response, since we give back a dispatched capabilities document to clients
252:             * who request it with a dispatcher.
253:             * @return true if the request came through a dispatcher.
254:             */
255:            public boolean isDispatchedRequest() {
256:                HttpServletRequest hsr = getHttpServletRequest();
257:
258:                // will happen if the dispatcher was called, as opposed to using the /wfs url.
259:                String uri = hsr.getRequestURI();
260:
261:                if (uri != null) {
262:                    uri = uri.toLowerCase();
263:                }
264:
265:                // will happen if the dispatcher was called, as opposed to using the /wfs url.
266:                if (uri.endsWith("/wcs") || uri.endsWith("/wfs")
267:                        || uri.endsWith("/wms")) {
268:                    return true;
269:                }
270:
271:                return false;
272:            }
273:
274:            /**
275:             * Tests if user is Logged into GeoServer.
276:             *
277:             * @return <code>true</code> if user is logged in
278:             */
279:            public boolean isLoggedIn() {
280:                return Requests.isLoggedIn(getHttpServletRequest());
281:            }
282:
283:            /**
284:             * Sets the servletRequest that generated this GeoServer request.
285:             * <p>
286:             * The ServletRequest is often used to:
287:             * </p>
288:             * <ul>
289:             * <li>Access the Sesssion and WebContainer by execute opperations
290:             *     </li>
291:             * <li>Of special importance is the use of the ServletRequest to locate the GeoServer Application
292:             *     </li>
293:             * </p>
294:             * @param servletRequest The servletRequest to set.
295:             */
296:            public void setHttpServletRequest(HttpServletRequest servletRequest) {
297:                httpServletRequest = servletRequest;
298:            }
299:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.