Source Code Cross Referenced for WcsException.java in  » GIS » GeoServer » org » vfny » geoserver » wcs » 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 
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;
006:
007:        import org.vfny.geoserver.ServiceException;
008:        import org.vfny.geoserver.global.GeoServer;
009:        import org.vfny.geoserver.util.Requests;
010:        import java.util.logging.Logger;
011:        import javax.servlet.http.HttpServletRequest;
012:
013:        /**
014:         * This defines an exception that can be turned into a valid xml service
015:         * exception that wcs clients will expect. All errors should be wrapped in this
016:         * before returning to clients.
017:         *
018:         * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last
019:         *         modification)
020:         * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last
021:         *         modification)
022:         * @version $Id: WcsException.java 8479 2008-02-28 19:11:04Z aaime $
023:         */
024:        public class WcsException extends ServiceException {
025:            /** Class logger */
026:            private static Logger LOGGER = org.geotools.util.logging.Logging
027:                    .getLogger("org.vfny.geoserver.wcs");
028:
029:            /**
030:             * The fixed MIME type of a WCS exception.
031:             */
032:            private static final String SE_XML = "application/vnd.ogc.se_xml";
033:
034:            /**
035:             * Empty constructor.
036:             */
037:            public WcsException() {
038:                super ();
039:            }
040:
041:            /**
042:             * Message constructor.
043:             *
044:             * @param message The message for the .
045:             */
046:            public WcsException(String message) {
047:                super (message);
048:            }
049:
050:            /**
051:             * Throwable constructor.
052:             *
053:             * @param e The message for the .
054:             */
055:            public WcsException(Throwable e) {
056:                super (e);
057:            }
058:
059:            /**
060:             * Message Locator constructor.
061:             *
062:             * @param message The message for the .
063:             * @param locator The java class that caused the problem
064:             */
065:            public WcsException(String message, String locator) {
066:                super (message, locator);
067:            }
068:
069:            /**
070:             * Message code and locator constructor.
071:             *
072:             * @param message The message for the .
073:             * @param locator The java class that caused the problem
074:             */
075:            public WcsException(String message, String locator, String code) {
076:                super (message, locator);
077:                setCode(code);
078:            }
079:
080:            public WcsException(String message, Throwable cause) {
081:                super (message, cause);
082:            }
083:
084:            /**
085:             * DOCUMENT ME!
086:             *
087:             * @param e The cause of failure
088:             * @param preMessage The message to tack on the front.
089:             * @param locator The java class that caused the problem
090:             */
091:            public WcsException(Throwable e, String preMessage, String locator) {
092:                super (e, preMessage, locator);
093:            }
094:
095:            /**
096:             * Return request type.
097:             *
098:             * @param printStackTrace whether the stack trace should be included.
099:             * @param request DOCUMENT ME!
100:             *
101:             * @return The ServiceExceptionReport of this error.
102:             *
103:             * @task REVISIT: Our error handling should actually have knowledge of the
104:             *       app configuration, so that we can set the ogc error report to
105:             *       validate right (reference our own schema), and to put the correct
106:             *       mime type here.
107:             */
108:            public String getXmlResponse(boolean printStackTrace,
109:                    HttpServletRequest request, GeoServer geoserver) {
110:                //Perhaps not the best place to do this, but it's by far the best place to ensure
111:                //that all logged errors get recorded in the same way, as there all must return
112:                //xml responses.
113:                LOGGER.warning("encountered error: " + getMessage());
114:
115:                String indent = "   ";
116:
117:                StringBuffer returnXml = new StringBuffer(
118:                        "<?xml version=\"1.0\" ?>\n");
119:
120:                returnXml.append("<ServiceExceptionReport\n");
121:
122:                returnXml.append(indent + "version=\"1.2.0\"\n");
123:
124:                returnXml.append(indent
125:                        + "xmlns=\"http://www.opengis.net/ogc\"\n");
126:
127:                returnXml.append(indent + "xmlns:xsi=\"http://www.w3.org/2001/"
128:                        + "XMLSchema-instance\"\n");
129:
130:                returnXml.append(indent);
131:
132:                returnXml
133:                        .append("xsi:schemaLocation=\"http://www.opengis.net/ogc ");
134:
135:                returnXml.append(Requests.getSchemaBaseUrl(request, geoserver)
136:                        + "wcs/1.0.0/OGC-exception.xsd\">\n");
137:
138:                //REVISIT: handle multiple service exceptions?  must refactor class.
139:                returnXml.append(indent + "<ServiceException");
140:
141:                if (!isEmpty(getCode())) {
142:                    returnXml.append(" code=\"" + getCode() + "\"");
143:                }
144:
145:                if (!isEmpty(this .locator)) {
146:                    returnXml.append(" locator=\"" + this .locator + "\"");
147:                }
148:
149:                returnXml.append(">\n" + indent + indent);
150:                returnXml.append(getXmlMessage(printStackTrace));
151:
152:                returnXml.append(indent + "</ServiceException>\n");
153:
154:                returnXml.append("</ServiceExceptionReport>");
155:
156:                LOGGER.fine("return wfs exception is " + returnXml);
157:
158:                return returnXml.toString();
159:            }
160:
161:            /**
162:             * Returns the mime type that should be exposed to the client
163:             * when sending the exception message.
164:             *
165:             * <p>
166:             * Defaults to <code>geoserver.getMimeType()</code>
167:             * </p>
168:             *
169:             * @return
170:             */
171:            public String getMimeType(GeoServer geoserver) {
172:                return SE_XML + "; charset=" + geoserver.getCharSet().name();
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.