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


001:        /*
002:         * $Id: InvalidResultXINSCallException.java,v 1.18 2007/03/16 09:54:58 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.client;
008:
009:        import java.io.UnsupportedEncodingException;
010:
011:        import org.xins.common.MandatoryArgumentChecker;
012:        import org.xins.common.Utils;
013:        import org.xins.common.service.TargetDescriptor;
014:
015:        /**
016:         * Exception thrown to indicate that the result from a XINS API call was
017:         * invalid according to the XINS rules for a XINS call result.
018:         *
019:         * <p>Note that this exception is <em>only</em> thrown if the result is
020:         * invalid according to the XINS rules for a result XML document. If the
021:         * result is only invalid in relation to the applicable API specification,
022:         * then an {@link UnacceptableResultXINSCallException} is thrown instead.
023:         *
024:         * @version $Revision: 1.18 $ $Date: 2007/03/16 09:54:58 $
025:         * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
026:         *
027:         * @since XINS 1.0.0
028:         */
029:        public final class InvalidResultXINSCallException extends
030:                XINSCallException {
031:
032:            /**
033:             * Constructs a new <code>InvalidResultXINSCallException</code>.
034:             *
035:             * @param request
036:             *    the original request, cannot be <code>null</code>.
037:             *
038:             * @param target
039:             *    descriptor for the target that was attempted to be called, cannot be
040:             *    <code>null</code>.
041:             *
042:             * @param duration
043:             *    the call duration in milliseconds, must be &gt;= 0.
044:             *
045:             * @param detail
046:             *    a more detailed description of the problem, or <code>null</code> if
047:             *    none is available.
048:             *
049:             * @param cause
050:             *    the cause exception, or <code>null</code> if there is none.
051:             *
052:             * @throws IllegalArgumentException
053:             *    if <code>request     == null
054:             *          || target      == null
055:             *          || duration  &lt; 0</code>.
056:             */
057:            private InvalidResultXINSCallException(XINSCallRequest request,
058:                    TargetDescriptor target, long duration, String detail,
059:                    Throwable cause) throws IllegalArgumentException {
060:                super ("Invalid XINS call result", request, target, duration,
061:                        detail, cause);
062:            }
063:
064:            /**
065:             * Creates a <code>InvalidResultXINSCallException</code> for the situation
066:             * where no HTTP data is received.
067:             *
068:             * @param request
069:             *    the original request, cannot be <code>null</code>.
070:             *
071:             * @param target
072:             *    descriptor for the target that was attempted to be called, cannot be
073:             *    <code>null</code>.
074:             *
075:             * @param duration
076:             *    the call duration in milliseconds, must be &gt;= 0.
077:             *
078:             * @return
079:             *    the exception indicating that no HTTP data was received.
080:             *
081:             * @throws IllegalArgumentException
082:             *    if <code>request     == null
083:             *          || target      == null
084:             *          || duration  &lt; 0</code>.
085:             */
086:            static InvalidResultXINSCallException noDataReceived(
087:                    XINSCallRequest request, TargetDescriptor target,
088:                    long duration) throws IllegalArgumentException {
089:
090:                // Check preconditions
091:                MandatoryArgumentChecker.check("request", request, "target",
092:                        target);
093:                if (duration < 0) {
094:                    throw new IllegalArgumentException("duration (" + duration
095:                            + ") < 0");
096:                }
097:
098:                String detail = "No HTTP response received.";
099:                Throwable cause = null;
100:
101:                return new InvalidResultXINSCallException(request, target,
102:                        duration, detail, cause);
103:            }
104:
105:            /**
106:             * Creates a <code>InvalidResultXINSCallException</code> for the situation
107:             * where the received HTTP data cannot be parsed.
108:             *
109:             * @param httpData
110:             *    the HTTP data, cannot be <code>null</code> and the length must be
111:             *    positive.
112:             *
113:             * @param request
114:             *    the original request, cannot be <code>null</code>.
115:             *
116:             * @param target
117:             *    descriptor for the target that was attempted to be called, cannot be
118:             *    <code>null</code>.
119:             *
120:             * @param duration
121:             *    the call duration in milliseconds, must be &gt;= 0.
122:             *
123:             * @param cause
124:             *    the cause exception, or <code>null</code> if there is none.
125:             *
126:             * @return
127:             *    the exception indicating that the HTTP data could not be parsed.
128:             *
129:             * @throws IllegalArgumentException
130:             *    if <code>httpData        ==   null
131:             *          || request         ==   null
132:             *          || target          ==   null
133:             *          || httpData.length &lt; 1
134:             *          || duration        &lt; 0</code>.
135:             */
136:            static InvalidResultXINSCallException parseError(byte[] httpData,
137:                    XINSCallRequest request, TargetDescriptor target,
138:                    long duration, Throwable cause)
139:                    throws IllegalArgumentException {
140:
141:                // Check preconditions
142:                MandatoryArgumentChecker.check("httpData", httpData, "request",
143:                        request, "target", target);
144:                if (httpData.length < 1) {
145:                    throw new IllegalArgumentException("httpData.length == 0");
146:                } else if (duration < 0) {
147:                    throw new IllegalArgumentException("duration (" + duration
148:                            + ") < 0");
149:                }
150:
151:                // Determine how much to quote; max is 512 bytes
152:                int quoteLength = Math.min(httpData.length, 512);
153:                String quote;
154:                try {
155:                    quote = new String(httpData, 0, quoteLength, "US-ASCII");
156:                } catch (UnsupportedEncodingException exception) {
157:                    throw Utils.logProgrammingError(cause);
158:                }
159:
160:                // Construct the detail message
161:                String detail = "Failed to parse the HTTP response. The first "
162:                        + quoteLength + " bytes are (in ASCII): \"" + quote
163:                        + "\".";
164:
165:                return new InvalidResultXINSCallException(request, target,
166:                        duration, detail, cause);
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.