1 7 package org.jboss.axis.message; 8 9 11 import org.jboss.axis.transport.http.HTTPConstants; 12 import org.jboss.axis.utils.Messages; 13 import org.jboss.logging.Logger; 14 import org.w3c.dom.Attr ; 15 import org.w3c.dom.CDATASection ; 16 import org.w3c.dom.Comment ; 17 import org.w3c.dom.DOMException ; 18 import org.w3c.dom.DOMImplementation ; 19 import org.w3c.dom.Document ; 20 import org.w3c.dom.DocumentFragment ; 21 import org.w3c.dom.DocumentType ; 22 import org.w3c.dom.Element ; 23 import org.w3c.dom.EntityReference ; 24 import org.w3c.dom.NamedNodeMap ; 25 import org.w3c.dom.Node ; 26 import org.w3c.dom.NodeList ; 27 import org.w3c.dom.ProcessingInstruction ; 28 import org.w3c.dom.Text ; 29 import org.w3c.dom.DOMConfiguration ; 30 import org.w3c.dom.UserDataHandler ; 31 32 import javax.xml.parsers.DocumentBuilder ; 33 import javax.xml.parsers.DocumentBuilderFactory ; 34 import javax.xml.soap.MimeHeaders ; 35 import javax.xml.soap.SOAPEnvelope ; 36 import javax.xml.soap.SOAPException ; 37 import javax.xml.soap.SOAPMessage ; 38 import javax.xml.transform.Source ; 39 import java.io.InputStream ; 40 import java.util.Iterator ; 41 42 51 public class SOAPPartImpl extends javax.xml.soap.SOAPPart 52 { 53 54 private static Logger log = Logger.getLogger(SOAPPartImpl.class.getName()); 55 56 private SOAPMessage soapMessage; 57 private MimeHeaders mimeHeaders; 58 private SOAPEnvelope soapEnvelope; 59 60 private Document document; 61 62 private Source contentSource; 64 65 public SOAPPartImpl() 66 { 67 } 68 69 public SOAPPartImpl(SOAPMessage soapMessage, InputStream inStream, MimeHeaders headers) 70 { 71 this.soapMessage = soapMessage; 72 73 mimeHeaders = new MimeHeadersImpl(headers); 74 if (headers == null) 75 { 76 mimeHeaders = new MimeHeadersImpl(); 77 mimeHeaders.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml"); 78 } 79 80 try 81 { 82 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 83 factory.setValidating(false); 84 factory.setNamespaceAware(true); 85 DocumentBuilder builder = factory.newDocumentBuilder(); 86 document = builder.parse(inStream); 87 document.getDocumentElement(); 88 } 89 catch (Exception e) 90 { 91 e.printStackTrace(); 92 } 93 } 94 95 101 public void addMimeHeader(String header, String value) 102 { 103 mimeHeaders.addHeader(header, value); 104 } 105 106 111 public String getContentLocation() 112 { 113 return getFirstMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION); 114 } 115 116 121 public void setContentLocation(String loc) 122 { 123 setMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION, loc); 124 } 125 126 132 public void setContentId(String newCid) 133 { 134 setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, newCid); 135 } 136 137 142 public String getContentId() 143 { 144 return getFirstMimeHeader(HTTPConstants.HEADER_CONTENT_ID); 145 } 146 147 153 public Iterator getMatchingMimeHeaders(final String [] match) 154 { 155 return mimeHeaders.getMatchingHeaders(match); 156 } 157 158 165 public Iterator getNonMatchingMimeHeaders(final String [] match) 166 { 167 return mimeHeaders.getNonMatchingHeaders(match); 168 } 169 170 177 public void setContent(Source source) throws SOAPException 178 { 179 180 if (source == null) 181 throw new SOAPException (Messages.getMessage("illegalArgumentException00")); 182 183 185 this.contentSource = source; 186 209 } 210 211 218 public Source getContent() throws SOAPException 219 { 220 248 return contentSource; 249 } 250 251 259 public Iterator getAllMimeHeaders() 260 { 261 return mimeHeaders.getAllHeaders(); 262 } 263 264 289 public void setMimeHeader(String name, String value) 290 { 291 mimeHeaders.setHeader(name, value); 292 } 293 294 305 public String [] getMimeHeader(String name) 306 { 307 return mimeHeaders.getHeader(name); 308 } 309 310 314 public void removeAllMimeHeaders() 315 { 316 mimeHeaders.removeAllHeaders(); 317 } 318 319 325 public void removeMimeHeader(String header) 326 { 327 mimeHeaders.removeHeader(header); 328 } 329 330 339 public SOAPEnvelope getEnvelope() throws SOAPException 340 { 341 return soapEnvelope; 342 } 343 344 350 private String getFirstMimeHeader(String header) 351 { 352 String [] values = mimeHeaders.getHeader(header); 353 if (values != null && values.length > 0) 354 return values[0]; 355 return null; 356 } 357 358 360 public DocumentType getDoctype() 361 { 362 return document.getDoctype(); 363 } 364 365 public DOMImplementation getImplementation() 366 { 367 return document.getImplementation(); 368 } 369 370 public Element getDocumentElement() 371 { 372 return document.getDocumentElement(); 373 } 374 375 public Element createElement(String tagName) throws DOMException 376 { 377 return document.createElement(tagName); 378 } 379 380 public DocumentFragment createDocumentFragment() 381 { 382 return document.createDocumentFragment(); 383 } 384 385 public Text createTextNode(String data) 386 { 387 return document.createTextNode(data); 388 } 389 390 public Comment createComment(String data) 391 { 392 return document.createComment(data); 393 } 394 395 public CDATASection createCDATASection(String data) throws DOMException 396 { 397 return document.createCDATASection(data); 398 } 399 400 public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException 401 { 402 return document.createProcessingInstruction(target, data); 403 } 404 405 public Attr createAttribute(String name) throws DOMException 406 { 407 return document.createAttribute(name); 408 } 409 410 public EntityReference createEntityReference(String name) throws DOMException 411 { 412 return document.createEntityReference(name); 413 } 414 415 public NodeList getElementsByTagName(String tagname) 416 { 417 return document.getElementsByTagName(tagname); 418 } 419 420 public Node importNode(Node importedNode, boolean deep) throws DOMException 421 { 422 return document.importNode(importedNode, deep); 423 } 424 425 public Element createElementNS(String namespaceURI, String qualifiedName) 426 throws DOMException 427 { 428 return document.createElementNS(namespaceURI, qualifiedName); 429 } 430 431 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 432 throws DOMException 433 { 434 return document.createAttributeNS(namespaceURI, qualifiedName); 435 } 436 437 public NodeList getElementsByTagNameNS(String namespaceURI, String localName) 438 { 439 return document.getElementsByTagNameNS(namespaceURI, localName); 440 } 441 442 public Element getElementById(String elementId) 443 { 444 return document.getElementById(elementId); 445 } 446 447 449 public String getNodeName() 450 { 451 return document.getNodeName(); 452 } 453 454 public String getNodeValue() throws DOMException 455 { 456 return document.getNodeValue(); 457 } 458 459 public void setNodeValue(String nodeValue) throws DOMException 460 { 461 document.setNodeValue(nodeValue); 462 } 463 464 public short getNodeType() 465 { 466 return document.getNodeType(); 467 } 468 469 public Node getParentNode() 470 { 471 return document.getParentNode(); 472 } 473 474 public NodeList getChildNodes() 475 { 476 return document.getChildNodes(); 477 } 478 479 public Node getFirstChild() 480 { 481 return document.getFirstChild(); 482 } 483 484 public Node getLastChild() 485 { 486 return document.getLastChild(); 487 } 488 489 public Node getPreviousSibling() 490 { 491 return document.getPreviousSibling(); 492 } 493 494 public Node getNextSibling() 495 { 496 return document.getNextSibling(); 497 } 498 499 public NamedNodeMap getAttributes() 500 { 501 return document.getAttributes(); 502 } 503 504 public Document getOwnerDocument() 505 { 506 return document.getOwnerDocument(); 507 } 508 509 public Node insertBefore(Node newChild, Node refChild) throws DOMException 510 { 511 return document.insertBefore(newChild, refChild); 512 } 513 514 public Node replaceChild(Node newChild, Node oldChild) throws DOMException 515 { 516 return document.replaceChild(newChild, oldChild); 517 } 518 519 public Node removeChild(Node oldChild) throws DOMException 520 { 521 return document.removeChild(oldChild); 522 } 523 524 public Node appendChild(Node newChild) throws DOMException 525 { 526 return document.appendChild(newChild); 527 } 528 529 public boolean hasChildNodes() 530 { 531 return document.hasChildNodes(); 532 } 533 534 public Node cloneNode(boolean deep) 535 { 536 return document.cloneNode(deep); 537 } 538 539 public void normalize() 540 { 541 document.normalize(); 542 } 543 544 public boolean isSupported(String feature, String version) 545 { 546 return document.isSupported(feature, version); 547 } 548 549 public String getNamespaceURI() 550 { 551 return document.getNamespaceURI(); 552 } 553 554 public String getPrefix() 555 { 556 return document.getPrefix(); 557 } 558 559 public void setPrefix(String prefix) throws DOMException 560 { 561 document.setPrefix(prefix); 562 } 563 564 public String getLocalName() 565 { 566 return document.getLocalName(); 567 } 568 569 public boolean hasAttributes() 570 { 571 return document.hasAttributes(); 572 } 573 574 public String getInputEncoding() 576 { 577 return null; 578 } 579 580 public String getXmlEncoding() 581 { 582 return null; 583 } 584 585 public boolean getXmlStandalone() 586 { 587 return false; 588 } 589 590 public void setXmlStandalone(boolean xmlStandalone) throws DOMException 591 { 592 593 } 594 595 public String getXmlVersion() 596 { 597 return null; 598 } 599 600 public void setXmlVersion(String xmlVersion) throws DOMException 601 { 602 603 } 604 605 public boolean getStrictErrorChecking() 606 { 607 return false; 608 } 609 610 public void setStrictErrorChecking(boolean strictErrorChecking) 611 { 612 613 } 614 615 public String getDocumentURI() 616 { 617 return null; 618 } 619 620 public void setDocumentURI(String documentURI) 621 { 622 623 } 624 625 public Node adoptNode(Node source) throws DOMException 626 { 627 return null; 628 } 629 630 public DOMConfiguration getDomConfig() 631 { 632 return null; 633 } 634 635 public void normalizeDocument() 636 { 637 638 } 639 640 public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException 641 { 642 return null; 643 } 644 public String getBaseURI() 645 { 646 return null; 647 } 648 649 public short compareDocumentPosition(Node other) throws DOMException 650 { 651 return 0; 652 } 653 654 public String getTextContent() throws DOMException 655 { 656 return null; 657 } 658 659 public void setTextContent(String textContent) throws DOMException 660 { 661 662 } 663 664 public boolean isSameNode(Node other) 665 { 666 return false; 667 } 668 669 public String lookupPrefix(String namespaceURI) 670 { 671 return null; 672 } 673 674 public boolean isDefaultNamespace(String namespaceURI) 675 { 676 return false; 677 } 678 679 public String lookupNamespaceURI(String prefix) 680 { 681 return null; 682 } 683 684 public boolean isEqualNode(Node arg) 685 { 686 return false; 687 } 688 689 public Object getFeature(String feature, String version) 690 { 691 return null; 692 } 693 694 public Object setUserData(String key, Object data, UserDataHandler handler) 695 { 696 return null; 697 } 698 699 public Object getUserData(String key) 700 { 701 return null; 702 } 703 } 705 | Popular Tags |