1 9 10 package org.uddi4j.response; 11 12 import java.util.Vector ; 13 14 import org.uddi4j.UDDIElement; 15 import org.uddi4j.UDDIException; 16 import org.w3c.dom.Element ; 17 import org.w3c.dom.NodeList ; 18 19 20 39 public class DispositionReport extends UDDIElement { 40 41 public static String UDDI_TAG = "dispositionReport"; 42 String genericAttrib = null; 44 String operatorAttrib = null; 45 String truncated = null; 46 47 Vector results = new Vector (); 48 49 50 51 52 56 public static final String E_assertionNotFound = "E_assertionNotFound"; 57 58 62 public static final String E_authTokenExpired = "E_authTokenExpired"; 63 64 65 69 public static final String E_authTokenRequired = "E_authTokenRequired"; 70 71 74 public static final String E_accountLimitExceeded = "E_accountLimitExceeded"; 75 76 79 public static final String E_busy = "E_busy"; 80 81 87 public static final String E_categorizationNotAllowed = "E_categorizationNotAllowed"; 88 89 93 public static final String E_fatalError= "E_fatalError"; 94 95 100 public static final String E_invalidKeyPassed = "E_invalidKeyPassed"; 101 102 107 public static final String E_invalidProjection = "E_invalidProjection"; 108 109 113 public static final String E_invalidCategory = "E_invalidCategory"; 114 115 119 public static final String E_invalidCompletionStatus = "E_invalidCompletionStatus"; 120 121 124 public static final String E_invalidURLPassed = "E_invalidURLPassed"; 125 126 131 public static final String E_invalidValue = "E_invalidValue"; 132 133 138 public static final String E_keyRetired = "E_keyRetired"; 139 140 145 public static final String E_languageError = "E_languageError"; 146 147 151 public static final String E_messageTooLarge = "E_messageTooLarge"; 152 153 157 public static final String E_nameTooLong = "E_nameTooLong"; 158 159 163 public static final String E_operatorMismatch = "E_operatorMismatch"; 164 165 168 public static final String E_publisherCancelled = "E_publisherCancelled"; 169 170 173 public static final String E_requestDenied = "E_requestDenied"; 174 175 179 public static final String E_requestTimeout = "E_requestTimeout"; 180 181 186 public static final String E_secretUnknown = "E_secretUnknown"; 187 188 192 public static final String E_success = "E_success"; 193 194 198 public static final String E_tooManyOptions = "E_tooManyOptions"; 199 200 203 public static final String E_transferAborted = "E_transferAborted"; 204 205 209 public static final String E_unrecognizedVersion = "E_unrecognizedVersion"; 210 211 215 public static final String E_unknownUser = "E_unknownUser"; 216 217 220 public static final String E_unsupported = "E_unsupported"; 221 222 226 public static final String E_unvalidatable = "E_unvalidatable"; 227 228 232 public static final String E_userMismatch = "E_userMismatch"; 233 234 239 public static final String E_valueNotAllowed = "E_valueNotAllowed"; 240 241 242 243 public DispositionReport() { 244 } 245 246 252 public DispositionReport(Element el) throws UDDIException { 253 boolean fault = false ; 254 UDDIException exception = null; 255 256 if( UDDIException.isValidElement(el) ) { 257 fault = true; 261 exception = new UDDIException(el, true); 262 NodeList nl = exception.getDetailElement().getElementsByTagName(UDDI_TAG); 263 if( nl.getLength()>0 ) { 264 base = (Element)nl.item(0); 265 } 266 else { 267 throw exception; 269 } 270 } 271 else { 272 base = el; 273 } 274 275 if( isValidElement(base) ) { 276 NodeList nl; 278 genericAttrib = el.getAttribute("generic"); 280 operatorAttrib = el.getAttribute("operator"); 281 truncated = el.getAttribute("truncated"); 282 283 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 public boolean getTruncated() { 296 return "true".equals(truncated); 297 } 298 public String getGeneric() { 299 return this.genericAttrib; 300 } 301 public String getOperator() { 302 return this.operatorAttrib; 303 } 304 305 306 public boolean success() { 307 boolean success = true; 309 for( int i = 0; i < results.size(); i++ ) { 310 int errnoInt = new Integer (((Result)results.elementAt(i)).getErrno()).intValue(); 311 success = success && (errnoInt == 0); 312 } 313 return success; 314 } 315 316 317 322 public int getErrno() { 323 if( results.size() > 0 ) 324 return new Integer (((Result)results.elementAt(0)).getErrno()).intValue(); 325 else 326 return -1; 327 } 328 329 333 public int getErrno(int index) { 334 if( results.size() > index ) 335 return new Integer (((Result)results.elementAt(index)).getErrno()).intValue(); 336 else 337 return -1; 338 } 339 340 344 public String 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 360 public String 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 376 public String 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 392 public String 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 408 public String getKeyType() { 409 if( results.size() > 0 ) 410 return((Result)results.elementAt(0)).getKeyType(); 411 else 412 return null; 413 } 414 415 419 public String getKeyType(int index) { 420 if( results.size() > index ) 421 return((Result)results.elementAt(index)).getKeyType(); 422 else 423 return null; 424 } 425 426 431 public Vector getResultVector() { 432 return results; 433 } 434 435 public int getNumResults() { 436 return results.size(); 437 } 438 439 441 public void setGeneric(String gen) { 442 genericAttrib = gen; 443 } 444 445 public void setOperator(String 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 458 public void setErrno(int errno) { 459 setErrno(0, errno); 460 } 461 462 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 (errno).toString() ); 477 478 } 479 } 480 481 485 public void setErrCode(String errCode) { 486 setErrCode(errCode, 0); 487 } 488 489 493 public void setErrCode(String 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 520 public void setErrInfoText(String errInfoText) { 521 setErrInfoText(errInfoText, 0); 522 } 523 524 528 public void setErrInfoText(String 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 555 public void setKeyType(String keyType) { 556 setKeyType(keyType, 0); 557 } 558 559 563 public void setKeyType(String 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 582 public void setResultVector( Vector rv ) { 583 if( rv != null ) 584 results = rv; 585 else 586 results = new Vector (); 587 } 588 589 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 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 |