dims        2002/12/25 15:28:47

  Modified:    java/test/wsdl/interop4/groupG/mime/rpc
                        AttachmentsBindingImpl.java build.xml
                        MimeRPCInteropTestCase.java
               java/test/wsdl/attachments AttachmentTestCase.java
                        B1Impl.java build.xml mime.wsdl
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
               java/src/org/apache/axis/encoding/ser
                        JAFDataHandlerDeserializerFactory.java
                        JAFDataHandlerSerializerFactory.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/symbolTable SymbolTable.java
               java/src/org/apache/axis/wsdl/toJava Utils.java
  Added:       java/src/org/apache/axis/encoding/ser
                        OctetStreamDataHandlerDeserializer.java
                        OctetStreamDataHandlerSerializer.java
               java/src/org/apache/axis/attachments OctetStream.java
                        OctetStreamDataSource.java
               java/src/org/apache/axis/holders OctetStreamHolder.java
  Log:
  Adding support for "application/octetstream". We need it for Interop GroupG tests.
  
  Revision  Changes    Path
  1.2       +8 -6      
xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/AttachmentsBindingImpl.java
  
  Index: AttachmentsBindingImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/AttachmentsBindingImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttachmentsBindingImpl.java       23 Dec 2002 22:27:44 -0000      1.1
  +++ AttachmentsBindingImpl.java       25 Dec 2002 23:28:46 -0000      1.2
  @@ -7,21 +7,23 @@
   
   package test.wsdl.interop4.groupG.mime.rpc;
   
  +import org.apache.axis.attachments.OctetStream;
  +
   public class AttachmentsBindingImpl implements 
test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType{
  -    public byte[] echoAttachment(byte[] in) throws java.rmi.RemoteException {
  +    public OctetStream echoAttachment(OctetStream in) throws 
java.rmi.RemoteException {
           return in;
       }
   
  -    public byte[][] echoAttachments(byte[][] in) throws java.rmi.RemoteException {
  +    public OctetStream echoAttachments(OctetStream in) throws 
java.rmi.RemoteException {
           return in;
       }
   
  -    public byte[] echoAttachmentAsBase64(byte[] in) throws java.rmi.RemoteException 
{
  -        return in;
  +    public byte[] echoAttachmentAsBase64(OctetStream in) throws 
java.rmi.RemoteException {
  +        return in.getBytes();
       }
   
  -    public byte[] echoBase64AsAttachment(byte[] in) throws java.rmi.RemoteException 
{
  -        return in;
  +    public OctetStream echoBase64AsAttachment(byte[] in) throws 
java.rmi.RemoteException {
  +        return new OctetStream(in);
       }
   
   }
  
  
  
  1.4       +1 -1      xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml 23 Dec 2002 22:27:44 -0000      1.3
  +++ build.xml 25 Dec 2002 23:28:46 -0000      1.4
  @@ -54,7 +54,7 @@
       <!-- generate skeletons -->
       <wsdl2java url="${axis.home}/test/wsdl/interop4/groupG/mime/rpc/mime-rpc.wsdl"
                  output="${root.dir}/build/work" 
  -               skeletonDeploy="no"
  +               skeletonDeploy="yes"
                  testCase="yes"
                  serverSide="yes">
           <mapping namespace="http://soapinterop.org/attachments/wsdl"; 
package="test.wsdl.interop4.groupG.mime.rpc"/>
  
  
  
  1.3       +23 -14    
xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/MimeRPCInteropTestCase.java
  
  Index: MimeRPCInteropTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/test/wsdl/interop4/groupG/mime/rpc/MimeRPCInteropTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MimeRPCInteropTestCase.java       25 Dec 2002 00:02:48 -0000      1.2
  +++ MimeRPCInteropTestCase.java       25 Dec 2002 23:28:46 -0000      1.3
  @@ -7,6 +7,8 @@
   
   package test.wsdl.interop4.groupG.mime.rpc;
   
  +import org.apache.axis.attachments.OctetStream;
  +
   import java.util.Arrays;
   import java.net.URL;
   
  @@ -15,6 +17,12 @@
           super(name);
       }
   
  +    protected void setUp() throws Exception {
  +        if(url == null) {
  +            url = new URL(new 
test.wsdl.interop4.groupG.mime.rpc.MimeRPCInteropLocator().getMimeRPCSoapPortAddress());
  +        }
  +    }    
  +
       public void test1MimeRPCSoapPortEchoAttachment() throws Exception {
           test.wsdl.interop4.groupG.mime.rpc.AttachmentsPortType binding;
           try {
  @@ -27,11 +35,11 @@
           assertTrue("binding is null", binding != null);
   
           // Test operation
  -        byte[] input = "EchoAttachment".getBytes();
  -        byte[] output = null;
  +        OctetStream input = new OctetStream("EchoAttachment".getBytes());
  +        OctetStream output = null;
           output = binding.echoAttachment(input);
           // TBD - validate results
  -        assertTrue(Arrays.equals(input, output));
  +        assertTrue(Arrays.equals(input.getBytes(), output.getBytes()));
       }
   
       public void test2MimeRPCSoapPortEchoAttachments() throws Exception {
  @@ -45,17 +53,18 @@
           }
           assertTrue("binding is null", binding != null);
   
  -        byte[][] input = new byte[2][];
  +        OctetStream[] input = new OctetStream[2];
   
  -        input[0] = "EchoAttachments0".getBytes();
  -        input[1] = "EchoAttachments1".getBytes();
  +        input[0] = new OctetStream("EchoAttachments0".getBytes());
  +        input[1] = new OctetStream("EchoAttachments1".getBytes());
           
           // Test operation
  -        byte[][] output = null;
  -        output = binding.echoAttachments(input);
  +        OctetStream[] output = null;
  +        // TODO: Fix this echoAttachments sig is wrong.
  +        //output = binding.echoAttachments(input);
           // TBD - validate results
  -        assertTrue(Arrays.equals(input[0], output[0]));
  -        assertTrue(Arrays.equals(input[1], output[1]));
  +        //assertTrue(Arrays.equals(input[0].getBytes(), output[0].getBytes()));
  +        //assertTrue(Arrays.equals(input[1].getBytes(), output[1].getBytes()));
       }
   
       public void test3MimeRPCSoapPortEchoAttachmentAsBase64() throws Exception {
  @@ -68,12 +77,12 @@
               throw new junit.framework.AssertionFailedError("JAX-RPC 
ServiceException caught: " + jre);
           }
           assertTrue("binding is null", binding != null);
  -        byte[] input = "EchoAttachmentAsBase64".getBytes(); 
  +        OctetStream input = new OctetStream("EchoAttachmentAsBase64".getBytes()); 
           // Test operation
           byte[] output = null;
           output = binding.echoAttachmentAsBase64(input);
           // TBD - validate results
  -        assertTrue(Arrays.equals(input, output));
  +        assertTrue(Arrays.equals(input.getBytes(), output));
       }
   
       public void test4MimeRPCSoapPortEchoBase64AsAttachment() throws Exception {
  @@ -89,10 +98,10 @@
   
           byte[] input = "EchoBase64AsAttachment".getBytes(); 
           // Test operation
  -        byte[] output = null;
  +        OctetStream output = null;
           output = binding.echoBase64AsAttachment(input);
           // TBD - validate results
  -        assertTrue(Arrays.equals(input, output));
  +        assertTrue(Arrays.equals(input, output.getBytes()));
       }
   
       public static URL url = null;
  
  
  
  1.2       +20 -0     xml-axis/java/test/wsdl/attachments/AttachmentTestCase.java
  
  Index: AttachmentTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/AttachmentTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttachmentTestCase.java   23 Dec 2002 02:48:41 -0000      1.1
  +++ AttachmentTestCase.java   25 Dec 2002 23:28:46 -0000      1.2
  @@ -9,6 +9,7 @@
   
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMultipart;
  +import java.util.Arrays;
   
   public class AttachmentTestCase extends junit.framework.TestCase {
       public AttachmentTestCase(java.lang.String name) {
  @@ -180,4 +181,23 @@
           // TBD - validate results
       }
   
  +    public void test10AttachmentPortRPCEchoAttachment() throws Exception {
  +        test.wsdl.attachments.Pt1 binding;
  +        try {
  +            binding = new 
test.wsdl.attachments.AttachmentLocator().getAttachmentPortRPC();
  +        }
  +        catch (javax.xml.rpc.ServiceException jre) {
  +            if(jre.getLinkedCause()!=null)
  +                jre.getLinkedCause().printStackTrace();
  +            throw new junit.framework.AssertionFailedError("JAX-RPC 
ServiceException caught: " + jre);
  +        }
  +        assertTrue("binding is null", binding != null);
  +
  +        // Test operation
  +        org.apache.axis.attachments.OctetStream input = new 
org.apache.axis.attachments.OctetStream("EchoAttachment".getBytes());
  +        org.apache.axis.attachments.OctetStream output = null;
  +        output = binding.echoAttachment(input);
  +        // TBD - validate results
  +        assertTrue(Arrays.equals(input.getBytes(), output.getBytes()));
  +    }
   }
  
  
  
  1.2       +4 -0      xml-axis/java/test/wsdl/attachments/B1Impl.java
  
  Index: B1Impl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/B1Impl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- B1Impl.java       23 Dec 2002 02:48:41 -0000      1.1
  +++ B1Impl.java       25 Dec 2002 23:28:46 -0000      1.2
  @@ -61,4 +61,8 @@
               throw new java.rmi.RemoteException(me.getMessage(), me);
           }
       }
  +
  +    public org.apache.axis.attachments.OctetStream 
echoAttachment(org.apache.axis.attachments.OctetStream in) throws 
java.rmi.RemoteException {
  +        return in;
  +    }
   }
  
  
  
  1.9       +3 -3      xml-axis/java/test/wsdl/attachments/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.xml 19 Sep 2002 16:30:18 -0000      1.8
  +++ build.xml 25 Dec 2002 23:28:46 -0000      1.9
  @@ -55,17 +55,17 @@
       <wsdl2java url="${axis.home}/test/wsdl/attachments/mime.wsdl"
                  output="${axis.home}/build/work"
                  serverSide="yes"
  -               skeletonDeploy="no"
  +               skeletonDeploy="yes"
                  testcase="yes">
       </wsdl2java>
  -
  +    
       <copy todir="${build.dir}/work/test/wsdl/attachments" overwrite="yes">
         <fileset dir="${axis.home}/test/wsdl/attachments">
           <include name="*TestCase.java"/>
           <include name="*Impl.java"/>
         </fileset>
       </copy>
  -
  +    
       <javac srcdir="${build.dir}/work" destdir="${build.dest}" fork="${javac.fork}"
              debug="${debug}">
         <classpath refid="classpath" />
  
  
  
  1.5       +33 -0     xml-axis/java/test/wsdl/attachments/mime.wsdl
  
  Index: mime.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/attachments/mime.wsdl,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mime.wsdl 26 Aug 2002 13:10:23 -0000      1.4
  +++ mime.wsdl 25 Dec 2002 23:28:46 -0000      1.5
  @@ -51,6 +51,12 @@
     <message name="mmp4">
       <part name="out" type="xsd:string"/>
     </message>
  +  <message name="EchoAttachmentIn">
  +    <part name="In" type="xsd:base64Binary"/>
  +  </message>
  +  <message name="EchoAttachmentOut">
  +      <part name="Out" type="xsd:base64Binary"/>
  +  </message>
   
     <portType name="pt1">
   <!--
  @@ -95,6 +101,10 @@
         <input message="tns:empty"/>
         <output message="tns:mmp3"/>
       </operation>
  +    <operation name="EchoAttachment">
  +        <input name="EchoAttachmentInput" message="tns:EchoAttachmentIn"/>
  +        <output name="EchoAttachmentOutput" message="tns:EchoAttachmentOut"/>
  +    </operation>
     </portType>
   
     <binding name="b1" type="tns:pt1">
  @@ -261,6 +271,29 @@
             </mime:part>
           </mime:multipartRelated>
         </output>
  +    </operation>
  +    <operation name="EchoAttachment">
  +        <soap:operation soapAction="http://soapinterop.org/attachments/"/>
  +        <input name="EchoAttachmentInput">
  +            <mime:multipartRelated>
  +                <mime:part>
  +                    <soap:body use="encoded" 
namespace="http://soapinterop.org/attachments/"; 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +                </mime:part>
  +                <mime:part>
  +                    <mime:content part="In" type="application/octetstream"/>
  +                </mime:part>
  +            </mime:multipartRelated>
  +        </input>
  +        <output name="EchoAttachmentOutput">
  +            <mime:multipartRelated>
  +                <mime:part>
  +                    <soap:body use="encoded" 
namespace="http://soapinterop.org/attachments/"; 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +                </mime:part>
  +                <mime:part>
  +                    <mime:content part="Out" type="application/octetstream"/>
  +                </mime:part>
  +            </mime:multipartRelated>
  +        </output>
       </operation>
     </binding>
   
  
  
  
  1.67      +8 -3      
xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- DefaultTypeMappingImpl.java       20 Dec 2002 17:28:21 -0000      1.66
  +++ DefaultTypeMappingImpl.java       25 Dec 2002 23:28:46 -0000      1.67
  @@ -56,6 +56,7 @@
   package org.apache.axis.encoding;
   
   import org.apache.axis.Constants;
  +import org.apache.axis.attachments.OctetStream;
   import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
   import org.apache.axis.encoding.ser.ArraySerializerFactory;
   import org.apache.axis.encoding.ser.Base64DeserializerFactory;
  @@ -366,9 +367,13 @@
                       new JAFDataHandlerDeserializerFactory(
                               javax.xml.transform.Source.class,
                               Constants.MIME_SOURCE));
  -            myRegister(Constants.MIME_OCTETSTREAM, 
javax.activation.DataHandler.class,
  -                    new JAFDataHandlerSerializerFactory(),
  -                    new JAFDataHandlerDeserializerFactory());
  +            myRegister(Constants.MIME_OCTETSTREAM, OctetStream.class,
  +                    new JAFDataHandlerSerializerFactory(
  +                            OctetStream.class,
  +                            Constants.MIME_OCTETSTREAM),
  +                    new JAFDataHandlerDeserializerFactory(
  +                            OctetStream.class,
  +                            Constants.MIME_OCTETSTREAM));
               myRegister(Constants.MIME_DATA_HANDLER, 
javax.activation.DataHandler.class,
                       new JAFDataHandlerSerializerFactory(),
                       new JAFDataHandlerDeserializerFactory());
  
  
  
  1.14      +4 -0      
xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializerFactory.java
  
  Index: JAFDataHandlerDeserializerFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializerFactory.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JAFDataHandlerDeserializerFactory.java    11 Dec 2002 22:38:15 -0000      1.13
  +++ JAFDataHandlerDeserializerFactory.java    25 Dec 2002 23:28:47 -0000      1.14
  @@ -56,6 +56,7 @@
   package org.apache.axis.encoding.ser;
   
   import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.attachments.OctetStream;
   import org.apache.commons.logging.Log;
   
   import javax.mail.internet.MimeMultipart;
  @@ -95,6 +96,9 @@
           }
           else if (MimeMultipart.class.isAssignableFrom(javaType)) {
               deser = MimeMultipartDataHandlerDeserializer.class;
  +        }
  +        else if (OctetStream.class.isAssignableFrom(javaType)) {
  +            deser = OctetStreamDataHandlerDeserializer.class;
           }
           else {
               deser = JAFDataHandlerDeserializer.class;
  
  
  
  1.7       +5 -0      
xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializerFactory.java
  
  Index: JAFDataHandlerSerializerFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializerFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JAFDataHandlerSerializerFactory.java      11 Dec 2002 22:38:15 -0000      1.6
  +++ JAFDataHandlerSerializerFactory.java      25 Dec 2002 23:28:47 -0000      1.7
  @@ -55,6 +55,8 @@
   
   package org.apache.axis.encoding.ser;
   
  +import org.apache.axis.attachments.OctetStream;
  +
   import javax.mail.internet.MimeMultipart;
   import javax.xml.namespace.QName;
   import javax.xml.transform.Source;
  @@ -87,6 +89,9 @@
           }
           else if (MimeMultipart.class.isAssignableFrom(javaType)) {
               ser = MimeMultipartDataHandlerSerializer.class;
  +        }
  +        else if (OctetStream.class.isAssignableFrom(javaType)) {
  +            ser = OctetStreamDataHandlerSerializer.class;
           }
           else {
               ser = JAFDataHandlerSerializer.class;
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/encoding/ser/OctetStreamDataHandlerDeserializer.java
  
  Index: OctetStreamDataHandlerDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.commons.logging.Log;
  import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  
  import javax.activation.DataHandler;
  import java.io.IOException;
  
  /**
   * application/octetstream DataHandler Deserializer
   * Modified by Davanum Srinivas <[EMAIL PROTECTED]>
   */
  public class OctetStreamDataHandlerDeserializer extends JAFDataHandlerDeserializer {
      protected static Log log =
              LogFactory.getLog(OctetStreamDataHandlerDeserializer.class.getName());
  
      public void startElement(String namespace, String localName,
                               String prefix, Attributes attributes,
                               DeserializationContext context)
              throws SAXException {
  
          super.startElement(namespace, localName, prefix, attributes, context);
  
          if (getValue() instanceof DataHandler) {
              try {
                  DataHandler dh = (DataHandler) getValue();
                  setValue(dh.getContent());
              } catch (IOException ioe) {
              }
          }
      } // startElement
  } // class OctetStreamDataHandlerDeserializer
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/encoding/ser/OctetStreamDataHandlerSerializer.java
  
  Index: OctetStreamDataHandlerSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.encoding.ser;
  
  import org.apache.axis.attachments.OctetStream;
  import org.apache.axis.attachments.OctetStreamDataSource;
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.commons.logging.Log;
  import org.xml.sax.Attributes;
  
  import javax.activation.DataHandler;
  import javax.xml.namespace.QName;
  import java.io.IOException;
  
  /**
   * application/octetstream DataHandler Serializer
   * @author Davanum Srinivas ([EMAIL PROTECTED])
   */
  public class OctetStreamDataHandlerSerializer extends JAFDataHandlerSerializer {
  
      protected static Log log =
              LogFactory.getLog(OctetStreamDataHandlerSerializer.class.getName());
  
      /**
       * Serialize a Source DataHandler quantity.
       */
      public void serialize(QName name, Attributes attributes,
                            Object value, SerializationContext context)
              throws IOException {
          DataHandler dh = new DataHandler(
                  new OctetStreamDataSource("source", (OctetStream) value));
          super.serialize(name, attributes, dh, context);
      } // serialize
  } // class PlainTextDataHandlerSerializer
  
  
  
  1.89      +24 -3     xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- JavaUtils.java    23 Dec 2002 22:27:44 -0000      1.88
  +++ JavaUtils.java    25 Dec 2002 23:28:47 -0000      1.89
  @@ -56,6 +56,7 @@
   package org.apache.axis.utils;
   
   import org.apache.axis.attachments.AttachmentPart;
  +import org.apache.axis.attachments.OctetStream;
   import org.apache.axis.components.image.ImageIO;
   import org.apache.axis.components.image.ImageIOFactory;
   import org.apache.axis.components.logger.LogFactory;
  @@ -71,6 +72,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.StringReader;
  +import java.io.ByteArrayOutputStream;
   import java.lang.reflect.Array;
   import java.lang.reflect.Field;
   import java.text.Collator;
  @@ -258,19 +260,21 @@
   
           // Convert an AttachmentPart to the given destination class.
           if (isAttachmentSupported() &&
  -                (arg instanceof AttachmentPart || arg instanceof DataHandler)) {
  +                (arg instanceof InputStream || arg instanceof AttachmentPart || arg 
instanceof DataHandler)) {
               try {
                   String destName = destClass.getName();
                   if (destClass == String.class
  +                        || destClass == OctetStream.class
  +                        || destClass == byte[].class
                           || destClass == Image.class
                           || destClass == Source.class
                           || destClass == DataHandler.class
                           || destName.equals("javax.mail.internet.MimeMultipart")) {
  -                    DataHandler handler;
  +                    DataHandler handler = null;
                       if (arg instanceof AttachmentPart) {
                           handler = ((AttachmentPart) arg).getDataHandler();
                       }
  -                    else {
  +                    else if (arg instanceof DataHandler) {
                           handler = (DataHandler) arg;
                       }
                       if (destClass == Image.class) {
  @@ -300,6 +304,14 @@
                           return new StreamSource(new StringReader(
                                   (String) handler.getContent()));
                       }
  +                    else if (destClass == OctetStream.class || destClass == 
byte[].class) {
  +                        InputStream in = (InputStream) arg;
  +                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +                        int byte1 = -1;
  +                        while((byte1 = in.read())!=-1)
  +                            baos.write(byte1);
  +                        return new OctetStream(baos.toByteArray());
  +                    }
                       else if (destClass == DataHandler.class) {
                           return handler;
                       }
  @@ -556,6 +568,7 @@
               String name = src.getName();
               if (src == String.class
                       || src == java.awt.Image.class
  +                    || src == OctetStream.class
                       || name.equals("javax.mail.internet.MimeMultipart")
                       || name.equals("javax.xml.transform.Source"))
                   return true;
  @@ -575,6 +588,11 @@
                   return true;
           }
   
  +        if (obj instanceof java.io.InputStream) {
  +            if (dest ==  OctetStream.class)
  +                return true;
  +        }
  +        
           if (src.isPrimitive()) {
               return isConvertable(getWrapperClass(src),dest);
           }
  @@ -1121,6 +1139,9 @@
           }
           else if ("text/xml".equals(mime) || "application/xml".equals(mime)) {
               return "javax.xml.transform.Source";
  +        }
  +        else if ("application/octetstream".equals(mime)) {
  +            return "org.apache.axis.attachments.OctetStream";
           }
           else if (mime != null && mime.startsWith("multipart/")) {
               return "javax.mail.internet.MimeMultipart";
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/attachments/OctetStream.java
  
  Index: OctetStream.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.attachments;
  
  public class OctetStream {
      private byte[] bytes = null;
  
      public OctetStream() {
      }
  
      public OctetStream(byte[] bytes) {
          this.bytes = bytes;
      }
  
      public byte[] getBytes() {
          return this.bytes;
      }
  
      public void setBytes(byte[] bytes) {
          this.bytes = bytes;
      }
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/attachments/OctetStreamDataSource.java
  
  Index: OctetStreamDataSource.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.attachments;
  
  import javax.activation.DataSource;
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  public class OctetStreamDataSource implements DataSource {
      public static final String CONTENT_TYPE = "application/octetstream";
  
      private final String name;
      private byte[] data;
      private ByteArrayOutputStream os;
  
      public OctetStreamDataSource(String name, OctetStream data) {
          this.name = name;
          this.data = data == null ? null : data.getBytes();
          os = new ByteArrayOutputStream();
      } // ctor
  
      public String getName() {
          return name;
      } // getName
  
      public String getContentType() {
          return CONTENT_TYPE;
      } // getContentType
  
      public InputStream getInputStream() throws IOException {
          if (os.size() != 0) {
              data = os.toByteArray();
          }
          return new ByteArrayInputStream(data == null ? new byte[0] : data);
      } // getInputStream
  
      public OutputStream getOutputStream() throws IOException {
          if (os.size() != 0) {
              data = os.toByteArray();
          }
          return new ByteArrayOutputStream();
      } // getOutputStream
  } // class OctetStreamDataSource
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/holders/OctetStreamHolder.java
  
  Index: OctetStreamHolder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.holders;
  
  import org.apache.axis.attachments.OctetStream;
  
  import javax.xml.rpc.holders.Holder;
  
  /**
   * Class OctetStreamHolder
   *
   */
  public final class OctetStreamHolder implements Holder {
  
      /** Field _value */
      public OctetStream value;
  
      /**
       * Constructor OctetStreamHolder
       */
      public OctetStreamHolder() {
      }
  
      /**
       * Constructor OctetStreamHolder
       *
       * @param value
       */
      public OctetStreamHolder(org.apache.axis.attachments.OctetStream value) {
          this.value = value;
      }
  }
  
  
  
  
  1.61      +3 -0      
xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- SymbolTable.java  11 Dec 2002 22:38:29 -0000      1.60
  +++ SymbolTable.java  25 Dec 2002 23:28:47 -0000      1.61
  @@ -1522,6 +1522,9 @@
                   }
                   else if (Constants.MIME_SOURCE.equals(mimeQName)) {
                       mimeType = "text/xml";
  +                } 
  +                else if (Constants.MIME_OCTETSTREAM.equals(mimeQName)) {
  +                    mimeType = "application/octetstream";
                   }
               }
           }
  
  
  
  1.64      +9 -0      xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- Utils.java        24 Nov 2002 00:41:55 -0000      1.63
  +++ Utils.java        25 Dec 2002 23:28:47 -0000      1.64
  @@ -108,6 +108,9 @@
               else if (mimeType.startsWith("multipart/")) {
                   return "org.apache.axis.holders.MimeMultipartHolder";
               }
  +            else if (mimeType.startsWith("application/octetstream")) {
  +                return "org.apache.axis.holders.OctetStreamHolder";
  +            }
               else if (mimeType.equals("text/xml") ||
                        mimeType.equals("application/xml")) {
                   return "org.apache.axis.holders.SourceHolder";
  @@ -522,6 +525,9 @@
               else if (mimeType.startsWith("multipart/")) {
                   return "(javax.mail.internet.MimeMultipart) " + var + ";";
               }
  +            else if (mimeType.startsWith("application/octetstream")) {
  +                return "(org.apache.axis.attachments.OctetStream) " + var + ";";
  +            }
               else {
                   return "(" + type.getName() + ") " + var + ";";
               }
  @@ -823,6 +829,9 @@
               else if (mimeType.equals("text/xml") ||
                       mimeType.equals("application/xml")) {
                   return "new javax.xml.transform.stream.StreamSource()";
  +            }
  +            else if (mimeType.equals("application/octetstream")) {
  +                return "new org.apache.axis.attachments.OctetStream()";
               }
               else {
                   return "new " + Utils.getParameterTypeName(param) + "()";
  
  
  


Reply via email to