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 private ObjectFactory objectFactory = new ObjectFactory();
77
78
79
80
81
82 public RegistryV3Exception(String msg)
83 {
84 super(msg);
85
86 setFaultCode(null);
87 setFaultString(msg);
88 setFaultActor(null);
89 }
90
91
92
93
94
95 public RegistryV3Exception(Exception ex)
96 {
97 super(ex);
98
99 if (ex != null)
100 {
101
102
103
104
105
106 if (ex instanceof RegistryV3Exception)
107 {
108 RegistryV3Exception regex = (RegistryV3Exception)ex;
109 setFaultCode(regex.getFaultCode());
110 setFaultString(regex.getFaultString());
111 setFaultActor(regex.getFaultActor());
112 setDispositionReport(regex.getDispositionReport());
113 }
114 else
115 {
116 setFaultString(ex.getMessage());
117 }
118 }
119 }
120
121
122
123
124
125
126
127
128
129 public RegistryV3Exception(String fCode,String fString,String fActor,DispositionReport dispRpt)
130 {
131 super(fString);
132
133 setFaultCode(fCode);
134 setFaultString(fString);
135 setFaultActor(fActor);
136 setDispositionReport(dispRpt);
137 }
138
139
140
141
142
143 RegistryV3Exception(String fCode,int errno,String msg)
144 {
145 super(buildMessage(errno,msg));
146
147 String errCode = lookupErrCode(errno);
148
149 if (fCode != null) {
150 setFaultCode(fCode);
151 }
152
153 setFaultString(getMessage());
154
155 Result r = this.objectFactory.createResult();
156 ErrInfo ei = this.objectFactory.createErrInfo();
157
158 if (errCode != null) {
159 ei.setErrCode(errCode);
160 }
161
162 ei.setValue(getMessage());
163
164 r.setErrno(errno);
165
166 if (ei != null) {
167 r.setErrInfo(ei);
168 }
169
170 addResult(r);
171 }
172
173
174
175
176
177 public void setFaultActor(String actor)
178 {
179 this.faultActor = actor;
180 }
181
182
183
184
185
186 public String getFaultActor()
187 {
188 return this.faultActor;
189 }
190
191
192
193
194
195 public void setFaultCode(String code)
196 {
197 this.faultCode = code;
198 }
199
200
201
202
203
204 public String getFaultCode()
205 {
206 return this.faultCode;
207 }
208
209
210
211
212
213 public void setFaultString(String value)
214 {
215 this.faultString = value;
216 }
217
218
219
220
221
222 public String getFaultString()
223 {
224 return this.faultString;
225 }
226
227
228
229
230
231
232
233 public void setDispositionReport(DispositionReport dispRpt)
234 {
235 this.dispReport = dispRpt;
236 }
237
238
239
240
241
242
243
244 public DispositionReport getDispositionReport()
245 {
246 return this.dispReport;
247 }
248
249
250
251
252
253 public void addResult(Result result)
254 {
255 if (this.dispReport==null) {
256 this.dispReport = this.objectFactory.createDispositionReport();
257 }
258
259 Result jaxbResult = this.objectFactory.createResult();
260 this.dispReport.getResult().add(jaxbResult);
261
262 if (result.getErrInfo() != null) jaxbResult.setErrInfo(result.getErrInfo());
263 if (result.getKeyType() != null) jaxbResult.setKeyType(result.getKeyType());
264 jaxbResult.setErrno(result.getErrno());
265 }
266
267
268
269
270 public String toString()
271 {
272 String msg = getMessage();
273 if (msg == null)
274 return "";
275 else
276 return getMessage();
277 }
278
279 private static final String buildMessage(int errno,String msg)
280 {
281 StringBuffer buffer = new StringBuffer();
282
283 String errCode = lookupErrCode(errno);
284 if (errCode != null)
285 {
286 buffer.append(errCode);
287 buffer.append(" ");
288 }
289
290 buffer.append("(");
291 buffer.append(errno);
292 buffer.append(") ");
293
294
295
296 String errText = "";
297 if (errText != null)
298 {
299 buffer.append(errText);
300 buffer.append(" ");
301 }
302
303 if ((msg != null) && (msg.trim().length() > 0))
304 {
305 buffer.append(msg);
306 }
307
308 return buffer.toString();
309 }
310
311 public static final String lookupErrCode(int errno)
312 {
313 switch (errno)
314 {
315 case E_ACCOUNT_LIMIT_EXCEEDED : return "E_accountLimitExceeded";
316 case E_ASSERTION_NOT_FOUND : return "E_assertionNotFound";
317 case E_AUTH_TOKEN_EXPIRED : return "E_authTokenExpired";
318 case E_AUTH_TOKEN_REQUIRED : return "E_authTokenRequired";
319 case E_BUSY : return "E_busy";
320 case E_CATEGORIZATION_NOT_ALLOWED : return "E_categorizationNotAllowed";
321 case E_FATAL_ERROR : return "E_fatalError";
322 case E_INVALID_CATEGORY : return "E_invalidCategory";
323 case E_INVALID_COMPLETION_STATUS : return "E_invalidCompletionStatus";
324 case E_INVALID_KEY_PASSED : return "E_invalidKeyPassed";
325 case E_INVALID_PROJECTION : return "E_invalidProjection";
326 case E_INVALID_TIME : return "E_invalidTime";
327 case E_INVALID_URL_PASSED : return "E_invalidURLPassed";
328 case E_INVALID_VALUE : return "E_invalidValue";
329 case E_KEY_RETIRED : return "E_keyRetired";
330 case E_LANGUAGE_ERROR : return "E_languageError";
331 case E_MESSAGE_TOO_LARGE : return "E_messageTooLarge";
332 case E_NAME_TOO_LONG : return "E_nameTooLong";
333 case E_OPERATOR_MISMATCH : return "E_operatorMismatch";
334 case E_PUBLISHER_CANCELLED : return "E_publisherCancelled";
335 case E_REQUEST_DENIED : return "E_requestDenied";
336 case E_REQUEST_TIMEOUT : return "E_requestTimeout";
337 case E_RESULT_SET_TOO_LARGE : return "E_resultSetTooLarge";
338 case E_SECRET_UNKNOWN : return "E_secretUnknown";
339 case E_SUCCESS : return "E_success";
340 case E_TOO_MANY_OPTIONS : return "E_tooManyOptions";
341 case E_TRANSFER_ABORTED : return "E_transferAborted";
342 case E_UNKNOWN_USER : return "E_unknownUser";
343 case E_UNRECOGNIZED_VERSION : return "E_unrecognizedVersion";
344 case E_UNSUPPORTED : return "E_unsupported";
345 case E_UNVALIDATABLE : return "E_unvalidatable";
346 case E_USER_MISMATCH : return "E_userMismatch";
347 case E_VALUE_NOT_ALLOWED : return "E_valueNotAllowed";
348 default : return null;
349 }
350 }
351 }