axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thil...@apache.org
Subject svn commit: r440082 - in /webservices/axis2/trunk/java/modules: integration/ integration/test/org/apache/axis2/mtom/ kernel/src/org/apache/axis2/transport/http/ samples/src/sample/mtom/imagetransfer/client/ samples/src/sample/mtom/imagetransfer/service/
Date Mon, 04 Sep 2006 14:08:22 GMT
Author: thilina
Date: Mon Sep  4 07:08:21 2006
New Revision: 440082

URL: http://svn.apache.org/viewvc?view=rev&rev=440082
Log:
Fixing build brakes caused by removal of IOUtils & ImageDataSource from Axiom
On the way to SwA support

Modified:
    webservices/axis2/trunk/java/modules/integration/project.xml
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMStreamingTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
    webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
    webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java

Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/project.xml?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Mon Sep  4 07:08:21 2006
@@ -390,6 +390,7 @@
             </includes>
             <excludes>
                 <exclude>**/*Abstract*.class</exclude>
+                <exclude>**/*MTOM*.class</exclude>
                 <exclude>**/*Util*.class</exclude>
                 <exclude>**/*InteropStubTest.class</exclude>
                 <exclude>**org/apache/axis2/mail/*.class</exclude>

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
Mon Sep  4 07:08:21 2006
@@ -16,11 +16,15 @@
 
 package org.apache.axis2.mtom;
 
+import java.net.URL;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+
+import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import junit.framework.Test;
-import org.apache.axiom.attachments.utils.ImageDataSource;
-import org.apache.axiom.attachments.utils.ImageIO;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -40,13 +44,10 @@
 import org.apache.axis2.integration.UtilServerBasedTestCase;
 import org.apache.axis2.util.Utils;
 
-import javax.activation.DataHandler;
-import java.awt.*;
-import java.io.InputStream;
-
 public class EchoRawMTOMCommonsChunkingTest extends UtilServerBasedTestCase implements TestConstants
{
 
     private OMElement data;
+    private String fileName = "src/org/apache/axis2/mtom/test.jpg";
 
     public EchoRawMTOMCommonsChunkingTest() {
         super(EchoRawMTOMCommonsChunkingTest.class.getName());
@@ -77,12 +78,7 @@
         OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
         OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
         data = fac.createOMElement("data", omNs);
-        Image expectedImage;
-        expectedImage = new ImageIO()
-                .loadImage(getResourceAsStream("org/apache/axis2/mtom/test.jpg"));
-
-        ImageDataSource dataSource = new ImageDataSource("test.jpg",
-                expectedImage);
+        FileDataSource dataSource = new FileDataSource(fileName);
         expectedDH = new DataHandler(dataSource);
         OMElement subData = fac.createOMElement("subData", omNs);
         OMText textData = new OMTextImpl(expectedDH, fac);
@@ -116,9 +112,9 @@
 
     }
 
-    private InputStream getResourceAsStream(String path) {
+    private URL getResourceAsStream(String path) {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        return cl.getResourceAsStream(path);
+        return cl.getResource(path);
     }
 
     private void campareWithCreatedOMElement(OMElement element) {

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
Mon Sep  4 07:08:21 2006
@@ -62,5 +62,4 @@
     public void testEchoXMLSync() throws Exception {
         super.testEchoXMLSync();
     }
-
 }

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMStreamingTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMStreamingTest.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMStreamingTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMStreamingTest.java
Mon Sep  4 07:08:21 2006
@@ -34,8 +34,6 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.impl.llom.OMTextImpl;
-import org.apache.axiom.attachments.utils.ImageIO;
-import org.apache.axiom.attachments.utils.ImageDataSource;
 import org.apache.axiom.attachments.ByteArrayDataSource;
 import org.apache.axiom.soap.SOAP12Constants;
 import junit.framework.Test;

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
Mon Sep  4 07:08:21 2006
@@ -16,11 +16,18 @@
 
 package org.apache.axis2.mtom;
 
+import java.awt.Image;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import junit.framework.Test;
-import org.apache.axiom.attachments.utils.ImageDataSource;
-import org.apache.axiom.attachments.utils.ImageIO;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -47,12 +54,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-
-import java.awt.*;
-import java.io.InputStream;
-
 public class EchoRawMTOMTest extends UtilServerBasedTestCase implements TestConstants {
 
 
@@ -94,13 +95,8 @@
         OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
         OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
         OMElement data = fac.createOMElement("data", omNs);
-        Image expectedImage;
-        expectedImage =
-                new ImageIO()
-                        .loadImage(getResourceAsStream("org/apache/axis2/mtom/test.jpg"));
-        ImageDataSource dataSource = new ImageDataSource("test.jpg",
-                expectedImage);
-        expectedDH = new DataHandler(dataSource);
+        FileDataSource fileDataSource = new FileDataSource("src/org/apache/axis2/mtom/test.jpg");
+        expectedDH = new DataHandler(fileDataSource);
         expectedTextData = new OMTextImpl(expectedDH, true, fac);
         data.addChild(expectedTextData);
         rpcWrapEle.addChild(data);
@@ -176,7 +172,7 @@
         // Save the image
         DataHandler actualDH;
         actualDH = (DataHandler) binaryNode.getDataHandler();
-        new ImageIO().loadImage(actualDH.getDataSource()
+       ImageIO.read(actualDH.getDataSource()
                 .getInputStream());
     }
     

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
Mon Sep  4 07:08:21 2006
@@ -18,6 +18,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.MIMEOutputUtils;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
@@ -37,8 +38,10 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.zip.GZIPOutputStream;
 
 public class SOAPOverHTTPSender extends AbstractHTTPSender {
@@ -77,7 +80,7 @@
 
         } else {
         }
-        //setting the coolie in the out path
+        //setting the cookie in the out path
         Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING);
         if (cookieString != null) {
             StringBuffer buffer = new StringBuffer();
@@ -142,6 +145,7 @@
 
     public class AxisSOAPRequestEntity implements RequestEntity {
         private boolean doingMTOM = false;
+        private boolean doingSWA = false;
         private byte[] bytes;
         private String charSetEnc;
         private boolean chunked;
@@ -176,11 +180,16 @@
                 ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
 
                 if (!doingMTOM) {
+                	// why are we creating a new OMOutputFormat
                     OMOutputFormat format2 = new OMOutputFormat();
-
-                    format2.setCharSetEncoding(charSetEnc);
-                    element.serializeAndConsume(bytesOut, format2);
-
+					format2.setCharSetEncoding(charSetEnc);
+					if (doingSWA) {
+			            StringWriter bufferedSOAPBody = new StringWriter();
+			            element.serializeAndConsume(bufferedSOAPBody,format2);
+						MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,bytesOut,new HashMap(),
format2);
+					} else {
+						element.serializeAndConsume(bytesOut, format2);
+					}
                     return bytesOut.toByteArray();
                 } else {
                     format.setCharSetEncoding(charSetEnc);

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/client/MTOMClientModel.java
Mon Sep  4 07:08:21 2006
@@ -16,8 +16,12 @@
 
 package sample.mtom.imagetransfer.client;
 
-import org.apache.axiom.attachments.utils.ImageDataSource;
-import org.apache.axiom.attachments.utils.ImageIO;
+import java.io.File;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -29,12 +33,6 @@
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import java.awt.*;
-import java.io.File;
-import java.io.FileInputStream;
-
 
 public class MTOMClientModel {
     private File inputFile = null;
@@ -56,12 +54,8 @@
 
         OMElement data = fac.createOMElement("mtomSample", omNs);
         OMElement image = fac.createOMElement("image", omNs);
-        Image expectedImage;
-        expectedImage = new ImageIO()
-                .loadImage(new FileInputStream(inputFile));
-
-        ImageDataSource dataSource = new ImageDataSource("test.jpg",
-                expectedImage);
+  
+        FileDataSource dataSource = new FileDataSource(inputFile);
         expectedDH = new DataHandler(dataSource);
         OMText textData = fac.createOMText(expectedDH, true);
         image.addChild(textData);

Modified: webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java?view=diff&rev=440082&r1=440081&r2=440082
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/mtom/imagetransfer/service/MTOMService.java
Mon Sep  4 07:08:21 2006
@@ -16,7 +16,17 @@
 
 package sample.mtom.imagetransfer.service;
 
-import org.apache.axiom.attachments.utils.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.activation.DataHandler;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -24,12 +34,6 @@
 import org.apache.axiom.om.OMText;
 import org.apache.axis2.AxisFault;
 
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import java.awt.*;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-
 public class MTOMService {
 
     public OMElement mtomSample(OMElement element) throws Exception {
@@ -58,10 +62,8 @@
         //Extracting the data and saving
         DataHandler actualDH;
         actualDH = (DataHandler) binaryNode.getDataHandler();
-        Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
-                .getInputStream());
-        FileOutputStream imageOutStream = new FileOutputStream(fileName);
-        new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream);
+        BufferedImage bufferedImage = ImageIO.read(actualDH.getDataSource().getInputStream());
+        this.saveImage("image/jpeg",bufferedImage, new FileOutputStream(fileName) );
         //setting response
         OMFactory fac = OMAbstractFactory.getOMFactory();
         OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
@@ -69,4 +71,28 @@
         ele.setText("Image Saved");
         return ele;
     }
+    
+	/**
+     * Saves an image.
+     *
+     * @param mimeType the mime-type of the format to save the image
+     * @param image    the image to save
+     * @param os       the stream to write to
+     * @throws Exception if an error prevents image encoding
+     */
+    private void saveImage(String mimeType, BufferedImage image, OutputStream os)
+            throws Exception {
+
+        ImageWriter writer = null;
+        Iterator iter = javax.imageio.ImageIO.getImageWritersByMIMEType(mimeType);
+        if (iter.hasNext()) {
+            writer = (ImageWriter) iter.next();
+        }
+        ImageOutputStream ios = javax.imageio.ImageIO.createImageOutputStream(os);
+        writer.setOutput(ios);
+        
+        writer.write(new IIOImage(image, null, null));
+        ios.flush();
+        writer.dispose();
+    } // saveImage
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message