axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rineh...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils SOAPUtils.java
Date Tue, 09 Jul 2002 11:28:25 GMT
rineholt    2002/07/09 04:28:25

  Modified:    java/src/org/apache/axis Part.java SOAPPart.java
               java/src/org/apache/axis/attachments AttachmentPart.java
                        Attachments.java AttachmentsImpl.java
                        MimeUtils.java MultiPartDimeInputStream.java
                        MultiPartInputStream.java
                        MultiPartRelatedInputStream.java
               java/src/org/apache/axis/encoding/ser
                        JAFDataHandlerSerializer.java
               java/src/org/apache/axis/utils SOAPUtils.java
  Log:
  This should remove the automatic prefixing of "cid:" for the Content-Id headers.
  I think to be honest that we transmitted this in the MIME headers on the wire which was
  incorrect and this also fixes that too.  However, I accepted code in the past that
  i'm sure broke the logic for finding attachments by Content-Location :-(.
  Need to revisted that as soon as I get more spare bandwidth.
  
  Revision  Changes    Path
  1.13      +10 -1     xml-axis/java/src/org/apache/axis/Part.java
  
  Index: Part.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Part.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Part.java	2 Jul 2002 18:07:26 -0000	1.12
  +++ Part.java	9 Jul 2002 11:28:24 -0000	1.13
  @@ -108,7 +108,7 @@
       public void setContentLocation(String loc);
   
       /**
  -     * Sets Content-Id of this part. "cid:" prefix will be added if one wan't
  +     * Sets Content-Id of this part. 
        *  already defined.
        * @param newCid new Content-Id
        * @returns void
  @@ -134,5 +134,14 @@
        * Content type.
        */
       public abstract String getContentType();
  +
  +    /**
  +     * Content ID.
  +     *
  +     * @return the contentId reference value that should be used directly
  +     * as an href in a SOAP element to reference this attachment.
  +     * <B>Not part of JAX-RPC, JAX-M, SAAJ, etc. </B>
  +     */
  +    public String getContentIdRef();
   }
   
  
  
  
  1.34      +14 -7     xml-axis/java/src/org/apache/axis/SOAPPart.java
  
  Index: SOAPPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SOAPPart.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- SOAPPart.java	3 Jul 2002 17:50:29 -0000	1.33
  +++ SOAPPart.java	9 Jul 2002 11:28:24 -0000	1.34
  @@ -141,12 +141,10 @@
   
       /**
        * Do not call this directly!  Should only be called by Message.
  -     * As this method's comment once read:
  -     * "Just something to us working..."
        */
       public SOAPPart(Message parent, Object initialContents, boolean isBodyStream) {
  -        addMimeHeader(HTTPConstants.HEADER_CONTENT_ID , SOAPUtils.getNewContentIdValue());
   
  +        addMimeHeader(HTTPConstants.HEADER_CONTENT_ID , SOAPUtils.getNewContentIdValue());
   
           msgObject=parent;
           // originalMessage = initialContents;
  @@ -505,15 +503,13 @@
       }
   
       /**
  -         * Sets Content-Id of this part. "cid:" prefix will be added if one wan't
  +         * Sets Content-Id of this part. 
            *  already defined.
            * @param newCid new Content-Id
            * @returns void
            */
           public void setContentId(String newCid){
  -                if(newCid!=null && !newCid.toLowerCase().startsWith("cid:")){
  -                        newCid="cid:"+newCid;
  -                }
  +                
                   addMimeHeader(HTTPConstants.HEADER_CONTENT_ID,newCid);
           }
   
  @@ -533,6 +529,17 @@
               addMimeHeader(HTTPConstants.HEADER_CONTENT_ID , ret);
           }
           return ret;
  +    }
  +    /**
  +     * Content ID.
  +     *
  +     * @return the contentId reference value that should be used directly
  +     * as an href in a SOAP element to reference this attachment.
  +     * <B>Not part of JAX-RPC, JAX-M, SAAJ, etc. </B>
  +     */
  +    public String getContentIdRef() {
  +      return org.apache.axis.attachments.Attachments.CIDprefix +
  +         getContentId();
       }
   
   
  
  
  
  1.24      +12 -4     xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java
  
  Index: AttachmentPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AttachmentPart.java	5 Jul 2002 12:34:49 -0000	1.23
  +++ AttachmentPart.java	9 Jul 2002 11:28:24 -0000	1.24
  @@ -197,15 +197,13 @@
       }
   
       /**
  -     *     Sets Content-Id of this part. "cid:" prefix will be added if one wan't
  +     *     Sets Content-Id of this part. 
        *      already defined.
        *     @param newCid new Content-Id
        *     @returns void
        */
       public void setContentId(String newCid) {
  -        if (newCid!=null && !newCid.toLowerCase().startsWith("cid:")) {
  -            newCid = "cid:" + newCid;
  -        }
  +        
           setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, newCid);
       }
   
  @@ -499,5 +497,15 @@
           byte[] getBytes() {
               return super.buf;
           }
  +    }
  +    /**
  +     * Content ID.
  +     *
  +     * @return the contentId reference value that should be used directly
  +     * as an href in a SOAP element to reference this attachment.
  +     * <B>Not part of JAX-RPC, JAX-M, SAAJ, etc. </B>
  +     */
  +    public String getContentIdRef() {
  +      return Attachments.CIDprefix + getContentId();
       }
   }
  
  
  
  1.10      +3 -0      xml-axis/java/src/org/apache/axis/attachments/Attachments.java
  
  Index: Attachments.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/Attachments.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Attachments.java	30 Jun 2002 19:59:04 -0000	1.9
  +++ Attachments.java	9 Jul 2002 11:28:24 -0000	1.10
  @@ -247,6 +247,9 @@
       /** The default attatchment type. MIME */
       final int SEND_TYPE_DEFAULT = SEND_TYPE_MIME; 
   
  +    /** The prefix used to assoc. attachments as content-id */
  +    public final String CIDprefix= "cid:";
  +
       /**
        * Set the format for attachments. 
        *
  
  
  
  1.27      +11 -1     xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
  
  Index: AttachmentsImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AttachmentsImpl.java	3 Jul 2002 17:50:25 -0000	1.26
  +++ AttachmentsImpl.java	9 Jul 2002 11:28:24 -0000	1.27
  @@ -359,9 +359,10 @@
               return ret;
           }
   
  +
           String referenceLC = reference.toLowerCase();
   
  -        if (!referenceLC.startsWith("cid:") && (null != contentLocation)) {
  +        if (!referenceLC.startsWith(Attachments.CIDprefix) && (null != contentLocation))
{
               String fqreference = contentLocation;
   
               if (!fqreference.endsWith("/")) {
  @@ -376,7 +377,16 @@
   
               // lets see if we can get it as Content-Location
               ret = (AttachmentPart) attachments.get(fqreference);
  +        
  +                
  +                }
  +
  +                if( null == ret && reference.startsWith(Attachments.CIDprefix)){
//last ditch effort.
  +                ret = (Part) attachments.get( reference.substring(4));
  +            
           }
  +
  +                
   
           return ret;
       }
  
  
  
  1.24      +1 -32     xml-axis/java/src/org/apache/axis/attachments/MimeUtils.java
  
  Index: MimeUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MimeUtils.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- MimeUtils.java	7 Jul 2002 22:15:46 -0000	1.23
  +++ MimeUtils.java	9 Jul 2002 11:28:24 -0000	1.24
  @@ -273,10 +273,6 @@
           try {
               String rootCID = getNewContentIdValue();
   
  -            if (rootCID.startsWith("cid:")) {
  -                rootCID = rootCID.substring(4);
  -            }
  -
               multipart = new javax.mail.internet.MimeMultipart(
                       "related; type=\"text/xml\"; start=\"<" + rootCID + ">\"");
   
  @@ -299,10 +295,6 @@
                                   part);
                   String contentID = part.getContentId();
   
  -                if (contentID.startsWith("cid:")) {
  -                    contentID = contentID.substring(4);
  -                }
  -
                   messageBodyPart = new javax.mail.internet.MimeBodyPart();
   
                   messageBodyPart.setDataHandler(dh);
  @@ -354,29 +346,6 @@
        */
       public static String getNewContentIdValue() {
   
  -        int lcount;
  -
  -        synchronized (org.apache.axis.Message.class) {
  -            lcount = ++count;
  -        }
  -
  -        if (null == thisHost) {
  -            try {
  -                thisHost = java.net.InetAddress.getLocalHost().getHostName();
  -            } catch (java.net.UnknownHostException e) {
  -                log.error(JavaUtils.getMessage("javaNetUnknownHostException00"),
  -                        e);
  -
  -                thisHost = "localhost";
  -            }
  -        }
  -
  -        StringBuffer s = new StringBuffer();
  -
  -        // Unique string is <hashcode>.<currentTime>.apache-soap.<hostname>
  -        s.append("cid:").append(lcount).append(s.hashCode()).append('.').append(
  -                System.currentTimeMillis()).append(".AXIS@").append(thisHost);
  -
  -        return s.toString();
  +         return org.apache.axis.utils.SOAPUtils.getNewContentIdValue();
       }
   }
  
  
  
  1.9       +7 -6      xml-axis/java/src/org/apache/axis/attachments/MultiPartDimeInputStream.java
  
  Index: MultiPartDimeInputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MultiPartDimeInputStream.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MultiPartDimeInputStream.java	3 Jul 2002 17:50:25 -0000	1.8
  +++ MultiPartDimeInputStream.java	9 Jul 2002 11:28:24 -0000	1.9
  @@ -107,7 +107,7 @@
       }
   
       public Part getAttachmentByReference(final String[] id)
  -      throws org.apache.axis.AxisFault {  // if CID should still have CID: prefix.  
  +      throws org.apache.axis.AxisFault { 
           //First see if we have read it in yet.
           Part ret = null; 
   
  @@ -131,8 +131,9 @@
   
       protected void addPart(String contentId, String locationId,
        AttachmentPart  ap) {
  -        if (contentId != null && contentId.trim().length() != 0) parts.put(contentId,
ap);
  -        if (locationId != null && locationId.trim().length() != 0)parts.put(locationId,
ap);
  +     //For DIME streams Content-Location is ignored.
  +        if (contentId != null && contentId.trim().length() != 0)
  +          parts.put(contentId, ap);
           orderedParts.add(ap); 
       }
   
  @@ -149,13 +150,13 @@
       public java.util.Collection getAttachments() 
         throws org.apache.axis.AxisFault {
           readAll();
  -        return orderedParts; 
  +        return new java.util.LinkedList(orderedParts); 
       }
   
       /** 
        * This will read streams in till the one that is needed is found.
  -     * @param The id is the stream being sought. TODO today its only handles CID. all ContentId
streams
  -     *         should be prefixed by "cid:"
  +     * @param The id is the stream being sought. 
  +     *         
        */
   
       protected Part readTillFound(final String[] id) 
  
  
  
  1.5       +1 -1      xml-axis/java/src/org/apache/axis/attachments/MultiPartInputStream.java
  
  Index: MultiPartInputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MultiPartInputStream.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MultiPartInputStream.java	2 Jul 2002 18:07:27 -0000	1.4
  +++ MultiPartInputStream.java	9 Jul 2002 11:28:24 -0000	1.5
  @@ -80,7 +80,7 @@
       }
   
       public abstract Part getAttachmentByReference(final String[] id)
  -     throws org.apache.axis.AxisFault;  // if CID should still have CID: prefix.  
  +     throws org.apache.axis.AxisFault;  
   
       public abstract java.util.Collection getAttachments() 
         throws org.apache.axis.AxisFault;
  
  
  
  1.23      +15 -15    xml-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java
  
  Index: MultiPartRelatedInputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/MultiPartRelatedInputStream.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MultiPartRelatedInputStream.java	3 Jul 2002 17:50:25 -0000	1.22
  +++ MultiPartRelatedInputStream.java	9 Jul 2002 11:28:24 -0000	1.23
  @@ -165,9 +165,9 @@
                               rootPartContentId.length() - 1);
                   }
   
  -                if (!rootPartContentId.startsWith("cid:")) {
  -                    rootPartContentId = "cid:" + rootPartContentId;
  -                }
  +              //  if (!rootPartContentId.startsWith("cid:")) {
  +              //      rootPartContentId = "cid:" + rootPartContentId;
  +              //  }
               }
   
               // if start is null then the first attachment is the rootpart
  @@ -242,11 +242,11 @@
   
                       contentId = contentId.trim();
   
  -                    if (!contentId.startsWith("cid:")) {
  -                        contentId =
  -                                "cid:"
  -                                + contentId;        // make sure its identified as cid
  -                    }
  +                  //  if (!contentId.startsWith("cid:")) {
  +                  //      contentId =
  +                  //              "cid:"
  +                  //              + contentId;        // make sure its identified as cid
  +                  //  }
                   }
   
                   contentLocation =
  @@ -375,7 +375,7 @@
        * @throws org.apache.axis.AxisFault
        */
       public Part getAttachmentByReference(final String[] id)
  -            throws org.apache.axis.AxisFault {    // if CID should still have CID: prefix.
  +            throws org.apache.axis.AxisFault {    
   
           // First see if we have read it in yet.
           Part ret = null;
  @@ -448,9 +448,9 @@
   
       /**
        * This will read streams in till the one that is needed is found.
  -     * @param The id is the stream being sought. TODO today its only handles CID. all ContentId
streams
  -     *         should be prefixed by "cid:"
  -     *
  +     * @param The id is the stream being sought. 
  +     *         
  +	 *
        * @param id
        *
        * @return
  @@ -521,9 +521,9 @@
                                       contentId.substring(0, contentId.length() - 1);
                           }
   
  -                        if (!contentId.startsWith("cid:")) {
  -                            contentId = "cid:" + contentId;
  -                        }
  +                     //   if (!contentId.startsWith("cid:")) {
  +                     //       contentId = "cid:" + contentId;
  +                     //   }
   
                           contentId = contentId.trim();
                       }
  
  
  
  1.17      +1 -2      xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java
  
  Index: JAFDataHandlerSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JAFDataHandlerSerializer.java	3 Jul 2002 17:50:22 -0000	1.16
  +++ JAFDataHandlerSerializer.java	9 Jul 2002 11:28:25 -0000	1.17
  @@ -112,7 +112,6 @@
           //Add the attachment content to the message.
           Attachments attachments= context.getCurrentMessage().getAttachmentsImpl();
           Part attachmentPart= attachments.createAttachmentPart(dh);
  -        String href= attachmentPart.getContentId();
   
           AttributesImpl attrs = new AttributesImpl();
           if (attributes != null && 0 < attributes.getLength())
  @@ -127,7 +126,7 @@
           }
   
           attrs.addAttribute("", Constants.ATTR_HREF, "href",
  -                               "CDATA", href);
  +                               "CDATA", attachmentPart.getContentIdRef() );
   
           context.startElement(name, attrs);
           context.endElement(); //There is no data to so end the element.
  
  
  
  1.6       +1 -1      xml-axis/java/src/org/apache/axis/utils/SOAPUtils.java
  
  Index: SOAPUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/SOAPUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SOAPUtils.java	3 Jul 2002 17:50:35 -0000	1.5
  +++ SOAPUtils.java	9 Jul 2002 11:28:25 -0000	1.6
  @@ -90,7 +90,7 @@
           StringBuffer s = new StringBuffer();
   
           // Unique string is <hashcode>.<currentTime>.apache-soap.<hostname>
  -        s.append("cid:").append( lcount).append(s.hashCode()).append('.').append(System.currentTimeMillis()).append(".AXIS@").append(thisHost);
  +        s.append( lcount).append(s.hashCode()).append('.').append(System.currentTimeMillis()).append(".AXIS@").append(thisHost);
           return s.toString();
       }
   }
  
  
  

Mime
View raw message