mirror of
https://github.com/openjdk/jdk.git
synced 2026-08-01 21:55:37 +00:00
Merge
This commit is contained in:
commit
3c879c4db2
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,12 @@
|
||||
|
||||
package com.sun.xml.internal.messaging.saaj.soap;
|
||||
|
||||
import com.sun.xml.internal.messaging.saaj.util.stax.SaajStaxWriter;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.util.SaajStaxWriter;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter;
|
||||
|
||||
|
||||
|
||||
@ -23,21 +23,19 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.org.jvnet.staxex.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.soap.SOAPElement;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
package com.sun.xml.internal.messaging.saaj.util.stax;
|
||||
|
||||
import com.sun.xml.internal.org.jvnet.staxex.Base64Data;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.BinaryText;
|
||||
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.util.DOMStreamReader;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import javax.xml.soap.SOAPElement;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* SaajStaxReaderEx
|
||||
*
|
||||
@ -63,12 +61,8 @@ public class SaajStaxReaderEx extends DOMStreamReader implements XMLStreamReader
|
||||
if (_current instanceof BinaryText) {
|
||||
binaryText = (BinaryText) _current;
|
||||
base64AttData = new Base64Data();
|
||||
try {
|
||||
base64AttData.set(binaryText.getDataHandler());
|
||||
base64AttData.set(binaryText.getDataHandler());
|
||||
//System.out.println("--------------- debug SaajStaxReaderEx binaryText " + binaryText);
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
} else {
|
||||
// if we are currently at text node, make sure that this is a meaningful text node.
|
||||
Node prev = _current.getPreviousSibling();
|
||||
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.org.jvnet.staxex.util;
|
||||
package com.sun.xml.internal.messaging.saaj.util.stax;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -55,6 +55,8 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
static final protected String Body = "Body";
|
||||
static final protected String xmlns = "xmlns";
|
||||
|
||||
private boolean isHeaderSeen = false;
|
||||
|
||||
public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException {
|
||||
soap = msg;
|
||||
this.envURI = uri;
|
||||
@ -91,6 +93,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
} else if (Header.equals(ln)) {
|
||||
isHeaderSeen = true;
|
||||
currentElement = soap.getSOAPHeader();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
@ -109,9 +112,13 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
}
|
||||
|
||||
private void fixPrefix(final String prfx) throws XMLStreamException {
|
||||
String oldPrfx = currentElement.getPrefix();
|
||||
fixPrefix(prfx, currentElement);
|
||||
}
|
||||
|
||||
private void fixPrefix(final String prfx, SOAPElement element) throws XMLStreamException {
|
||||
String oldPrfx = element.getPrefix();
|
||||
if (prfx != null && !prfx.equals(oldPrfx)) {
|
||||
currentElement.setPrefix(prfx);
|
||||
element.setPrefix(prfx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +144,21 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
|
||||
@Override
|
||||
public void writeEndDocument() throws XMLStreamException {
|
||||
try {
|
||||
if (!isHeaderSeen) {
|
||||
SOAPElement header = soap.getSOAPHeader();
|
||||
if (header != null) {
|
||||
String prefixAtHeader = header.getPrefix();
|
||||
SOAPElement env = getEnvelope();
|
||||
header.detachNode();
|
||||
if (prefixAtHeader != null && !prefixAtHeader.equals(env.getPrefix())) {
|
||||
env.removeNamespaceDeclaration(prefixAtHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.org.jvnet.staxex.util;
|
||||
package com.sun.xml.internal.messaging.saaj.util.stax;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
@ -42,6 +42,7 @@ import com.sun.xml.internal.org.jvnet.staxex.MtomEnabled;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.NamespaceContextEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.StreamingDataHandler;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.util.MtomStreamWriter;
|
||||
//
|
||||
//import com.sun.xml.internal.ws.api.message.saaj.SaajStaxWriter;
|
||||
//import com.sun.xml.internal.ws.developer.StreamingDataHandler;
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,15 +26,13 @@
|
||||
package com.sun.xml.internal.org.jvnet.staxex;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.Text;
|
||||
|
||||
/**
|
||||
* BinaryText represents a MTOM attachment.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface BinaryText extends Text {
|
||||
public interface BinaryText {
|
||||
public String getHref();
|
||||
public DataHandler getDataHandler() throws SOAPException;
|
||||
public DataHandler getDataHandler();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package com.sun.xml.internal.org.jvnet.staxex;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
@ -46,7 +45,6 @@ public interface StAxSOAPBody {
|
||||
/**
|
||||
* Retrieve payload qname without materializing its contents
|
||||
* @return
|
||||
* @throws SOAPException
|
||||
*/
|
||||
public QName getPayloadQName();
|
||||
|
||||
@ -58,7 +56,7 @@ public interface StAxSOAPBody {
|
||||
* Retrieve payload attribute value without materializing its contents
|
||||
* @param localName
|
||||
* @return
|
||||
* @throws SOAPException
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public String getPayloadAttributeValue(String localName) throws XMLStreamException;
|
||||
|
||||
@ -66,16 +64,16 @@ public interface StAxSOAPBody {
|
||||
* Retrieve payload attribute value without materializing its contents
|
||||
* @param qName
|
||||
* @return
|
||||
* @throws SOAPException
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public String getPayloadAttributeValue(QName qName) throws XMLStreamException;
|
||||
|
||||
public void materialize() throws SOAPException;
|
||||
public void materialize() throws XMLStreamException;
|
||||
}
|
||||
|
||||
public void setPayload(Payload src) throws SOAPException;
|
||||
public void setPayload(Payload src) throws XMLStreamException;
|
||||
|
||||
public Payload getPayload()throws SOAPException;
|
||||
public Payload getPayload()throws XMLStreamException;
|
||||
|
||||
public boolean hasStaxPayload();
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.util.SaajStaxWriter;
|
||||
|
||||
import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,8 +42,6 @@ import org.w3c.dom.Node;
|
||||
/**
|
||||
* SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface.
|
||||
*
|
||||
* @deprecated use com.sun.xml.internal.org.jvnet.staxex.util.SaajStaxWriter
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class SaajStaxWriter implements XMLStreamWriter {
|
||||
@ -57,16 +55,21 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
static final protected String Body = "Body";
|
||||
static final protected String xmlns = "xmlns";
|
||||
|
||||
public SaajStaxWriter(final SOAPMessage msg) throws SOAPException {
|
||||
private boolean isHeaderSeen = false;
|
||||
|
||||
public SaajStaxWriter(final SOAPMessage msg, String uri) throws SOAPException {
|
||||
soap = msg;
|
||||
currentElement = soap.getSOAPPart().getEnvelope();
|
||||
envURI = currentElement.getNamespaceURI();
|
||||
this.envURI = uri;
|
||||
}
|
||||
|
||||
public SOAPMessage getSOAPMessage() {
|
||||
return soap;
|
||||
}
|
||||
|
||||
protected SOAPElement getEnvelope() throws SOAPException {
|
||||
return soap.getSOAPPart().getEnvelope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(final String localName) throws XMLStreamException {
|
||||
try {
|
||||
@ -86,10 +89,11 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
try {
|
||||
if (envURI.equals(ns)) {
|
||||
if (Envelope.equals(ln)) {
|
||||
currentElement = soap.getSOAPPart().getEnvelope();
|
||||
currentElement = getEnvelope();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
} else if (Header.equals(ln)) {
|
||||
isHeaderSeen = true;
|
||||
currentElement = soap.getSOAPHeader();
|
||||
fixPrefix(prefix);
|
||||
return;
|
||||
@ -108,9 +112,13 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
}
|
||||
|
||||
private void fixPrefix(final String prfx) throws XMLStreamException {
|
||||
String oldPrfx = currentElement.getPrefix();
|
||||
fixPrefix(prfx, currentElement);
|
||||
}
|
||||
|
||||
private void fixPrefix(final String prfx, SOAPElement element) throws XMLStreamException {
|
||||
String oldPrfx = element.getPrefix();
|
||||
if (prfx != null && !prfx.equals(oldPrfx)) {
|
||||
currentElement.setPrefix(prfx);
|
||||
element.setPrefix(prfx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,6 +144,21 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
||||
|
||||
@Override
|
||||
public void writeEndDocument() throws XMLStreamException {
|
||||
try {
|
||||
if (!isHeaderSeen) {
|
||||
SOAPElement header = soap.getSOAPHeader();
|
||||
if (header != null) {
|
||||
String prefixAtHeader = header.getPrefix();
|
||||
SOAPElement env = getEnvelope();
|
||||
header.detachNode();
|
||||
if (prefixAtHeader != null && !prefixAtHeader.equals(env.getPrefix())) {
|
||||
env.removeNamespaceDeclaration(prefixAtHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SOAPException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user