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/06/20 21:48:45 UTC
svn commit: r786897 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-api/src/main/java/org/apache/axiom/om/impl/
axiom-api/src/test/resources/soap/soap11/
axiom-tests/src/test/java/org/apache/axi...
Author: veithen
Date: Sat Jun 20 19:48:45 2009
New Revision: 786897
URL: http://svn.apache.org/viewvc?rev=786897&view=rev
Log:
WSCOMMONS-477: Temporarily reverted change in r785554.
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/soap/soap11/SWAAttachmentStream.txt
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java?rev=786897&r1=786896&r2=786897&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMOutputFormat.java Sat Jun 20 19:48:45 2009
@@ -72,18 +72,6 @@
public static final String USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS =
"org.apache.axiom.om.OMFormat.use.cteBase64.forNonTextualAttachments";
- // The old default behavior for the swa output attachment order was the
- // natural order of the content ids.
- //
- // There are some customers who want the output order to match the
- // input order for swa attachments.
- public static final String RESPECT_SWA_ATTACHMENT_ORDER =
- "org.apache.axiom.om.OMFormat.respectSWAAttachmentOrder";
-
- public static final Boolean RESPECT_SWA_ATTACHMENT_ORDER_DEFAULT =
- Boolean.TRUE;
-
-
HashMap map = null; // Map of generic properties
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java?rev=786897&r1=786896&r2=786897&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/MIMEOutputUtils.java Sat Jun 20 19:48:45 2009
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
-import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
@@ -261,40 +260,14 @@
javax.activation.DataHandler dh = new javax.activation.DataHandler(
writer.toString(), "text/xml; charset="
+ format.getCharSetEncoding());
-
- // Get the collection of ids associated with the attachments
- Collection ids = null;
- if (respectSWAAttachmentOrder(format)) {
- // ContentIDList is the order of the incoming/added attachments
- ids = attachments.getContentIDList();
- } else {
- // ContentIDSet is an undefined order (the implemenentation currently
- // orders the attachments using the natural order of the content ids)
- ids = attachments.getContentIDSet();
- }
- writeDataHandlerWithAttachmentsMessage(dh, contentType, outputStream,
- attachments.getMap(), format, ids);
+ writeDataHandlerWithAttachmentsMessage(dh, contentType, outputStream, attachments.getMap(), format);
}
public static void writeDataHandlerWithAttachmentsMessage(DataHandler rootDataHandler,
- String contentType,
- OutputStream outputStream,
- Map attachments,
- OMOutputFormat format) {
- writeDataHandlerWithAttachmentsMessage(rootDataHandler,
- contentType,
- outputStream,
- attachments,
- format,
- null);
-
- }
- public static void writeDataHandlerWithAttachmentsMessage(DataHandler rootDataHandler,
String contentType,
OutputStream outputStream,
Map attachments,
- OMOutputFormat format,
- Collection ids) {
+ OMOutputFormat format) {
try {
startWritingMime(outputStream, format.getMimeBoundary());
@@ -309,20 +282,9 @@
writeBodyPart(outputStream, rootMimeBodyPart, format
.getMimeBoundary());
- Iterator idIterator = null;
- if (ids == null) {
- // If ids are not provided, use the attachment map
- // to get the keys
- idIterator = attachments.keySet().iterator();
- } else {
- // if ids are provided (normal case), iterate
- // over the ids so that the attachments are
- // written in the same order as the id keys.
- idIterator = ids.iterator();
- }
-
- while (idIterator.hasNext()) {
- String key = (String) idIterator.next();
+ Iterator iterator = attachments.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
MimeBodyPart part = createMimeBodyPart(key,
(DataHandler) attachments.get(key), format);
writeBodyPart(outputStream, part,
@@ -395,15 +357,7 @@
outputStream.write(CRLF);
outputStream.write(CRLF);
startWritingMime(outputStream, innerBoundary);
- Iterator attachmentIDIterator = null;
- if (respectSWAAttachmentOrder(format)) {
- // ContentIDList is the order of the incoming/added attachments
- attachmentIDIterator = attachments.getContentIDList().iterator();
- } else {
- // ContentIDSet is an undefined order (the implemenentation currently
- // orders the attachments using the natural order of the content ids)
- attachmentIDIterator = attachments.getContentIDSet().iterator();
- }
+ Iterator attachmentIDIterator = attachments.getContentIDSet().iterator();
while (attachmentIDIterator.hasNext()) {
String contentID = (String) attachmentIDIterator.next();
DataHandler dataHandler = attachments.getDataHandler(contentID);
@@ -422,16 +376,4 @@
throw new OMException("Problem writing Mime Parts.", e);
}
}
-
- /**
- * @param format
- * @return true if the incoming attachment order should be respected
- */
- private static boolean respectSWAAttachmentOrder(OMOutputFormat format) {
- Boolean value = (Boolean) format.getProperty(OMOutputFormat.RESPECT_SWA_ATTACHMENT_ORDER);
- if (value == null) {
- value = OMOutputFormat.RESPECT_SWA_ATTACHMENT_ORDER_DEFAULT;
- }
- return value.booleanValue();
- }
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=786897&r1=786896&r2=786897&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java Sat Jun 20 19:48:45 2009
@@ -24,23 +24,15 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.TestConstants;
-import org.apache.axiom.om.impl.MIMEOutputUtils;
import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
-import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
import java.util.Arrays;
import java.util.Set;
@@ -52,10 +44,6 @@
String img1FileName = "mtom/img/test.jpg";
String img2FileName = "mtom/img/test2.jpg";
- String inSWAFileName = "soap/soap11/SWAAttachmentStream.txt";
-
- String contentTypeString =
- "multipart/related; boundary=\"MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701\"; type=\"application/xop+xml\"; start=\"<0....@apache.org>\"; start-info=\"application/soap+xml\"; charset=UTF-8;action=\"mtomSample\"";
public void testMIMEHelper() {
}
@@ -260,78 +248,6 @@
"][" + expectedArray.length + "]");
}
}
-
- public void testSWAWriteWithContentIDOrder() throws Exception {
-
- // Read the stream that has soap xml followed by BAttachment then AAttachment
- InputStream inStream = getTestResource(inSWAFileName);
- Attachments attachments = new Attachments(inStream, contentTypeString);
-
- // Get the contentIDs to force the reading
- String[] contentIDs = attachments.getAllContentIDs();
-
- // Get the root
- XMLStreamReader reader =
- XMLInputFactory.newInstance()
- .createXMLStreamReader(new BufferedReader(new InputStreamReader(attachments.getSOAPPartInputStream())));
- MTOMStAXSOAPModelBuilder builder =
- new MTOMStAXSOAPModelBuilder(reader, attachments, null);
- OMElement root = builder.getDocumentElement();
- StringWriter xmlWriter = new StringWriter();
- root.serialize(xmlWriter);
-
- // Serialize the message using the legacy behavior (order by content id)
- OMOutputFormat format = new OMOutputFormat();
- format.setCharSetEncoding("utf-8");
- format.setDoingSWA(true);
- format.setProperty(OMOutputFormat.RESPECT_SWA_ATTACHMENT_ORDER, Boolean.FALSE);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- MIMEOutputUtils.writeSOAPWithAttachmentsMessage(xmlWriter, baos, attachments, format);
-
- String text = baos.toString();
- // Assert that AAttachment occurs before BAttachment since
- // that is the natural ordering of the content ids.
- assertTrue(text.indexOf("AAttachment") < text.indexOf("BAttachment"));
-
- }
-
- public void testSWAWriteWithIncomingOrder() throws Exception {
-
- // Read the stream that has soap xml followed by BAttachment then AAttachment
- InputStream inStream = getTestResource(inSWAFileName);
- Attachments attachments = new Attachments(inStream, contentTypeString);
-
- // Get the contentIDs to force the reading
- String[] contentIDs = attachments.getAllContentIDs();
-
- // Get the root
- XMLStreamReader reader =
- XMLInputFactory.newInstance()
- .createXMLStreamReader(new BufferedReader(new InputStreamReader(attachments.getSOAPPartInputStream())));
- MTOMStAXSOAPModelBuilder builder =
- new MTOMStAXSOAPModelBuilder(reader, attachments, null);
- OMElement root = builder.getDocumentElement();
- StringWriter xmlWriter = new StringWriter();
- root.serialize(xmlWriter);
-
- // Serialize the message using the legacy behavior (order by content id)
- OMOutputFormat format = new OMOutputFormat();
- format.setCharSetEncoding("utf-8");
- format.setDoingSWA(true);
- format.setProperty(OMOutputFormat.RESPECT_SWA_ATTACHMENT_ORDER, Boolean.TRUE);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- MIMEOutputUtils.writeSOAPWithAttachmentsMessage(xmlWriter, baos, attachments, format);
-
- String text = baos.toString();
- // Assert that AAttachment occurs before BAttachment since
- // that is the natural ordering of the content ids.
- assertTrue(text.indexOf("BAttachment") < text.indexOf("AAttachment"));
-
- }
public void testGetDataHandler() throws Exception {