Source Code Cross Referenced for ErrorResult.java in  » Web-Services » xins » org » xins » server » frontend » 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 » Web Services » xins » org.xins.server.frontend 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ErrorResult.java,v 1.4 2007/09/18 08:45:08 agoubard Exp $
003:         *
004:         * Copyright 2003-2007 Orange Nederland Breedband B.V.
005:         * See the COPYRIGHT file for redistribution and use restrictions.
006:         */
007:        package org.xins.server.frontend;
008:
009:        import java.text.SimpleDateFormat;
010:        import java.util.Date;
011:        import java.io.PrintWriter;
012:        import java.io.StringWriter;
013:        import javax.servlet.http.HttpServletRequest;
014:        import javax.xml.transform.SourceLocator;
015:        import javax.xml.transform.TransformerException;
016:        import org.xins.common.text.TextUtils;
017:        import org.xins.server.FunctionResult;
018:
019:        /**
020:         * Result for an error.
021:         *
022:         * @version $Revision: 1.4 $ $Date: 2007/09/18 08:45:08 $
023:         * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
024:         */
025:        class ErrorResult extends FunctionResult {
026:
027:            private static SimpleDateFormat ERROR_DATE_FORMATTER = new SimpleDateFormat(
028:                    "yyyy.MM.dd',' HH:mm:ss ");
029:
030:            /**
031:             * Creates the result for a transformation error.
032:             *
033:             * @param exception
034:             *    the exception during the transformation, cannot be <code>null</code>.
035:             *
036:             * @param httpRequest
037:             *    the HTTP request, cannot be <code>null</code>.
038:             */
039:            ErrorResult(Exception exception, HttpServletRequest httpRequest) {
040:
041:                param("error.type", "TechnicalError");
042:                param("error.message", exception.getMessage());
043:                StringWriter stWriter = new StringWriter(360);
044:                PrintWriter printWriter = new PrintWriter(stWriter);
045:                exception.printStackTrace(printWriter);
046:                String stackTrace = stWriter.toString();
047:                param("error.stacktrace", stackTrace);
048:                String timeOfFailure = ERROR_DATE_FORMATTER.format(new Date());
049:                param("error.time", timeOfFailure);
050:                if (exception instanceof  TransformerException) {
051:                    TransformerException tex = (TransformerException) exception;
052:                    SourceLocator locator = tex.getLocator();
053:                    if (locator != null) {
054:                        int line = locator.getLineNumber();
055:                        int col = locator.getColumnNumber();
056:                        String publicId = locator.getPublicId();
057:                        String systemId = locator.getSystemId();
058:                        String detail = "line: " + line + "; col: " + col
059:                                + "; public ID: " + publicId + "; system ID: "
060:                                + systemId;
061:                        param("error.location", detail);
062:                    }
063:                }
064:
065:                String command = httpRequest.getParameter("command");
066:                if (!TextUtils.isEmpty(command)) {
067:                    param("error.command", command);
068:                }
069:                String action = httpRequest.getParameter("action");
070:                if (!TextUtils.isEmpty(action)) {
071:                    param("error.action", action);
072:                }
073:                String query = httpRequest.getQueryString();
074:                if (!TextUtils.isEmpty(query)) {
075:                    param("error.query", query);
076:                }
077:            }
078:
079:            /**
080:             * Return the XSLT to use to display the data of the Control command.
081:             *
082:             * @return
083:             *    the XSLT to display the Control result, never <code>null</code>.
084:             */
085:            static String getDefaultErrorTemplate() {
086:                String result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
087:                        + "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
088:                        + "<xsl:output method=\"html\" indent=\"yes\" encoding=\"US-ASCII\"\n"
089:                        + "doctype-public=\"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
090:                        + "doctype-system=\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\n"
091:                        + "omit-xml-declaration=\"yes\" />\n"
092:                        + "<xsl:template match=\"commandresult\">\n"
093:                        + "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"
094:                        + "<body>\n"
095:                        + "<h2>\n"
096:                        + "A technical error occured\n"
097:                        + "</h2>\n"
098:                        + "<h3>Command</h3>\n"
099:                        + "<xsl:value-of select=\"parameter[@name='error.command']/text()\" />\n"
100:                        + "<xsl:if test=\"parameter[@name='error.action']\">\n"
101:                        + "<xsl:text> with the </xsl:text>\n"
102:                        + "<xsl:value-of select=\"parameter[@name='error.action']/text()\" />\n"
103:                        + "<xsl:text> action.</xsl:text>\n"
104:                        + "</xsl:if>\n"
105:                        + "<h3>Request</h3>\n"
106:                        + "<xsl:value-of select=\"parameter[@name='error.query']/text()\" />\n"
107:                        + "<h3>Error message</h3>\n"
108:                        + "<xsl:value-of select=\"parameter[@name='error.message']/text()\" />\n"
109:                        + "<xsl:if test=\"parameter[@name='error.location']\">\n"
110:                        + "<h3>Error location</h3>\n"
111:                        + "<xsl:value-of select=\"parameter[@name='error.location']/text()\" />\n"
112:                        + "</xsl:if>\n"
113:                        + "<h3>Error details</h3>\n"
114:                        + "<pre>\n"
115:                        + "<xsl:value-of select=\"parameter[@name='error.stacktrace']/text()\" />\n"
116:                        + "</pre>\n" + "</body>\n" + "</html>\n"
117:                        + "</xsl:template>\n" + "</xsl:stylesheet>";
118:                return result;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.