< prev index next >
src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/BodyImpl.java
Print this page
*** 28,52 ****
import java.util.Iterator;
import java.util.Locale;
import java.util.logging.Level;
import javax.xml.namespace.QName;
- import javax.xml.soap.*;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
- import org.w3c.dom.*;
- import org.w3c.dom.Node;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.StaxBridge;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
/**
* The implementation of SOAP-ENV:BODY or the SOAPBody abstraction.
*
* @author Anil Vijendran (anil@sun.com)
--- 28,61 ----
import java.util.Iterator;
import java.util.Locale;
import java.util.logging.Level;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import com.sun.xml.internal.messaging.saaj.util.SAAJUtil;
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument;
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
import com.sun.xml.internal.messaging.saaj.soap.StaxBridge;
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
+ import javax.xml.soap.Name;
+ import javax.xml.soap.SOAPBody;
+ import javax.xml.soap.SOAPBodyElement;
+ import javax.xml.soap.SOAPElement;
+ import javax.xml.soap.SOAPEnvelope;
+ import javax.xml.soap.SOAPException;
+ import javax.xml.soap.SOAPFault;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.DocumentFragment;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ import org.w3c.dom.NodeList;
/**
* The implementation of SOAP-ENV:BODY or the SOAPBody abstraction.
*
* @author Anil Vijendran (anil@sun.com)
*** 70,79 ****
--- 79,89 ----
protected abstract SOAPBodyElement createBodyElement(Name name);
protected abstract SOAPBodyElement createBodyElement(QName name);
protected abstract SOAPFault createFaultElement();
protected abstract QName getDefaultFaultCode();
+ @Override
public SOAPFault addFault() throws SOAPException {
if (hasFault()) {
log.severe("SAAJ0110.impl.fault.already.exists");
throw new SOAPExceptionImpl("Error: Fault already exists");
}
*** 86,95 ****
--- 96,106 ----
fault.setFaultString("Fault string, and possibly fault code, not set");
return fault;
}
+ @Override
public SOAPFault addFault(
Name faultCode,
String faultString,
Locale locale)
throws SOAPException {
*** 98,107 ****
--- 109,119 ----
fault.setFaultCode(faultCode);
fault.setFaultString(faultString, locale);
return fault;
}
+ @Override
public SOAPFault addFault(
QName faultCode,
String faultString,
Locale locale)
throws SOAPException {
*** 110,128 ****
--- 122,142 ----
fault.setFaultCode(faultCode);
fault.setFaultString(faultString, locale);
return fault;
}
+ @Override
public SOAPFault addFault(Name faultCode, String faultString)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
fault.setFaultString(faultString);
return fault;
}
+ @Override
public SOAPFault addFault(QName faultCode, String faultString)
throws SOAPException {
SOAPFault fault = addFault();
fault.setFaultCode(faultCode);
*** 145,163 ****
--- 159,179 ----
}
return null;
}
+ @Override
public boolean hasFault() {
QName payloadQName = getPayloadQName();
return getFaultQName().equals(payloadQName);
}
private Object getFaultQName() {
return new QName(getNamespaceURI(), "Fault");
}
+ @Override
public SOAPFault getFault() {
if (hasFault()) {
if (fault == null) {
//initialize fault member
fault = (SOAPFault) getSoapDocument().find(getFirstChildElement());
*** 165,174 ****
--- 181,191 ----
return fault;
}
return null;
}
+ @Override
public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
SOAPBodyElement newBodyElement =
(SOAPBodyElement) ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
name.getLocalName(),
*** 179,188 ****
--- 196,206 ----
}
addNode(newBodyElement);
return newBodyElement;
}
+ @Override
public SOAPBodyElement addBodyElement(QName qname) throws SOAPException {
SOAPBodyElement newBodyElement =
(SOAPBodyElement) ElementFactory.createNamedElement(
((SOAPDocument) getOwnerDocument()).getDocument(),
qname.getLocalPart(),
*** 193,215 ****
--- 211,236 ----
}
addNode(newBodyElement);
return newBodyElement;
}
+ @Override
public void setParentElement(SOAPElement element) throws SOAPException {
if (!(element instanceof SOAPEnvelope)) {
log.severe("SAAJ0111.impl.body.parent.must.be.envelope");
throw new SOAPException("Parent of SOAPBody has to be a SOAPEnvelope");
}
super.setParentElement(element);
}
+ @Override
protected SOAPElement addElement(Name name) throws SOAPException {
return addBodyElement(name);
}
+ @Override
protected SOAPElement addElement(QName name) throws SOAPException {
return addBodyElement(name);
}
// public Node insertBefore(Node newElement, Node ref) throws DOMException {
*** 224,233 ****
--- 245,255 ----
// newElement = new ElementWrapper((ElementImpl) newElement);
// }
// return super.replaceChild(newElement, ref);
// }
+ @Override
public SOAPBodyElement addDocument(Document document)
throws SOAPException {
/*
Element rootNode =
*** 250,270 ****
// This copies the whole tree which could be very big so it's slow.
// However, it does have the advantage of actually working.
org.w3c.dom.Node replacingNode = ownerDoc.importNode(docFrag, true);
// Adding replacingNode at the last of the children list of body
addNode(replacingNode);
! Iterator<Node> i =
getChildElements(NameImpl.copyElementName(rootElement));
// Return the child element with the required name which is at the
// end of the list
while(i.hasNext())
newBodyElement = (SOAPBodyElement) i.next();
}
return newBodyElement;
//*/
}
protected SOAPElement convertToSoapElement(Element element) {
final Node soapNode = getSoapDocument().findIfPresent(element);
if ((soapNode instanceof SOAPBodyElement) &&
//this check is required because ElementImpl currently
// implements SOAPBodyElement
--- 272,293 ----
// This copies the whole tree which could be very big so it's slow.
// However, it does have the advantage of actually working.
org.w3c.dom.Node replacingNode = ownerDoc.importNode(docFrag, true);
// Adding replacingNode at the last of the children list of body
addNode(replacingNode);
! Iterator<javax.xml.soap.Node> i =
getChildElements(NameImpl.copyElementName(rootElement));
// Return the child element with the required name which is at the
// end of the list
while(i.hasNext())
newBodyElement = (SOAPBodyElement) i.next();
}
return newBodyElement;
//*/
}
+ @Override
protected SOAPElement convertToSoapElement(Element element) {
final Node soapNode = getSoapDocument().findIfPresent(element);
if ((soapNode instanceof SOAPBodyElement) &&
//this check is required because ElementImpl currently
// implements SOAPBodyElement
*** 276,298 ****
(ElementImpl) createBodyElement(NameImpl
.copyElementName(element)));
}
}
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
public Document extractContentAsDocument() throws SOAPException {
! Iterator<Node> eachChild = getChildElements();
javax.xml.soap.Node firstBodyElement = null;
while (eachChild.hasNext() &&
!(firstBodyElement instanceof SOAPElement))
firstBodyElement = (javax.xml.soap.Node) eachChild.next();
--- 299,323 ----
(ElementImpl) createBodyElement(NameImpl
.copyElementName(element)));
}
}
+ @Override
public SOAPElement setElementQName(QName newName) throws SOAPException {
log.log(Level.SEVERE,
"SAAJ0146.impl.invalid.name.change.requested",
new Object[] {elementQName.getLocalPart(),
newName.getLocalPart()});
throw new SOAPException("Cannot change name for "
+ elementQName.getLocalPart() + " to "
+ newName.getLocalPart());
}
+ @Override
public Document extractContentAsDocument() throws SOAPException {
! Iterator<javax.xml.soap.Node> eachChild = getChildElements();
javax.xml.soap.Node firstBodyElement = null;
while (eachChild.hasNext() &&
!(firstBodyElement instanceof SOAPElement))
firstBodyElement = (javax.xml.soap.Node) eachChild.next();
< prev index next >