Source Code Cross Referenced for WMSCapabilitiesResponse.java in  » GIS » GeoServer » org » vfny » geoserver » wms » responses » 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.wms.responses 
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.wms.responses;
006:
007:        import java.io.ByteArrayOutputStream;
008:        import java.io.IOException;
009:        import java.io.OutputStream;
010:        import java.util.HashMap;
011:        import java.util.Set;
012:        import java.util.logging.Logger;
013:
014:        import javax.xml.transform.TransformerException;
015:
016:        import org.springframework.context.ApplicationContext;
017:        import org.vfny.geoserver.Request;
018:        import org.vfny.geoserver.Response;
019:        import org.vfny.geoserver.ServiceException;
020:        import org.vfny.geoserver.global.GeoServer;
021:        import org.vfny.geoserver.global.Service;
022:        import org.vfny.geoserver.util.requests.CapabilitiesRequest;
023:        import org.vfny.geoserver.wms.WmsException;
024:        import org.vfny.geoserver.wms.responses.helpers.WMSCapsTransformer;
025:
026:        /**
027:         * Processes a WMS GetCapabilities request.
028:         * <p>
029:         * The response of a GetCapabilities request is general information about the
030:         * service itself and specific information about the available maps.
031:         * </p>
032:         *
033:         * @author Gabriel Roldan, Axios Engineering
034:         * @version $Id: WMSCapabilitiesResponse.java 8477 2008-02-28 15:00:23Z aaime $
035:         */
036:        public class WMSCapabilitiesResponse implements  Response {
037:            /** package's logger */
038:            private static final Logger LOGGER = org.geotools.util.logging.Logging
039:                    .getLogger(WMSCapabilitiesResponse.class.getPackage()
040:                            .getName());
041:
042:            /**
043:             * Byte array holding the raw content of the capabilities document,
044:             * generated in <code>execute()</code>
045:             */
046:            private byte[] rawResponse;
047:
048:            /**
049:             * List of formats accessible via a GetMap request.
050:             */
051:            private Set formats;
052:            private ApplicationContext applicationContext;
053:
054:            public WMSCapabilitiesResponse(Set wmsGetMapFormats,
055:                    ApplicationContext applicationContext) {
056:                this .formats = wmsGetMapFormats;
057:                this .applicationContext = applicationContext;
058:            }
059:
060:            /**
061:             * Returns any extra headers that this service might want to set in the HTTP response object.
062:             * @see org.vfny.geoserver.Response#getResponseHeaders()
063:             */
064:            public HashMap getResponseHeaders() {
065:                return null;
066:            }
067:
068:            /**
069:             * DOCUMENT ME!
070:             *
071:             * @param request DOCUMENT ME!
072:             *
073:             * @throws ServiceException DOCUMENT ME!
074:             * @throws IllegalArgumentException DOCUMENT ME!
075:             * @throws WmsException DOCUMENT ME!
076:             */
077:            public void execute(Request request) throws ServiceException {
078:                if (!(request instanceof  CapabilitiesRequest)) {
079:                    throw new IllegalArgumentException(
080:                            "Not a GetCapabilities Request");
081:                }
082:
083:                //UpdateSequence handling for WMS:  see WMS 1.1.1 page 23
084:                CapabilitiesRequest capreq = (CapabilitiesRequest) request;
085:                int reqUS = -1;
086:                if (capreq.getUpdateSequence() != null
087:                        && !"".equals(capreq.getUpdateSequence().trim())) {
088:                    try {
089:                        reqUS = Integer.parseInt(capreq.getUpdateSequence());
090:                    } catch (NumberFormatException nfe) {
091:                        throw new ServiceException(
092:                                "GeoServer only accepts numbers in the updateSequence parameter");
093:                    }
094:                }
095:                int geoUS = request.getServiceRef().getServiceRef()
096:                        .getGeoServer().getUpdateSequence();
097:                if (reqUS > geoUS) {
098:                    throw new org.geoserver.platform.ServiceException(
099:                            "Client supplied an updateSequence that is greater than the current sever updateSequence",
100:                            "InvalidUpdateSequence");
101:                }
102:                if (reqUS == geoUS) {
103:                    throw new org.geoserver.platform.ServiceException(
104:                            "WMS capabilities document is current (updateSequence = "
105:                                    + geoUS + ")", "CurrentUpdateSequence");
106:                }
107:                //otherwise it's a normal response...
108:
109:                WMSCapsTransformer transformer = new WMSCapsTransformer(request
110:                        .getBaseUrl(), formats, applicationContext);
111:
112:                // if (request.getWFS().getGeoServer().isVerbose()) {
113:                transformer.setIndentation(2);
114:
115:                // }
116:                ByteArrayOutputStream out = new ByteArrayOutputStream();
117:
118:                try {
119:                    transformer.transform(request, out);
120:                } catch (TransformerException e) {
121:                    throw new WmsException(e);
122:                }
123:
124:                this .rawResponse = out.toByteArray();
125:            }
126:
127:            /**
128:             * Returns the fixed capabilities MIME type  (application/vnd.ogc.wms_xml)
129:             * as specified in whe WMS spec, version 1.1.1, section 6.5.3, table 3.
130:             *
131:             * @param gs DOCUMENT ME!
132:             *
133:             * @return the capabilities document MIME type.
134:             *
135:             * @throws IllegalStateException if the response was not yet produced.
136:             */
137:            public String getContentType(GeoServer gs)
138:                    throws IllegalStateException {
139:                if (rawResponse == null) {
140:                    throw new IllegalStateException(
141:                            "execute() not called or not succeed.");
142:                }
143:
144:                return WMSCapsTransformer.WMS_CAPS_MIME;
145:            }
146:
147:            /**
148:             * Just returns <code>null</code>, since no special encoding is applyed to
149:             * the output data.
150:             *
151:             * @return <code>null</code>
152:             */
153:            public String getContentEncoding() {
154:                return null;
155:            }
156:
157:            /**
158:             * Writes the capabilities document generated in <code>execute()</code> to
159:             * the given output stream.
160:             *
161:             * @param out the capabilities document destination
162:             *
163:             * @throws ServiceException never, since the whole content was aquired in
164:             *         <code>execute()</code>
165:             * @throws IOException if it is thrown while writing to <code>out</code>
166:             * @throws IllegalStateException if <code>execute()</code> was not
167:             *         called/succeed before this method is called.
168:             */
169:            public void writeTo(OutputStream out) throws ServiceException,
170:                    IOException {
171:                if (rawResponse == null) {
172:                    throw new IllegalStateException("No raw response presents!");
173:                }
174:
175:                out.write(rawResponse);
176:            }
177:
178:            /**
179:             * Does nothing, since no processing is done after <code>execute()</code>
180:             * has returned.
181:             *
182:             * @param gs the service instance
183:             */
184:            public void abort(Service gs) {
185:            }
186:
187:            /*
188:             * (non-Javadoc)
189:             *
190:             * @see org.vfny.geoserver.Response#getContentDisposition()
191:             */
192:            public String getContentDisposition() {
193:                return null;
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.