You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2022/11/05 14:17:54 UTC

[ws-axiom] branch master updated: [AXIOM-506] Migrate OMMultipartWriter to the Blob API

This is an automated email from the ASF dual-hosted git repository.

veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git


The following commit(s) were added to refs/heads/master by this push:
     new db755ec99 [AXIOM-506] Migrate OMMultipartWriter to the Blob API
db755ec99 is described below

commit db755ec9909842f441c4227be46e2588e942a49c
Author: Andreas Veithen <an...@gmail.com>
AuthorDate: Sat Nov 5 14:17:46 2022 +0000

    [AXIOM-506] Migrate OMMultipartWriter to the Blob API
---
 .../java/org/apache/axiom/om/impl/OMMultipartWriter.java   | 14 +++++---------
 .../apache/axiom/om/impl/mixin/AxiomContainerMixin.java    |  3 ++-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/axiom-api/src/main/java/org/apache/axiom/om/impl/OMMultipartWriter.java b/axiom-api/src/main/java/org/apache/axiom/om/impl/OMMultipartWriter.java
index a6cee0138..5c45580c5 100644
--- a/axiom-api/src/main/java/org/apache/axiom/om/impl/OMMultipartWriter.java
+++ b/axiom-api/src/main/java/org/apache/axiom/om/impl/OMMultipartWriter.java
@@ -23,8 +23,6 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
 
-import javax.activation.DataHandler;
-
 import org.apache.axiom.attachments.ConfigurableDataHandler;
 import org.apache.axiom.blob.Blob;
 import org.apache.axiom.mime.ContentTransferEncoding;
@@ -38,7 +36,6 @@ import org.apache.axiom.om.format.xop.ContentTransferEncodingPolicy;
 import org.apache.axiom.om.format.xop.ContentTypeProvider;
 import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.util.activation.DataHandlerContentTypeProvider;
-import org.apache.axiom.util.activation.DataHandlerUtils;
 
 /**
  * Writes a MIME multipart package as used by XOP/MTOM and SOAP with Attachments. This class wraps a
@@ -155,7 +152,7 @@ public class OMMultipartWriter {
      * {@link MultipartBodyWriter#writePart(Blob, ContentType, ContentTransferEncoding, String, List)}, but computes the
      * appropriate content transfer encoding from the {@link OMOutputFormat}.
      * 
-     * @param dataHandler
+     * @param blob
      *            the content of the MIME part to write
      * @param contentID
      *            the content ID of the MIME part
@@ -164,8 +161,7 @@ public class OMMultipartWriter {
      * @throws IOException
      *             if an I/O error occurs when writing the part to the underlying stream
      */
-    public void writePart(DataHandler dataHandler, String contentID, List<Header> extraHeaders) throws IOException {
-        Blob blob = DataHandlerUtils.toBlob(dataHandler);
+    public void writePart(Blob blob, String contentID, List<Header> extraHeaders) throws IOException {
         ContentType contentType = contentTypeProvider.getContentType(blob);
         writer.writePart(blob, contentType, getContentTransferEncoding(blob, contentType), contentID, extraHeaders);
     }
@@ -175,15 +171,15 @@ public class OMMultipartWriter {
      * {@link MultipartBodyWriter#writePart(Blob, ContentType, ContentTransferEncoding, String, List)}, but computes the appropriate
      * content transfer encoding from the {@link OMOutputFormat}.
      * 
-     * @param dataHandler
+     * @param blob
      *            the content of the MIME part to write
      * @param contentID
      *            the content ID of the MIME part 
      * @throws IOException
      *             if an I/O error occurs when writing the part to the underlying stream
      */
-    public void writePart(DataHandler dataHandler, String contentID) throws IOException {
-        writePart(dataHandler, contentID, null);
+    public void writePart(Blob blob, String contentID) throws IOException {
+        writePart(blob, contentID, null);
     }
 
     /**
diff --git a/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerMixin.java b/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerMixin.java
index 49e86387b..3a02114e2 100644
--- a/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerMixin.java
+++ b/mixins/om-mixins/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerMixin.java
@@ -78,6 +78,7 @@ import org.apache.axiom.om.impl.stream.xop.ContentIDGeneratorImpl;
 import org.apache.axiom.om.impl.stream.xop.OptimizationPolicy;
 import org.apache.axiom.om.impl.stream.xop.OptimizationPolicyImpl;
 import org.apache.axiom.om.impl.stream.xop.XOPEncodingFilterHandler;
+import org.apache.axiom.util.activation.DataHandlerUtils;
 import org.apache.axiom.util.io.IOUtils;
 import org.apache.axiom.weaver.annotation.Mixin;
 import org.xml.sax.InputSource;
@@ -387,7 +388,7 @@ public abstract class AxiomContainerMixin implements AxiomContainer {
             for (String contentID : encoder.getContentIDs()) {
                 DataHandler dataHandler = encoder.getDataHandler(contentID);
                 if (cache || !(dataHandler instanceof PartDataHandler)) {
-                    multipartWriter.writePart(dataHandler, contentID);
+                    multipartWriter.writePart(DataHandlerUtils.toBlob(dataHandler), contentID);
                 } else {
                     ContentType contentType;
                     try {