1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.apache.ws.scout.registry; |
17 | |
|
18 | |
import org.uddi.api_v3.*; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class RegistryV3Exception extends Exception |
28 | |
{ |
29 | |
private static final long serialVersionUID = -733955749275810694L; |
30 | |
public static final int E_ASSERTION_NOT_FOUND = 30000; |
31 | |
public static final int E_AUTH_TOKEN_EXPIRED = 10110; |
32 | |
public static final int E_AUTH_TOKEN_REQUIRED = 10120; |
33 | |
public static final int E_ACCOUNT_LIMIT_EXCEEDED = 10160; |
34 | |
public static final int E_BUSY = 10400; |
35 | |
public static final int E_CATEGORIZATION_NOT_ALLOWED = 20100; |
36 | |
public static final int E_FATAL_ERROR = 10500; |
37 | |
public static final int E_INVALID_KEY_PASSED = 10210; |
38 | |
public static final int E_INVALID_PROJECTION = 20230; |
39 | |
public static final int E_INVALID_CATEGORY = 20000; |
40 | |
public static final int E_INVALID_COMPLETION_STATUS = 30100; |
41 | |
public static final int E_INVALID_URL_PASSED = 10220; |
42 | |
public static final int E_INVALID_VALUE = 20200; |
43 | |
public static final int E_KEY_RETIRED = 10310; |
44 | |
public static final int E_LANGUAGE_ERROR = 10060; |
45 | |
public static final int E_MESSAGE_TOO_LARGE = 30110; |
46 | |
public static final int E_NAME_TOO_LONG = 10020; |
47 | |
public static final int E_OPERATOR_MISMATCH = 10130; |
48 | |
public static final int E_PUBLISHER_CANCELLED = 30220; |
49 | |
public static final int E_REQUEST_DENIED = 30210; |
50 | |
public static final int E_SECRET_UNKNOWN = 30230; |
51 | |
public static final int E_SUCCESS = 0; |
52 | |
public static final int E_TOO_MANY_OPTIONS = 10030; |
53 | |
public static final int E_TRANSFER_ABORTED = 30200; |
54 | |
public static final int E_UNRECOGNIZED_VERSION = 10040; |
55 | |
public static final int E_UNKNOWN_USER = 10150; |
56 | |
public static final int E_UNSUPPORTED = 10050; |
57 | |
public static final int E_USER_MISMATCH = 10140; |
58 | |
public static final int E_VALUE_NOT_ALLOWED = 20210; |
59 | |
public static final int E_UNVALIDATABLE = 20220; |
60 | |
public static final int E_REQUEST_TIMEOUT = 20240; |
61 | |
public static final int E_INVALID_TIME = 40030; |
62 | |
public static final int E_RESULT_SET_TOO_LARGE = 40300; |
63 | |
|
64 | |
|
65 | |
private String faultActor; |
66 | |
|
67 | |
|
68 | |
private String faultCode; |
69 | |
|
70 | |
|
71 | |
private String faultString; |
72 | |
|
73 | |
|
74 | |
private DispositionReport dispReport; |
75 | |
|
76 | 0 | private ObjectFactory objectFactory = new ObjectFactory(); |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public RegistryV3Exception(String msg) |
83 | |
{ |
84 | 0 | super(msg); |
85 | |
|
86 | 0 | setFaultCode(null); |
87 | 0 | setFaultString(msg); |
88 | 0 | setFaultActor(null); |
89 | 0 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public RegistryV3Exception(Exception ex) |
96 | |
{ |
97 | 0 | super(ex); |
98 | |
|
99 | 0 | if (ex != null) |
100 | |
{ |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | 0 | if (ex instanceof RegistryV3Exception) |
107 | |
{ |
108 | 0 | RegistryV3Exception regex = (RegistryV3Exception)ex; |
109 | 0 | setFaultCode(regex.getFaultCode()); |
110 | 0 | setFaultString(regex.getFaultString()); |
111 | 0 | setFaultActor(regex.getFaultActor()); |
112 | 0 | setDispositionReport(regex.getDispositionReport()); |
113 | 0 | } |
114 | |
else |
115 | |
{ |
116 | 0 | setFaultString(ex.getMessage()); |
117 | |
} |
118 | |
} |
119 | 0 | } |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public RegistryV3Exception(String fCode,String fString,String fActor,DispositionReport dispRpt) |
130 | |
{ |
131 | 0 | super(fString); |
132 | |
|
133 | 0 | setFaultCode(fCode); |
134 | 0 | setFaultString(fString); |
135 | 0 | setFaultActor(fActor); |
136 | 0 | setDispositionReport(dispRpt); |
137 | 0 | } |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
RegistryV3Exception(String fCode,int errno,String msg) |
144 | |
{ |
145 | 0 | super(buildMessage(errno,msg)); |
146 | |
|
147 | 0 | String errCode = lookupErrCode(errno); |
148 | |
|
149 | 0 | if (fCode != null) { |
150 | 0 | setFaultCode(fCode); |
151 | |
} |
152 | |
|
153 | 0 | setFaultString(getMessage()); |
154 | |
|
155 | 0 | Result r = this.objectFactory.createResult(); |
156 | 0 | ErrInfo ei = this.objectFactory.createErrInfo(); |
157 | |
|
158 | 0 | if (errCode != null) { |
159 | 0 | ei.setErrCode(errCode); |
160 | |
} |
161 | |
|
162 | 0 | ei.setValue(getMessage()); |
163 | |
|
164 | 0 | r.setErrno(errno); |
165 | |
|
166 | 0 | if (ei != null) { |
167 | 0 | r.setErrInfo(ei); |
168 | |
} |
169 | |
|
170 | 0 | addResult(r); |
171 | 0 | } |
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
public void setFaultActor(String actor) |
178 | |
{ |
179 | 0 | this.faultActor = actor; |
180 | 0 | } |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
public String getFaultActor() |
187 | |
{ |
188 | 0 | return this.faultActor; |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public void setFaultCode(String code) |
196 | |
{ |
197 | 0 | this.faultCode = code; |
198 | 0 | } |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
public String getFaultCode() |
205 | |
{ |
206 | 0 | return this.faultCode; |
207 | |
} |
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
public void setFaultString(String value) |
214 | |
{ |
215 | 0 | this.faultString = value; |
216 | 0 | } |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
public String getFaultString() |
223 | |
{ |
224 | 0 | return this.faultString; |
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
public void setDispositionReport(DispositionReport dispRpt) |
234 | |
{ |
235 | 0 | this.dispReport = dispRpt; |
236 | 0 | } |
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
public DispositionReport getDispositionReport() |
245 | |
{ |
246 | 0 | return this.dispReport; |
247 | |
} |
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
public void addResult(Result result) |
254 | |
{ |
255 | 0 | if (this.dispReport==null) { |
256 | 0 | this.dispReport = this.objectFactory.createDispositionReport(); |
257 | |
} |
258 | |
|
259 | 0 | Result jaxbResult = this.objectFactory.createResult(); |
260 | 0 | this.dispReport.getResult().add(jaxbResult); |
261 | |
|
262 | 0 | if (result.getErrInfo() != null) jaxbResult.setErrInfo(result.getErrInfo()); |
263 | 0 | if (result.getKeyType() != null) jaxbResult.setKeyType(result.getKeyType()); |
264 | 0 | jaxbResult.setErrno(result.getErrno()); |
265 | 0 | } |
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
public String toString() |
271 | |
{ |
272 | 0 | String msg = getMessage(); |
273 | 0 | if (msg == null) |
274 | 0 | return ""; |
275 | |
else |
276 | 0 | return getMessage(); |
277 | |
} |
278 | |
|
279 | |
private static final String buildMessage(int errno,String msg) |
280 | |
{ |
281 | 0 | StringBuffer buffer = new StringBuffer(); |
282 | |
|
283 | 0 | String errCode = lookupErrCode(errno); |
284 | 0 | if (errCode != null) |
285 | |
{ |
286 | 0 | buffer.append(errCode); |
287 | 0 | buffer.append(" "); |
288 | |
} |
289 | |
|
290 | 0 | buffer.append("("); |
291 | 0 | buffer.append(errno); |
292 | 0 | buffer.append(") "); |
293 | |
|
294 | |
|
295 | |
|
296 | 0 | String errText = ""; |
297 | 0 | if (errText != null) |
298 | |
{ |
299 | 0 | buffer.append(errText); |
300 | 0 | buffer.append(" "); |
301 | |
} |
302 | |
|
303 | 0 | if ((msg != null) && (msg.trim().length() > 0)) |
304 | |
{ |
305 | 0 | buffer.append(msg); |
306 | |
} |
307 | |
|
308 | 0 | return buffer.toString(); |
309 | |
} |
310 | |
|
311 | |
public static final String lookupErrCode(int errno) |
312 | |
{ |
313 | 0 | switch (errno) |
314 | |
{ |
315 | 0 | case E_ACCOUNT_LIMIT_EXCEEDED : return "E_accountLimitExceeded"; |
316 | 0 | case E_ASSERTION_NOT_FOUND : return "E_assertionNotFound"; |
317 | 0 | case E_AUTH_TOKEN_EXPIRED : return "E_authTokenExpired"; |
318 | 0 | case E_AUTH_TOKEN_REQUIRED : return "E_authTokenRequired"; |
319 | 0 | case E_BUSY : return "E_busy"; |
320 | 0 | case E_CATEGORIZATION_NOT_ALLOWED : return "E_categorizationNotAllowed"; |
321 | 0 | case E_FATAL_ERROR : return "E_fatalError"; |
322 | 0 | case E_INVALID_CATEGORY : return "E_invalidCategory"; |
323 | 0 | case E_INVALID_COMPLETION_STATUS : return "E_invalidCompletionStatus"; |
324 | 0 | case E_INVALID_KEY_PASSED : return "E_invalidKeyPassed"; |
325 | 0 | case E_INVALID_PROJECTION : return "E_invalidProjection"; |
326 | 0 | case E_INVALID_TIME : return "E_invalidTime"; |
327 | 0 | case E_INVALID_URL_PASSED : return "E_invalidURLPassed"; |
328 | 0 | case E_INVALID_VALUE : return "E_invalidValue"; |
329 | 0 | case E_KEY_RETIRED : return "E_keyRetired"; |
330 | 0 | case E_LANGUAGE_ERROR : return "E_languageError"; |
331 | 0 | case E_MESSAGE_TOO_LARGE : return "E_messageTooLarge"; |
332 | 0 | case E_NAME_TOO_LONG : return "E_nameTooLong"; |
333 | 0 | case E_OPERATOR_MISMATCH : return "E_operatorMismatch"; |
334 | 0 | case E_PUBLISHER_CANCELLED : return "E_publisherCancelled"; |
335 | 0 | case E_REQUEST_DENIED : return "E_requestDenied"; |
336 | 0 | case E_REQUEST_TIMEOUT : return "E_requestTimeout"; |
337 | 0 | case E_RESULT_SET_TOO_LARGE : return "E_resultSetTooLarge"; |
338 | 0 | case E_SECRET_UNKNOWN : return "E_secretUnknown"; |
339 | 0 | case E_SUCCESS : return "E_success"; |
340 | 0 | case E_TOO_MANY_OPTIONS : return "E_tooManyOptions"; |
341 | 0 | case E_TRANSFER_ABORTED : return "E_transferAborted"; |
342 | 0 | case E_UNKNOWN_USER : return "E_unknownUser"; |
343 | 0 | case E_UNRECOGNIZED_VERSION : return "E_unrecognizedVersion"; |
344 | 0 | case E_UNSUPPORTED : return "E_unsupported"; |
345 | 0 | case E_UNVALIDATABLE : return "E_unvalidatable"; |
346 | 0 | case E_USER_MISMATCH : return "E_userMismatch"; |
347 | 0 | case E_VALUE_NOT_ALLOWED : return "E_valueNotAllowed"; |
348 | 0 | default : return null; |
349 | |
} |
350 | |
} |
351 | |
} |