Source Code Cross Referenced for UnsuccessfulXINSCallException.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: UnsuccessfulXINSCallException.java,v 1.33 2007/05/15 11:33:19 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 org.xins.common.MandatoryArgumentChecker;
010:        import org.xins.common.collections.PropertyReader;
011:        import org.xins.common.service.TargetDescriptor;
012:        import org.xins.common.spec.ErrorCodeSpec;
013:        import org.xins.common.xml.Element;
014:
015:        /**
016:         * Exception that indicates that a result code was returned by the API call.
017:         *
018:         * @version $Revision: 1.33 $ $Date: 2007/05/15 11:33:19 $
019:         * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
020:         *
021:         * @since XINS 1.0.0
022:         */
023:        public class UnsuccessfulXINSCallException extends XINSCallException
024:                implements  XINSCallResultData {
025:
026:            /**
027:             * The result data. The value of this field cannot be <code>null</code>.
028:             */
029:            private final XINSCallResultData _result;
030:
031:            /**
032:             * The type of the error.
033:             */
034:            private ErrorCodeSpec.Type _type;
035:
036:            /**
037:             * Constructs a new <code>UnsuccessfulXINSCallException</code> based on a
038:             * <code>XINSCallResultData</code> instance.
039:             *
040:             * @param request
041:             *    the original request, cannot be <code>null</code>.
042:             *
043:             * @param target
044:             *    descriptor for the target that was attempted to be called, cannot be
045:             *    <code>null</code>.
046:             *
047:             * @param duration
048:             *    the call duration in milliseconds, must be &gt;= 0.
049:             *
050:             * @param resultData
051:             *    the result data, cannot be <code>null</code>.
052:             *
053:             * @param detail
054:             *    detail message, or <code>null</code>.
055:             *
056:             * @throws IllegalArgumentException
057:             *    if <code>request     == null
058:             *          || target      == null
059:             *          || duration  &lt; 0
060:             *          || resultData  == null
061:             *          || resultData.{@link XINSCallResult#getErrorCode() getErrorCode()} == null</code>.
062:             */
063:            UnsuccessfulXINSCallException(XINSCallRequest request,
064:                    TargetDescriptor target, long duration,
065:                    XINSCallResultData resultData, String detail)
066:                    throws IllegalArgumentException {
067:
068:                super ("Unsuccessful XINS call result", request, target,
069:                        duration, determineDetail(resultData, detail), null);
070:
071:                // Check additional precondition
072:                MandatoryArgumentChecker.check("resultData", resultData);
073:
074:                // Result object must be unsuccessful
075:                String errorCode = resultData.getErrorCode();
076:                if (errorCode == null) {
077:                    throw new IllegalArgumentException(
078:                            "resultData.getErrorCode() == null");
079:                }
080:
081:                // Store details
082:                _result = resultData;
083:            }
084:
085:            /**
086:             * Delegate for the constructor that determines the detail message based on
087:             * a <code>XINSCallResultData</code> object and an optional detailed
088:             * description.
089:             *
090:             * @param result
091:             *    the {@link XINSCallResultData} instance, should not be
092:             *    <code>null</code>.
093:             *
094:             * @param detail
095:             *    detailed description to include, or <code>null</code> if unavailable.
096:             *
097:             * @return
098:             *    the detail message for the constructor to use, never
099:             *    <code>null</code>.
100:             *
101:             * @throws IllegalArgumentException
102:             *    if <code>result == null
103:             *          || result.{@link XINSCallResultData#getErrorCode() getErrorCode()} == null</code>.
104:             */
105:            private static final String determineDetail(
106:                    XINSCallResultData result, String detail)
107:                    throws IllegalArgumentException {
108:
109:                // Argument cannot be null
110:                MandatoryArgumentChecker.check("result", result);
111:
112:                // Result must be unsuccessful
113:                String errorCode = result.getErrorCode();
114:                if (errorCode == null) {
115:                    throw new IllegalArgumentException(
116:                            "result.getErrorCode() == null");
117:                }
118:
119:                if (detail == null || detail.length() < 1) {
120:                    return "Error code \"" + errorCode + "\".";
121:                } else {
122:                    return "Error code \"" + errorCode + "\": " + detail;
123:                }
124:            }
125:
126:            /**
127:             * Returns the error code.
128:             *
129:             * @return
130:             *    the error code, never <code>null</code>.
131:             */
132:            public final String getErrorCode() {
133:                return _result.getErrorCode();
134:            }
135:
136:            /**
137:             * Gets all returned parameters.
138:             *
139:             * @return
140:             *    a {@link PropertyReader} containing all parameters, or
141:             *    <code>null</code> if there are none.
142:             */
143:            public final PropertyReader getParameters() {
144:                return _result.getParameters();
145:            }
146:
147:            /**
148:             * Gets the value of the specified returned parameter.
149:             *
150:             * @param name
151:             *    the parameter name, not <code>null</code>.
152:             *
153:             * @return
154:             *    the value of the parameter, or <code>null</code> if there is no values.
155:             *
156:             * @throws IllegalArgumentException
157:             *    if <code>name == null</code>.
158:             */
159:            public final String getParameter(String name)
160:                    throws IllegalArgumentException {
161:                PropertyReader p = getParameters();
162:                if (p == null) {
163:                    return null;
164:                } else {
165:                    return p.get(name);
166:                }
167:            }
168:
169:            /**
170:             * Returns the optional extra data.
171:             *
172:             * @return
173:             *    the extra data as an {@link Element}, can be <code>null</code>;
174:             */
175:            public final Element getDataElement() {
176:                return _result.getDataElement();
177:            }
178:
179:            /**
180:             * Sets the type of the error code.
181:             *
182:             * @param type
183:             *    the type of the error (functionnal or technical).
184:             */
185:            void setType(ErrorCodeSpec.Type type) {
186:                _type = type;
187:            }
188:
189:            /**
190:             * Returns the type of the error code.
191:             *
192:             * @return
193:             *    the type as a {@link ErrorCodeSpec ErrorCodeSpec.Type}, can be <code>null</code> if it's unknown.
194:             *
195:             * @since XINS 1.4.0
196:             */
197:            public final ErrorCodeSpec.Type getType() {
198:                return _type;
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.