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