You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/07/21 23:51:00 UTC
svn commit: r796551 -
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
Author: veithen
Date: Tue Jul 21 21:51:00 2009
New Revision: 796551
URL: http://svn.apache.org/viewvc?rev=796551&view=rev
Log:
The change in WSCOMMONS-485 implies that XOP decoding is always done at the same level (i.e. between the underlying parser and XOPAwareStAXOMBuilder/MTOMStAXSOAPModelBuilder). There is therefore no need any more for StreamingOMSerializer to do XOP decoding.
Regression tested with Axis2 trunk.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java?rev=796551&r1=796550&r2=796551&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializer.java Tue Jul 21 21:51:00 2009
@@ -21,18 +21,14 @@
import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
import org.apache.axiom.ext.stax.datahandler.DataHandlerWriter;
-import org.apache.axiom.om.OMAttachmentAccessor;
import org.apache.axiom.om.OMSerializer;
import org.apache.axiom.om.impl.builder.DataHandlerReaderUtils;
import org.apache.axiom.om.impl.util.OMSerializerUtil;
-import org.apache.axiom.om.util.ElementHelper;
import org.apache.axiom.util.stax.XMLStreamWriterUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.activation.DataHandler;
import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -59,13 +55,8 @@
/** Field depth */
private int depth = 0;
- public static final QName XOP_INCLUDE =
- new QName("http://www.w3.org/2004/08/xop/include", "Include");
-
private DataHandlerReader dataHandlerReader;
private DataHandlerWriter dataHandlerWriter;
- private boolean inputHasAttachments = false;
- private boolean skipEndElement = false;
/**
* Method serialize.
@@ -88,11 +79,6 @@
public void serialize(XMLStreamReader reader, XMLStreamWriter writer, boolean startAtNext)
throws XMLStreamException {
- // Set attachment status
- if (reader instanceof OMAttachmentAccessor) {
- inputHasAttachments = true;
- }
-
dataHandlerReader = DataHandlerReaderUtils.getDataHandlerReader(reader);
dataHandlerWriter = XMLStreamWriterUtils.getDataHandlerWriter(writer);
@@ -213,20 +199,6 @@
String eNamespace = reader.getNamespaceURI();
eNamespace = (eNamespace != null && eNamespace.length() == 0) ? null : eNamespace;
- if (this.inputHasAttachments &&
- XOP_INCLUDE.getNamespaceURI().equals(eNamespace)) {
- String eLocalPart = reader.getLocalName();
- if (XOP_INCLUDE.getLocalPart().equals(eLocalPart)) {
- if (serializeXOPInclude(reader, writer)) {
- // Since the xop:include is replaced with inlined text,
- // skip the rest of serialize element and skip the end event for
- // of the xop:include
- skipEndElement = true;
- return;
- }
- }
- }
-
// Write the startElement if required
boolean setPrefixFirst = OMSerializerUtil.isSetPrefixBeforeStartElement(writer);
if (!setPrefixFirst) {
@@ -418,10 +390,6 @@
*/
protected void serializeEndElement(XMLStreamWriter writer)
throws XMLStreamException {
- if (this.skipEndElement) {
- skipEndElement = false;
- return;
- }
writer.writeEndElement();
}
@@ -574,74 +542,6 @@
}
}
- /**
- * Inspect the current element and if it is an
- * XOP Include then write it out as inlined or optimized.
- * @param reader
- * @param writer
- * @return true if inlined
- */
- protected boolean serializeXOPInclude(XMLStreamReader reader,
- XMLStreamWriter writer) throws XMLStreamException {
- String cid = ElementHelper.getContentID(reader);
- // TODO: this is suboptimal because it forces loading of the data; we could do deferred loading here
- DataHandler dh = getDataHandler(cid, (OMAttachmentAccessor) reader);
- if (dh == null) {
- return false;
- }
-
- try {
- dataHandlerWriter.writeDataHandler(dh, cid, true);
- } catch (IOException ex) {
- throw new XMLStreamException("Unable to read data handler for content ID '" + cid + "'");
- }
- // The binary data always appears as "inlined" because DataHandlerWriter either uses base64
- // or generates an xop:Include element. Therefore we must always skip the xop:Include in
- // the original stream.
- return true;
- }
-
- private DataHandler getDataHandler(String cid, OMAttachmentAccessor oaa) {
- DataHandler dh = null;
-
- String blobcid = cid;
- if (blobcid.startsWith("cid:")) {
- blobcid = blobcid.substring(4);
- }
- // Get the attachment
- if (oaa != null) {
- dh = oaa.getDataHandler(blobcid);
- }
-
- if (dh == null) {
- blobcid = getNewCID(cid);
- if (blobcid.startsWith("cid:")) {
- blobcid = blobcid.substring(4);
- }
- if (oaa != null) {
- dh = oaa.getDataHandler(blobcid);
- }
- }
- return dh;
- }
-
- /**
- * @param cid
- * @return cid with translated characters
- */
- private String getNewCID(String cid) {
- String cid2 = cid;
-
- try {
- cid2 = java.net.URLDecoder.decode(cid, "UTF-8");
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("getNewCID decoding " + cid + " as UTF-8 decoding error: " + e);
- }
- }
- return cid2;
- }
-
private void serializeDataHandler() throws XMLStreamException {
try {
if (dataHandlerReader.isDeferred()) {