KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > response > DispositionReport


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, International Business Machines Corporation
5  * Copyright (C) 2001, Hewlett-Packard Company
6  * All Rights Reserved.
7  *
8  */

9
10 package org.uddi4j.response;
11
12 import java.util.Vector JavaDoc;
13
14 import org.uddi4j.UDDIElement;
15 import org.uddi4j.UDDIException;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19
20 /**
21  * Represents an UDDI defined error. This object is returned from certain
22  * UDDI API calls. Other UDDI APIs return a data object if success and
23  * generate a fault message if failure. The API returns the fault
24  * by throwing a UDDIException.
25  *
26  * <P>UDDIException usually contains a Disposition report that has detailed
27  * information about the UDDI error as defined by the UDDI specification.
28  * If the response is a SOAP fault, but does not contains a disposition
29  * report, a UDDIException may be thrown without containing a
30  * DispositionReport.
31  *
32  * <P>This class contains defines for the various error values
33  * that can be returned.
34  *
35  * @author David Melgar (dmelgar@us.ibm.com)
36  * @author Ravi Trivedi (ravi_trivedi@hp.com)
37  * @author Ozzy (ozzy@hursley.ibm.com)
38  */

39 public class DispositionReport extends UDDIElement {
40
41     public static String JavaDoc UDDI_TAG = "dispositionReport";
42     // XML attributes. Looks common to all message responses
43
String JavaDoc genericAttrib = null;
44     String JavaDoc operatorAttrib = null;
45     String JavaDoc truncated = null;
46
47     Vector JavaDoc results = new Vector JavaDoc();
48
49     /* Defines of possible error codes that can be returned */
50
51
52     /**
53      * Signifies that a particular publisher assertion (consisting of two businessKey values, and
54      * a keyed reference with three components) cannot be identified in a save or delete operation.
55      */

56     public static final String JavaDoc E_assertionNotFound = "E_assertionNotFound";
57
58     /**
59      * Signifies that the authentication token value passed in the authInfo argument
60      * is no longer valid because the token has expired.
61      */

62     public static final String JavaDoc E_authTokenExpired = "E_authTokenExpired";
63
64
65     /**
66      * Signifies that the authentication token value passed in the authInfo argument
67      * is either missing or is not valid.
68      */

69     public static final String JavaDoc E_authTokenRequired = "E_authTokenRequired";
70
71     /**
72      * Signifies that user account limits have been exceeded.
73      */

74     public static final String JavaDoc E_accountLimitExceeded = "E_accountLimitExceeded";
75
76     /**
77      * Signifies that the request cannot be processed at the current time.
78      */

79     public static final String JavaDoc E_busy = "E_busy";
80
81     /**
82      * Restrictions have been placed by the taxonomy provider on the types of
83      * information that should be included at that location within a specific
84      * taxonomy. The validation routine chosen by the Operator Site has
85      * rejected this tModel for at least one specified category.
86      */

87     public static final String JavaDoc E_categorizationNotAllowed = "E_categorizationNotAllowed";
88
89     /**
90      * Signifies that a serious technical error has occurred while processing
91      * the request.
92      */

93     public static final String JavaDoc E_fatalError= "E_fatalError";
94
95     /**
96      * Signifies that the request cannot be satisfied because one or more uuid_key
97      * values specified is not a valid key value. This will occur if a uuid_key
98      * value is passed in a tModel that does not match with any known tModel key.
99      */

100     public static final String JavaDoc E_invalidKeyPassed = "E_invalidKeyPassed";
101
102     /**
103      * Signifies that an attempt was made to save a businessEntity containing a service projection
104      * that does not match the businessService being projected. The serviceKey of at least one such
105      * businessService will be included in the dispositionReport
106      */

107     public static final String JavaDoc E_invalidProjection = "E_invalidProjection";
108
109     /**
110      * Signifies that the given keyValue did not correspond to a category within
111      * the taxonomy identified by a tModelKey value within one of the categoryBag elements provided.
112      */

113     public static final String JavaDoc E_invalidCategory = "E_invalidCategory";
114
115     /**
116      * Signifies that one of assertion status values passed is unrecognized. The completion status
117      * that caused the problem will be clearly indicated in the error text.
118      */

119     public static final String JavaDoc E_invalidCompletionStatus = "E_invalidCompletionStatus";
120
121     /**
122      * An error occurred with one of the uploadRegister URL values.
123      */

124     public static final String JavaDoc E_invalidURLPassed = "E_invalidURLPassed";
125
126     /**
127      * A value that was passed in a keyValue attribute did not pass validation. This applies to
128      * checked categorizations, identifiers and other validated code lists. The error text will
129      * clearly indicate the key and value combination that failed validation.
130      */

131     public static final String JavaDoc E_invalidValue = "E_invalidValue";
132
133     /**
134      * Signifies that the request cannot be satisfied because one or more uuid_key
135      * values specified has previously been hidden or removed by the requester.
136      * This specifically applies to the tModelKey values passed.
137      */

138     public static final String JavaDoc E_keyRetired = "E_keyRetired";
139
140     /**
141      * Signifies that an error was detected while processing elements that were annotated with
142      * xml:lang qualifiers. Presently, only the description and name elements support xml:lang
143      * qualifications.
144      */

145     public static final String JavaDoc E_languageError = "E_languageError";
146
147     /**
148      * Signifies that the message it too large. The upper limit will be clearly indicated in the
149      * error text.
150      */

151     public static final String JavaDoc E_messageTooLarge = "E_messageTooLarge";
152
153     /**
154      * Signifies that the partial name value passed exceeds the maximum name length designated by
155      * the policy of an implementation or Operator Site.
156      */

157     public static final String JavaDoc E_nameTooLong = "E_nameTooLong";
158
159     /**
160      * Signifies that one or more of the uuid_key values passed refers to data
161      * that is not controlled by the Operator Site that received the request for processing.
162      */

163     public static final String JavaDoc E_operatorMismatch = "E_operatorMismatch";
164
165     /**
166      * Signifies that the target publisher cancelled the custody transfer operation.
167      */

168     public static final String JavaDoc E_publisherCancelled = "E_publisherCancelled";
169
170     /**
171      * Signifies that a custody transfer request has been refused.
172      */

173     public static final String JavaDoc E_requestDenied = "E_requestDenied";
174
175     /**
176      * Signifies that the request could not be carried out because a needed validate_values service did not
177      * respond in a reasonable amount of time.
178      */

179     public static final String JavaDoc E_requestTimeout = "E_requestTimeout";
180
181     /**
182      * Signifies that the target publisher was unable to match the shared secret and the five (5)
183      * attempt limit was exhausted. The target operator automatically cancelled the transfer
184      * operation.
185      */

186     public static final String JavaDoc E_secretUnknown = "E_secretUnknown";
187
188     /**
189      * Signifies no failure occurred. This return code is used with the dispositionReport for
190      * reporting results from requests with no natural response document.
191      */

192     public static final String JavaDoc E_success = "E_success";
193
194     /**
195      * Signifies that too many or incompatible arguments were passed. The error text will clearly
196      * indicate the nature of the problem.
197      */

198     public static final String JavaDoc E_tooManyOptions = "E_tooManyOptions";
199
200     /**
201      * Signifies that a custody transfer request will not succeed.
202      */

203     public static final String JavaDoc E_transferAborted = "E_transferAborted";
204
205     /**
206      * Signifies that the value of the generic attribute passed is unsupported by the Operator
207      * Instance being queried.
208      */

209     public static final String JavaDoc E_unrecognizedVersion = "E_unrecognizedVersion";
210
211     /**
212      * Signifies that the user ID and password pair passed in a get_authToken message is not known
213      * to the Operator Site or is not valid.
214      */

215     public static final String JavaDoc E_unknownUser = "E_unknownUser";
216
217     /**
218      * Signifies that the implementer does not support a feature or API.
219      */

220     public static final String JavaDoc E_unsupported = "E_unsupported";
221
222     /**
223      * Signifies that an attempt was made to reference a taxonomy or identifier system in a
224      * keyedReference whose tModel is categorized with the unvalidatable categorization.
225      */

226     public static final String JavaDoc E_unvalidatable = "E_unvalidatable";
227
228     /**
229      * Signifies that one or more of the uuid_key values passed refers to data
230      * that is not controlled by the individual who is represented by the authentication token.
231      */

232     public static final String JavaDoc E_userMismatch = "E_userMismatch";
233
234     /**
235      * Signifies that a value did not pass validation because of contextual issues. The value may
236      * be valid in some contexts, but not in the context used. The error text may contain information
237      * about the contextual problem.
238      */

239     public static final String JavaDoc E_valueNotAllowed = "E_valueNotAllowed";
240
241
242     /** Default constructor */
243     public DispositionReport() {
244     }
245
246     /**
247      * Constructer that parses the XML dom tree and extracts
248      * useful attributes.
249      *
250      * @param el Root element of the tree within the SOAP body.
251      */

252     public DispositionReport(Element el) throws UDDIException {
253         boolean fault = false ;
254         UDDIException exception = null;
255
256         if( UDDIException.isValidElement(el) ) {
257             //If it is a Fault, then there most likely is a Disposition report.
258
//If it is not present then the UDDIException constructor will
259
//handle it.
260
fault = true;
261             exception = new UDDIException(el, true);
262             NodeList JavaDoc nl = exception.getDetailElement().getElementsByTagName(UDDI_TAG);
263             if( nl.getLength()>0 ) {
264                 base = (Element)nl.item(0);
265             }
266             else {
267                 // Not a disposition report, some other error, throw it
268
throw exception;
269             }
270         }
271         else {
272             base = el;
273         }
274
275         if( isValidElement(base) ) {
276             // Extract useful attributes
277
NodeList JavaDoc nl;
278             // Extract attribute values
279
genericAttrib = el.getAttribute("generic");
280             operatorAttrib = el.getAttribute("operator");
281             truncated = el.getAttribute("truncated");
282
283             // Process embedded elements
284
nl = el.getElementsByTagName("result");
285             for( int i = 0; i<nl.getLength(); i++ ) {
286                 results.add( new Result( (Element)nl.item(i) ) );
287             }
288         }
289         if( fault ) {
290             throw exception;
291         }
292     }
293
294     // Getters
295
public boolean getTruncated() {
296         return "true".equals(truncated);
297     }
298     public String JavaDoc getGeneric() {
299         return this.genericAttrib;
300     }
301     public String JavaDoc getOperator() {
302         return this.operatorAttrib;
303     }
304
305
306     public boolean success() {
307         // Did all results return successful
308
boolean success = true;
309         for( int i = 0; i < results.size(); i++ ) {
310             int errnoInt = new Integer JavaDoc(((Result)results.elementAt(i)).getErrno()).intValue();
311             success = success && (errnoInt == 0);
312         }
313         return success;
314     }
315
316
317     /**
318      * @deprecated This method has been deprecated. Use
319      * {@link #getResultVector()} then
320      *
321      */

322     public int getErrno() {
323         if( results.size() > 0 )
324             return new Integer JavaDoc(((Result)results.elementAt(0)).getErrno()).intValue();
325         else
326             return -1;
327     }
328
329     /**
330      * @deprecated This method has been deprecated. Use
331      * {@link #getResultVector()} instead.
332      */

333     public int getErrno(int index) {
334         if( results.size() > index )
335             return new Integer JavaDoc(((Result)results.elementAt(index)).getErrno()).intValue();
336         else
337             return -1;
338     }
339
340     /**
341      * @deprecated This method has been deprecated. Use
342      * {@link #getResultVector()} instead.
343      */

344     public String JavaDoc getErrCode() {
345         if( results.size() > 0 ) {
346             Result r = (Result)results.elementAt(0);
347             if( r.getErrInfo() != null )
348                 return r.getErrInfo().getErrCode();
349             else
350                 return null;
351         }
352         else
353             return null;
354     }
355
356     /**
357      * @deprecated This method has been deprecated. Use
358      * {@link #getResultVector()} instead.
359      */

360     public String JavaDoc getErrCode(int index) {
361         if( results.size() > index ) {
362             Result r = (Result)results.elementAt(index);
363             if( r.getErrInfo() != null )
364                 return r.getErrInfo().getErrCode();
365             else
366                 return null;
367         }
368         else
369             return null;
370     }
371
372     /**
373      * @deprecated This method has been deprecated. Use
374      * {@link #getResultVector()} instead.
375      */

376     public String JavaDoc getErrInfoText() {
377         if( results.size() > 0 ) {
378             Result r = (Result)results.elementAt(0);
379             if( r.getErrInfo() != null )
380                 return r.getErrInfo().getText();
381             else
382                 return null;
383         }
384         else
385             return null;
386     }
387
388     /**
389      * @deprecated This method has been deprecated. Use
390      * {@link #getResultVector()} instead.
391      */

392     public String JavaDoc getErrInfoText(int index) {
393         if( results.size() > index ) {
394             Result r = (Result)results.elementAt(index);
395             if( r.getErrInfo() != null )
396                 return r.getErrInfo().getText();
397             else
398                 return null;
399         }
400         else
401             return null;
402     }
403
404     /**
405      * @deprecated This method has been deprecated. Use
406      * {@link #getResultVector()} instead.
407      */

408     public String JavaDoc getKeyType() {
409         if( results.size() > 0 )
410             return((Result)results.elementAt(0)).getKeyType();
411         else
412             return null;
413     }
414
415     /**
416      * @deprecated This method has been deprecated. Use
417      * {@link #getResultVector()} instead.
418      */

419     public String JavaDoc getKeyType(int index) {
420         if( results.size() > index )
421             return((Result)results.elementAt(index)).getKeyType();
422         else
423             return null;
424     }
425
426     /**
427      * Retrieves the Vector containing the <i>Result</i> objects that were
428      * present in this DispositionReport.
429      * @return s Vector the Vector of <i>Result</i> objects.
430      */

431     public Vector JavaDoc getResultVector() {
432         return results;
433     }
434
435     public int getNumResults() {
436         return results.size();
437     }
438
439     // Setters
440

441     public void setGeneric(String JavaDoc gen) {
442         genericAttrib = gen;
443     }
444
445     public void setOperator(String JavaDoc oper) {
446         operatorAttrib = oper;
447     }
448
449     public void setTruncated(boolean t) {
450         if( t ) this.truncated="true";
451         else this.truncated="false";
452     }
453
454     /**
455      * @deprecated This method has been deprecated. Use
456      * {@link #setResultVector( Vector )} instead.
457      */

458     public void setErrno(int errno) {
459         setErrno(0, errno);
460     }
461
462     /**
463      * @deprecated This method has been deprecated. Use
464      * {@link #setResultVector( Vector )} instead.
465      */

466     public void setErrno(int errno, int index) {
467         if( index >= 0 ) {
468
469             if( index > this.results.size() ) {
470                 this.results.setSize(index+1);
471                 Result r = new Result();
472                 this.results.setElementAt( r , index);
473             }
474
475             Result r = ((Result)results.elementAt(index));
476             r.setErrno( new Integer JavaDoc(errno).toString() );
477
478         }
479     }
480
481     /**
482      * @deprecated This method has been deprecated. Use
483      * {@link #setResultVector( Vector )} instead.
484      */

485     public void setErrCode(String JavaDoc errCode) {
486         setErrCode(errCode, 0);
487     }
488
489     /**
490      * @deprecated This method has been deprecated. Use
491      * {@link #setResultVector( Vector )} instead.
492      */

493     public void setErrCode(String JavaDoc errCode, int index) {
494         if( index >= 0 ) {
495
496             if( index > this.results.size() ) {
497                 this.results.setSize(index+1);
498                 Result r = new Result();
499                 ErrInfo ei = new ErrInfo();
500                 r.setErrInfo(ei);
501                 this.results.setElementAt( r , index);
502             }
503
504             Result r = ((Result)results.elementAt(index));
505             ErrInfo ei = r.getErrInfo();
506
507             if( ei==null )
508                 ei = new ErrInfo();
509
510             ei.setErrCode(errCode);
511             r.setErrInfo(ei);
512
513         }
514     }
515
516     /**
517      * @deprecated This method has been deprecated. Use
518      * {@link #setResultVector( Vector )} instead.
519      */

520     public void setErrInfoText(String JavaDoc errInfoText) {
521         setErrInfoText(errInfoText, 0);
522     }
523
524     /**
525      * @deprecated This method has been deprecated. Use
526      * {@link #setResultVector( Vector )} instead.
527      */

528     public void setErrInfoText(String JavaDoc errInfoText, int index) {
529         if( index >= 0 ) {
530
531             if( index > this.results.size() ) {
532                 this.results.setSize(index+1);
533                 Result r = new Result();
534                 ErrInfo ei = new ErrInfo();
535                 r.setErrInfo(ei);
536                 this.results.setElementAt( r , index);
537             }
538
539             Result r = ((Result)results.elementAt(index));
540             ErrInfo ei = r.getErrInfo();
541
542             if( ei==null )
543                 ei = new ErrInfo();
544
545             ei.setText(errInfoText);
546             r.setErrInfo(ei);
547
548         }
549     }
550
551     /**
552      * @deprecated This method has been deprecated. Use
553      * {@link #setResultVector( Vector )} instead.
554      */

555     public void setKeyType(String JavaDoc keyType) {
556         setKeyType(keyType, 0);
557     }
558
559     /**
560      * @deprecated This method has been deprecated. Use
561      * {@link #setResultVector( Vector )} instead.
562      */

563     public void setKeyType(String JavaDoc keyType, int index) {
564         if( index >= 0 ) {
565
566             if( index > this.results.size() ) {
567                 this.results.setSize(index+1);
568                 Result r = new Result();
569                 this.results.setElementAt( r , index);
570             }
571
572             Result r = ((Result)results.elementAt(index));
573             r.setKeyType( keyType );
574
575         }
576     }
577
578     /**
579      * Set the Vector of result objects for this DispositionReport
580      * @param rv Vector of <i>Result</i> objects.
581      */

582     public void setResultVector( Vector JavaDoc rv ) {
583         if( rv != null )
584             results = rv;
585         else
586             results = new Vector JavaDoc();
587     }
588
589     /**
590      * Tests the passed in element to determine if the
591      * element is a serialized version of this object.
592      *
593      * @param el Root element for this object
594      */

595     public boolean isValidElement(Element el) {
596         return el.getNodeName().equals(UDDI_TAG);
597     }
598
599     public void saveToXML(Element parent) {
600         base = parent.getOwnerDocument().createElement(UDDI_TAG);
601         // Save attributes
602
if( genericAttrib!=null ) {
603             base.setAttribute("generic", genericAttrib);
604         }
605         base.setAttribute("xmlns", UDDIElement.XMLNS);
606         if( operatorAttrib!=null ) {
607             base.setAttribute("operator", operatorAttrib);
608         }
609         if( truncated!=null ) {
610             base.setAttribute("truncated", truncated);
611         }
612         for( int i = 0; i < results.size(); i++ ) {
613             Result r = ((Result)results.elementAt(i));
614             if( r!=null )
615                 r.saveToXML(base);
616         }
617         parent.appendChild(base);
618     }
619 }
620
621
622
Popular Tags