Source Code Cross Referenced for UnacceptableMessageException.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: UnacceptableMessageException.java,v 1.5 2007/09/18 08:45:07 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.util.Iterator;
010:        import java.util.List;
011:
012:        import org.xins.common.xml.Element;
013:        import org.xins.common.xml.ElementBuilder;
014:
015:        /**
016:         * Exception that indicates that a request for an API call is considered
017:         * unacceptable on the application-level. For example, a mandatory input
018:         * parameter may be missing.
019:         *
020:         * @version $Revision: 1.5 $ $Date: 2007/09/18 08:45:07 $
021:         * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
022:         * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
023:         *
024:         * @since XINS 2.0
025:         */
026:        public class UnacceptableMessageException extends XINSCallException {
027:
028:            // TODO: Support XINSCallRequest objects?
029:            // TODO: Is the name UnacceptableRequestException okay?
030:
031:            /**
032:             * The DataElement containing the errors.
033:             */
034:            private Element _errors = new Element("data");
035:
036:            /**
037:             * The error message.
038:             */
039:            private String _message;
040:
041:            /**
042:             * Constructs a new <code>UnacceptableMessageException</code> using the
043:             * specified <code>AbstractCAPICallRequest</code>.
044:             *
045:             * @param request
046:             *    the {@link AbstractCAPICallRequest} that is considered unacceptable,
047:             *    cannot be <code>null</code>.
048:             */
049:            UnacceptableMessageException(XINSCallRequest request) {
050:                super ("Invalid request", request, null, 0L, null, null);
051:            }
052:
053:            /**
054:             * Constructs a new <code>UnacceptableMessageException</code> using the
055:             * specified <code>XINSCallResult</code>.
056:             * This constructor is used by the generated CAPI.
057:             *
058:             * @param result
059:             *    the {@link XINSCallResult} that is considered unacceptable,
060:             *    cannot be <code>null</code>.
061:             */
062:            public UnacceptableMessageException(XINSCallResult result) {
063:                super ("Invalid result", result, null, null);
064:            }
065:
066:            /**
067:             * Returns the message for this exception.
068:             *
069:             * @return
070:             *    the exception message, can be <code>null</code>.
071:             */
072:            public String getMessage() {
073:                if (_message == null) {
074:                    _message = InvalidRequestException.createMessage(_errors);
075:                }
076:                return _message;
077:            }
078:
079:            /**
080:             * Adds to the response that a paramater that is missing.
081:             *
082:             * @param parameter
083:             *    the missing parameter.
084:             */
085:            public void addMissingParameter(String parameter) {
086:                ElementBuilder missingParam = new ElementBuilder(
087:                        "missing-param");
088:                missingParam.setAttribute("param", parameter);
089:                _errors.addChild(missingParam.createElement());
090:            }
091:
092:            /**
093:             * Adds to the response a parameter that is missing in an element.
094:             *
095:             * @param parameter
096:             *    the missing parameter.
097:             *
098:             * @param element
099:             *    the element in which the parameter is missing.
100:             */
101:            public void addMissingParameter(String parameter, String element) {
102:                ElementBuilder missingParam = new ElementBuilder(
103:                        "missing-param");
104:                missingParam.setAttribute("param", parameter);
105:                missingParam.setAttribute("element", element);
106:                _errors.addChild(missingParam.createElement());
107:            }
108:
109:            /**
110:             * Adds an invalid value for a specified type.
111:             *
112:             * @param parameter
113:             *    the name of the parameter passed by the user.
114:             *
115:             * @param type
116:             *    the type which this parameter should be compliant with.
117:             *
118:             * @deprecated since XINS 2.0, use {@link #addInvalidValueForType(String, String, String)}.
119:             */
120:            public void addInvalidValueForType(String parameter, String type) {
121:                ElementBuilder invalidValue = new ElementBuilder(
122:                        "invalid-value-for-type");
123:                invalidValue.setAttribute("param", parameter);
124:                invalidValue.setAttribute("type", type);
125:                _errors.addChild(invalidValue.createElement());
126:            }
127:
128:            /**
129:             * Adds an invalid value for a specified type.
130:             *
131:             * @param parameter
132:             *    the name of the parameter passed by the user.
133:             *
134:             * @param value
135:             *    the value of the parameter passed by the user.
136:             *
137:             * @param type
138:             *    the type which this parameter should be compliant with.
139:             *
140:             * @since XINS 2.0
141:             */
142:            public void addInvalidValueForType(String parameter, String value,
143:                    String type) {
144:                ElementBuilder invalidValue = new ElementBuilder(
145:                        "invalid-value-for-type");
146:                invalidValue.setAttribute("param", parameter);
147:                invalidValue.setAttribute("value", value);
148:                invalidValue.setAttribute("type", type);
149:                _errors.addChild(invalidValue.createElement());
150:            }
151:
152:            /**
153:             * Adds an invalid value for a specified type.
154:             *
155:             * @param parameter
156:             *    the parameter passed by the user.
157:             *
158:             * @param value
159:             *    the value of the parameter passed by the user.
160:             *
161:             * @param type
162:             *    the type which this parameter should be compliant with.
163:             *
164:             * @param element
165:             *    the element in which the parameter is missing.
166:             *
167:             * @since XINS 2.0
168:             */
169:            public void addInvalidValueForType(String parameter, String value,
170:                    String type, String element) {
171:                ElementBuilder invalidValue = new ElementBuilder(
172:                        "invalid-value-for-type");
173:                invalidValue.setAttribute("param", parameter);
174:                invalidValue.setAttribute("value", value);
175:                invalidValue.setAttribute("type", type);
176:                invalidValue.setAttribute("element", element);
177:                _errors.addChild(invalidValue.createElement());
178:            }
179:
180:            /**
181:             * Adds an invalid combination of parameters.
182:             *
183:             * @param type
184:             *    the type of the combination.
185:             *
186:             * @param parameters
187:             *    list of the parameters in the combination passed as a list of
188:             *    {@link String} objects.
189:             */
190:            public void addParamCombo(String type, List parameters) {
191:
192:                ElementBuilder paramCombo = new ElementBuilder("param-combo");
193:                paramCombo.setAttribute("type", type);
194:
195:                // Iterate over all parameters
196:                Iterator itParameters = parameters.iterator();
197:                while (itParameters.hasNext()) {
198:                    ElementBuilder param = new ElementBuilder("param");
199:                    param.setAttribute("name", (String) itParameters.next());
200:                    paramCombo.addChild(param.createElement());
201:                }
202:
203:                _errors.addChild(paramCombo.createElement());
204:            }
205:
206:            /**
207:             * Adds an invalid combination of attributes.
208:             *
209:             * @param type
210:             *    the type of the combination.
211:             *
212:             * @param attributes
213:             *    list of the attributes in the combination passed as a list of
214:             *    {@link String} objects.
215:             *
216:             * @param elementName
217:             *    the name of the element to which these attributes belong.
218:             *
219:             * @since XINS 1.4.0
220:             */
221:            public void addAttributeCombo(String type, List attributes,
222:                    String elementName) {
223:
224:                ElementBuilder attributeCombo = new ElementBuilder(
225:                        "attribute-combo");
226:                attributeCombo.setAttribute("type", type);
227:
228:                // Iterate over all attributes
229:                Iterator itAttributes = attributes.iterator();
230:                while (itAttributes.hasNext()) {
231:                    ElementBuilder attribute = new ElementBuilder("attribute");
232:                    attribute
233:                            .setAttribute("name", (String) itAttributes.next());
234:                    attributeCombo.addChild(attribute.createElement());
235:                }
236:
237:                _errors.addChild(attributeCombo.createElement());
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.