1 16 17 package org.jboss.axis.message; 18 19 import org.jboss.axis.AxisFault; 20 import org.jboss.axis.Constants; 21 import org.jboss.axis.MessagePart; 22 import org.jboss.axis.utils.XMLUtils; 23 import org.w3c.dom.Attr ; 24 import org.w3c.dom.CDATASection ; 25 import org.w3c.dom.Comment ; 26 import org.w3c.dom.DOMException ; 27 import org.w3c.dom.DOMImplementation ; 28 import org.w3c.dom.Document ; 29 import org.w3c.dom.DocumentFragment ; 30 import org.w3c.dom.DocumentType ; 31 import org.w3c.dom.Element ; 32 import org.w3c.dom.EntityReference ; 33 import org.w3c.dom.NamedNodeMap ; 34 import org.w3c.dom.Node ; 35 import org.w3c.dom.NodeList ; 36 import org.w3c.dom.ProcessingInstruction ; 37 import org.w3c.dom.DOMConfiguration ; 38 import org.w3c.dom.UserDataHandler ; 39 40 import javax.xml.parsers.ParserConfigurationException ; 41 import javax.xml.soap.SOAPException ; 42 43 54 55 public class SOAPDocumentImpl implements Document 56 { 57 Document delegate = null; 59 MessagePart soapPart = null; 60 61 66 public SOAPDocumentImpl(MessagePart sp) 67 { 68 try 69 { 70 delegate = XMLUtils.newDocument(); 71 } 72 catch (ParserConfigurationException e) 73 { 74 } 76 soapPart = sp; 77 } 78 79 public DocumentType getDoctype() 80 { 81 return delegate.getDoctype(); 82 } 83 84 public DOMImplementation getImplementation() 85 { 86 return delegate.getImplementation(); 87 } 88 89 94 public Element getDocumentElement() 95 { 96 return soapPart.getDocumentElement(); 97 } 98 99 107 public org.w3c.dom.Element createElement(String tagName) 108 throws DOMException 109 { 110 int index = tagName.indexOf(":"); 111 String prefix, localname; 112 if (index < 0) 113 { 114 prefix = ""; 115 localname = tagName; 116 } 117 else 118 { 119 prefix = tagName.substring(0, index); 120 localname = tagName.substring(index + 1); 121 } 122 123 try 124 { 125 SOAPEnvelopeAxisImpl soapenv = 126 (org.jboss.axis.message.SOAPEnvelopeAxisImpl)soapPart.getEnvelope(); 127 if (soapenv != null) 128 { 129 if (tagName.equalsIgnoreCase(Constants.ELEM_ENVELOPE)) 130 new SOAPEnvelopeAxisImpl(); 131 if (tagName.equalsIgnoreCase(Constants.ELEM_HEADER)) 132 return new SOAPHeaderAxisImpl(soapenv, soapenv.getSOAPConstants()); 133 if (tagName.equalsIgnoreCase(Constants.ELEM_BODY)) 134 return new SOAPBodyAxisImpl(soapenv, soapenv.getSOAPConstants()); 135 if (tagName.equalsIgnoreCase(Constants.ELEM_FAULT)) 136 return new SOAPEnvelopeAxisImpl(); 137 if (tagName.equalsIgnoreCase(Constants.ELEM_FAULT_DETAIL)) 138 return new SOAPFaultImpl(new AxisFault(tagName)); 139 else 140 { 141 return new SOAPElementAxisImpl("", prefix, localname); 142 } 143 } 144 else 145 { 146 return new SOAPElementAxisImpl("", prefix, localname); 147 } 148 149 } 150 catch (SOAPException se) 151 { 152 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 153 } 154 } 155 156 162 public DocumentFragment createDocumentFragment() 163 { 164 return delegate.createDocumentFragment(); 165 } 166 167 173 public org.w3c.dom.Text createTextNode(String data) 174 { 175 return new TextImpl(delegate.createTextNode(data)); 176 } 177 178 184 public Comment createComment(String data) 185 { 186 return new CommentImpl(createTextNode(data)); 187 } 188 189 198 public CDATASection createCDATASection(String data) throws DOMException 199 { 200 return new CDATAImpl(createTextNode(data)); 201 } 202 203 214 public ProcessingInstruction createProcessingInstruction(String target, 215 String data) 216 throws DOMException 217 { 218 throw new java.lang.UnsupportedOperationException ("createProcessingInstruction"); 219 } 220 221 public Attr createAttribute(String name) throws DOMException 222 { 223 return delegate.createAttribute(name); 224 } 225 226 231 public EntityReference createEntityReference(String name) 232 throws DOMException 233 { 234 throw new java.lang.UnsupportedOperationException ("createEntityReference"); 235 } 236 237 public Node importNode(Node importedNode, boolean deep) 238 throws DOMException 239 { 240 throw new java.lang.UnsupportedOperationException ("importNode"); 241 } 242 243 251 public Element createElementNS(String namespaceURI, String qualifiedName) 252 throws DOMException 253 { 254 org.jboss.axis.soap.SOAPConstants soapConstants = null; 255 if (Constants.URI_SOAP11_ENV.equals(namespaceURI)) 256 { 257 soapConstants = org.jboss.axis.soap.SOAPConstants.SOAP11_CONSTANTS; 258 } 259 else if (Constants.URI_SOAP12_ENV.equals(namespaceURI)) 260 { 261 soapConstants = org.jboss.axis.soap.SOAPConstants.SOAP12_CONSTANTS; 262 } 263 264 SOAPElementAxisImpl me = null; 266 if (soapConstants != null) 267 { 268 if (qualifiedName.equals(Constants.ELEM_ENVELOPE)) 269 { 270 me = new SOAPEnvelopeAxisImpl(soapConstants); 272 } 273 else if (qualifiedName.equals(Constants.ELEM_HEADER)) 274 { 275 me = new SOAPHeaderAxisImpl(null, soapConstants); 276 } 278 else if (qualifiedName.equals(Constants.ELEM_BODY)) 279 { 280 me = new SOAPBodyAxisImpl(null, soapConstants); 281 } 282 else if (qualifiedName.equals(Constants.ELEM_FAULT)) 283 { 284 me = null; 285 } 286 else if (qualifiedName.equals(Constants.ELEM_FAULT_DETAIL)) 287 { 288 me = null; 290 } 291 else 292 { 293 throw new DOMException (DOMException.INVALID_STATE_ERR, 294 "No such Localname for SOAP URI"); 295 } 296 return null; 298 } 300 else 301 { 302 me = new SOAPElementAxisImpl(namespaceURI, qualifiedName); 303 } 304 305 if (me != null) 306 me.setOwnerDocument(soapPart); 307 308 return me; 309 310 } 311 312 315 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 316 throws DOMException 317 { 318 return delegate.createAttributeNS(namespaceURI, qualifiedName); 319 } 320 321 325 public NodeList getElementsByTagNameNS(String namespaceURI, 326 String localName) 327 { 328 try 329 { 330 if (soapPart != null) 331 { 332 SOAPEnvelopeAxisImpl soapEnv = 333 (org.jboss.axis.message.SOAPEnvelopeAxisImpl)soapPart 334 .getEnvelope(); 335 SOAPHeaderAxisImpl header = 336 (org.jboss.axis.message.SOAPHeaderAxisImpl)soapEnv.getHeader(); 337 if (header != null) 338 { 339 return header.getElementsByTagNameNS(namespaceURI, 340 localName); 341 } 342 SOAPBodyAxisImpl body = 343 (org.jboss.axis.message.SOAPBodyAxisImpl)soapEnv.getHeader(); 344 if (body != null) 345 { 346 return header.getElementsByTagNameNS(namespaceURI, 347 localName); 348 } 349 } 350 return null; 351 } 352 catch (SOAPException se) 353 { 354 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 355 } 356 } 357 358 362 public NodeList getElementsByTagName(String localName) 363 { 364 365 try 366 { 367 if (soapPart != null) 368 { 369 SOAPEnvelopeAxisImpl soapEnv = 370 (org.jboss.axis.message.SOAPEnvelopeAxisImpl)soapPart 371 .getEnvelope(); 372 SOAPHeaderAxisImpl header = 373 (org.jboss.axis.message.SOAPHeaderAxisImpl)soapEnv.getHeader(); 374 if (header != null) 375 { 376 return header.getElementsByTagName(localName); 377 } 378 SOAPBodyAxisImpl body = 379 (org.jboss.axis.message.SOAPBodyAxisImpl)soapEnv.getHeader(); 380 if (body != null) 381 { 382 return header.getElementsByTagName(localName); 383 } 384 } 385 return null; 386 } 387 catch (SOAPException se) 388 { 389 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 390 } 391 } 392 393 406 public Element getElementById(String elementId) 407 { 408 return delegate.getElementById(elementId); 409 } 410 411 414 415 public String getNodeName() 416 { 417 return null; 418 } 419 420 public String getNodeValue() throws DOMException 421 { 422 throw new DOMException (DOMException.NO_DATA_ALLOWED_ERR, 423 "Cannot use TextNode.get in " + this); 424 } 425 426 public void setNodeValue(String nodeValue) throws DOMException 427 { 428 throw new DOMException (DOMException.NO_DATA_ALLOWED_ERR, 429 "Cannot use TextNode.set in " + this); 430 } 431 432 437 public short getNodeType() 438 { 439 return Node.DOCUMENT_NODE; 440 } 441 442 public Node getParentNode() 443 { 444 return null; 445 } 446 447 public NodeList getChildNodes() 448 { 449 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 450 } 451 452 457 public Node getFirstChild() 458 { 459 try 460 { 461 if (soapPart != null) 462 return (org.jboss.axis.message.SOAPEnvelopeAxisImpl)soapPart 463 .getEnvelope(); 464 else 465 return null; 466 } 467 catch (SOAPException se) 468 { 469 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 470 } 471 472 } 473 474 477 public Node getLastChild() 478 { 479 try 480 { 481 if (soapPart != null) 482 return (org.jboss.axis.message.SOAPEnvelopeAxisImpl)soapPart 483 .getEnvelope(); 484 else 485 return null; 486 } 487 catch (SOAPException se) 488 { 489 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 490 } 491 492 } 493 494 public Node getPreviousSibling() 495 { 496 return null; 497 } 498 499 public Node getNextSibling() 500 { 501 502 return null; 503 } 504 505 public NamedNodeMap getAttributes() 506 { 507 return null; 508 } 509 510 513 public Document getOwnerDocument() 514 { 515 return null; 516 } 517 518 520 public Node insertBefore(Node newChild, Node refChild) 521 throws DOMException 522 { 523 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 524 } 525 526 public Node replaceChild(Node newChild, Node oldChild) 527 throws DOMException 528 { 529 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 530 } 531 532 public Node removeChild(Node oldChild) throws DOMException 533 { 534 try 535 { 536 Node envNode; 537 if (soapPart != null) 538 { 539 envNode = soapPart.getEnvelope(); 540 if (envNode.equals(oldChild)) 541 { 542 return envNode; 543 } 544 } 545 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 546 } 547 catch (SOAPException se) 548 { 549 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 550 } 551 } 552 553 public Node appendChild(Node newChild) throws DOMException 554 { 555 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 556 } 557 558 public boolean hasChildNodes() 559 { 560 try 561 { 562 if (soapPart != null) 563 { 564 if (soapPart.getEnvelope() != null) 565 { 566 return true; 567 } 568 } 569 return false; 570 } 571 catch (SOAPException se) 572 { 573 throw new DOMException (DOMException.INVALID_STATE_ERR, ""); 574 } 575 576 } 577 578 581 public Node cloneNode(boolean deep) 582 { 583 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 584 } 585 586 589 public void normalize() 590 { 591 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 592 } 593 594 private String [] features = {"foo", "bar"}; 596 private String version = "version 2.0"; 597 598 public boolean isSupported(String feature, String version) 599 { 600 if (!version.equalsIgnoreCase(version)) 601 return false; 602 else 603 return true; 604 } 605 606 public String getPrefix() 607 { 608 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 609 } 610 611 public void setPrefix(String prefix) 612 { 613 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 614 } 615 616 public String getNamespaceURI() 617 { 618 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 619 } 620 621 public void setNamespaceURI(String nsURI) 622 { 623 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 624 } 625 626 public String getLocalName() 627 { 628 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 629 } 630 631 public boolean hasAttributes() 632 { 633 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, ""); 634 } 635 636 public String getInputEncoding() 638 { 639 return null; 640 } 641 642 public String getXmlEncoding() 643 { 644 return null; 645 } 646 647 public boolean getXmlStandalone() 648 { 649 return false; 650 } 651 652 public void setXmlStandalone(boolean xmlStandalone) throws DOMException 653 { 654 655 } 656 657 public String getXmlVersion() 658 { 659 return null; 660 } 661 662 public void setXmlVersion(String xmlVersion) throws DOMException 663 { 664 665 } 666 667 public boolean getStrictErrorChecking() 668 { 669 return false; 670 } 671 672 public void setStrictErrorChecking(boolean strictErrorChecking) 673 { 674 675 } 676 677 public String getDocumentURI() 678 { 679 return null; 680 } 681 682 public void setDocumentURI(String documentURI) 683 { 684 685 } 686 687 public Node adoptNode(Node source) throws DOMException 688 { 689 return null; 690 } 691 692 public DOMConfiguration getDomConfig() 693 { 694 return null; 695 } 696 697 public void normalizeDocument() 698 { 699 700 } 701 702 public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException 703 { 704 return null; 705 } 706 707 public String getBaseURI() 708 { 709 return null; 710 } 711 712 public short compareDocumentPosition(Node other) throws DOMException 713 { 714 return 0; 715 } 716 717 public String getTextContent() throws DOMException 718 { 719 return null; 720 } 721 722 public void setTextContent(String textContent) throws DOMException 723 { 724 725 } 726 727 public boolean isSameNode(Node other) 728 { 729 return false; 730 } 731 732 public String lookupPrefix(String namespaceURI) 733 { 734 return null; 735 } 736 737 public boolean isDefaultNamespace(String namespaceURI) 738 { 739 return false; 740 } 741 742 public String lookupNamespaceURI(String prefix) 743 { 744 return null; 745 } 746 747 public boolean isEqualNode(Node arg) 748 { 749 return false; 750 } 751 752 public Object getFeature(String feature, String version) 753 { 754 return null; 755 } 756 757 public Object setUserData(String key, Object data, UserDataHandler handler) 758 { 759 return null; 760 } 761 762 public Object getUserData(String key) 763 { 764 return null; 765 } 766 } | Popular Tags |