package org.jboss.axis.message;
import org.jboss.axis.transport.http.HTTPConstants;
import org.jboss.axis.utils.Messages;
import org.jboss.logging.Logger;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.UserDataHandler;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import java.io.InputStream;
import java.util.Iterator;
public class SOAPPartImpl extends javax.xml.soap.SOAPPart
{
private static Logger log = Logger.getLogger(SOAPPartImpl.class.getName());
private SOAPMessage soapMessage;
private MimeHeaders mimeHeaders;
private SOAPEnvelope soapEnvelope;
private Document document;
private Source contentSource;
public SOAPPartImpl()
{
}
public SOAPPartImpl(SOAPMessage soapMessage, InputStream inStream, MimeHeaders headers)
{
this.soapMessage = soapMessage;
mimeHeaders = new MimeHeadersImpl(headers);
if (headers == null)
{
mimeHeaders = new MimeHeadersImpl();
mimeHeaders.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, "text/xml");
}
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(inStream);
document.getDocumentElement();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void addMimeHeader(String header, String value)
{
mimeHeaders.addHeader(header, value);
}
public String getContentLocation()
{
return getFirstMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION);
}
public void setContentLocation(String loc)
{
setMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION, loc);
}
public void setContentId(String newCid)
{
setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, newCid);
}
public String getContentId()
{
return getFirstMimeHeader(HTTPConstants.HEADER_CONTENT_ID);
}
public Iterator getMatchingMimeHeaders(final String[] match)
{
return mimeHeaders.getMatchingHeaders(match);
}
public Iterator getNonMatchingMimeHeaders(final String[] match)
{
return mimeHeaders.getNonMatchingHeaders(match);
}
public void setContent(Source source) throws SOAPException
{
if (source == null)
throw new SOAPException(Messages.getMessage("illegalArgumentException00"));
this.contentSource = source;
}
public Source getContent() throws SOAPException
{
return contentSource;
}
public Iterator getAllMimeHeaders()
{
return mimeHeaders.getAllHeaders();
}
public void setMimeHeader(String name, String value)
{
mimeHeaders.setHeader(name, value);
}
public String[] getMimeHeader(String name)
{
return mimeHeaders.getHeader(name);
}
public void removeAllMimeHeaders()
{
mimeHeaders.removeAllHeaders();
}
public void removeMimeHeader(String header)
{
mimeHeaders.removeHeader(header);
}
public SOAPEnvelope getEnvelope() throws SOAPException
{
return soapEnvelope;
}
private String getFirstMimeHeader(String header)
{
String[] values = mimeHeaders.getHeader(header);
if (values != null && values.length > 0)
return values[0];
return null;
}
public DocumentType getDoctype()
{
return document.getDoctype();
}
public DOMImplementation getImplementation()
{
return document.getImplementation();
}
public Element getDocumentElement()
{
return document.getDocumentElement();
}
public Element createElement(String tagName) throws DOMException
{
return document.createElement(tagName);
}
public DocumentFragment createDocumentFragment()
{
return document.createDocumentFragment();
}
public Text createTextNode(String data)
{
return document.createTextNode(data);
}
public Comment createComment(String data)
{
return document.createComment(data);
}
public CDATASection createCDATASection(String data) throws DOMException
{
return document.createCDATASection(data);
}
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
{
return document.createProcessingInstruction(target, data);
}
public Attr createAttribute(String name) throws DOMException
{
return document.createAttribute(name);
}
public EntityReference createEntityReference(String name) throws DOMException
{
return document.createEntityReference(name);
}
public NodeList getElementsByTagName(String tagname)
{
return document.getElementsByTagName(tagname);
}
public Node importNode(Node importedNode, boolean deep) throws DOMException
{
return document.importNode(importedNode, deep);
}
public Element createElementNS(String namespaceURI, String qualifiedName)
throws DOMException
{
return document.createElementNS(namespaceURI, qualifiedName);
}
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
throws DOMException
{
return document.createAttributeNS(namespaceURI, qualifiedName);
}
public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
{
return document.getElementsByTagNameNS(namespaceURI, localName);
}
public Element getElementById(String elementId)
{
return document.getElementById(elementId);
}
public String getNodeName()
{
return document.getNodeName();
}
public String getNodeValue() throws DOMException
{
return document.getNodeValue();
}
public void setNodeValue(String nodeValue) throws DOMException
{
document.setNodeValue(nodeValue);
}
public short getNodeType()
{
return document.getNodeType();
}
public Node getParentNode()
{
return document.getParentNode();
}
public NodeList getChildNodes()
{
return document.getChildNodes();
}
public Node getFirstChild()
{
return document.getFirstChild();
}
public Node getLastChild()
{
return document.getLastChild();
}
public Node getPreviousSibling()
{
return document.getPreviousSibling();
}
public Node getNextSibling()
{
return document.getNextSibling();
}
public NamedNodeMap getAttributes()
{
return document.getAttributes();
}
public Document getOwnerDocument()
{
return document.getOwnerDocument();
}
public Node insertBefore(Node newChild, Node refChild) throws DOMException
{
return document.insertBefore(newChild, refChild);
}
public Node replaceChild(Node newChild, Node oldChild) throws DOMException
{
return document.replaceChild(newChild, oldChild);
}
public Node removeChild(Node oldChild) throws DOMException
{
return document.removeChild(oldChild);
}
public Node appendChild(Node newChild) throws DOMException
{
return document.appendChild(newChild);
}
public boolean hasChildNodes()
{
return document.hasChildNodes();
}
public Node cloneNode(boolean deep)
{
return document.cloneNode(deep);
}
public void normalize()
{
document.normalize();
}
public boolean isSupported(String feature, String version)
{
return document.isSupported(feature, version);
}
public String getNamespaceURI()
{
return document.getNamespaceURI();
}
public String getPrefix()
{
return document.getPrefix();
}
public void setPrefix(String prefix) throws DOMException
{
document.setPrefix(prefix);
}
public String getLocalName()
{
return document.getLocalName();
}
public boolean hasAttributes()
{
return document.hasAttributes();
}
public String getInputEncoding()
{
return null;
}
public String getXmlEncoding()
{
return null;
}
public boolean getXmlStandalone()
{
return false;
}
public void setXmlStandalone(boolean xmlStandalone) throws DOMException
{
}
public String getXmlVersion()
{
return null;
}
public void setXmlVersion(String xmlVersion) throws DOMException
{
}
public boolean getStrictErrorChecking()
{
return false;
}
public void setStrictErrorChecking(boolean strictErrorChecking)
{
}
public String getDocumentURI()
{
return null;
}
public void setDocumentURI(String documentURI)
{
}
public Node adoptNode(Node source) throws DOMException
{
return null;
}
public DOMConfiguration getDomConfig()
{
return null;
}
public void normalizeDocument()
{
}
public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
{
return null;
}
public String getBaseURI()
{
return null;
}
public short compareDocumentPosition(Node other) throws DOMException
{
return 0;
}
public String getTextContent() throws DOMException
{
return null;
}
public void setTextContent(String textContent) throws DOMException
{
}
public boolean isSameNode(Node other)
{
return false;
}
public String lookupPrefix(String namespaceURI)
{
return null;
}
public boolean isDefaultNamespace(String namespaceURI)
{
return false;
}
public String lookupNamespaceURI(String prefix)
{
return null;
}
public boolean isEqualNode(Node arg)
{
return false;
}
public Object getFeature(String feature, String version)
{
return null;
}
public Object setUserData(String key, Object data, UserDataHandler handler)
{
return null;
}
public Object getUserData(String key)
{
return null;
}
}