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/attachments Attachments.java AttachmentsImpl.java MultiPartRelatedInputStream.java
Date Mon, 26 Nov 2001 19:09:31 GMT
rineholt    01/11/26 11:09:31

  Modified:    java/src/org/apache/axis Part.java
               java/src/org/apache/axis/attachments Attachments.java
                        AttachmentsImpl.java
                        MultiPartRelatedInputStream.java
  Log:
  preserve all header information.
  allow access to attachments as a collection.
  Fix bug with matching header.
  Preserve order of attachments.
  
  Revision  Changes    Path
  1.3       +3 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Part.java	2001/11/25 19:05:05	1.2
  +++ Part.java	2001/11/26 19:09:31	1.3
  @@ -179,7 +179,9 @@
           if(null != match && 0 != match.length ){
               for(int i= match.length-1 ; i > -1 ; --i){
                       if(match[i] != null){
  -                    retList.add( headers.get(match[i].toLowerCase())); 
  +                      String key= match[i].toLowerCase();
  +                      if(headers.containsKey(key))
  +                         retList.add(match[i]); 
                   }
               }
           }
  
  
  
  1.5       +7 -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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Attachments.java	2001/11/25 19:05:05	1.4
  +++ Attachments.java	2001/11/26 19:09:31	1.5
  @@ -77,6 +77,13 @@
        * @return The part associated with the attachment.
        */ 
       public Part getAttachmentByReference(String reference) throws org.apache.axis.AxisFault;
  +
  +    /**
  +     * This method will return all attachments as a collection. 
  +     * 
  +     * @return A collection of attachments. 
  +     */ 
  +    public java.util.Collection getAttachments() throws org.apache.axis.AxisFault;
       
       /**
        * Create a new attachment Part in this Message.
  
  
  
  1.7       +16 -0     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AttachmentsImpl.java	2001/11/26 03:34:53	1.6
  +++ AttachmentsImpl.java	2001/11/26 19:09:31	1.7
  @@ -194,6 +194,22 @@
           }
           return  ret;
       }
  +    
  +    /**
  +     * This method will return all attachments as a collection. 
  +     * 
  +     * @return A collection of attachments. 
  +     */ 
  +    public java.util.Collection getAttachments() throws org.apache.axis.AxisFault{
  +        java.util.Collection ret= new java.util.LinkedList();
  +
  +        if(null != mpartStream){
  +            java.util.Collection mc= mpartStream.getAttachments();
  +            ret= new java.util.LinkedList( mc); // make a copy.
  +        }
  +
  +       return ret;
  +    }
   
       /**
        * From the complex stream return the root part. 
  
  
  
  1.4       +68 -10    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MultiPartRelatedInputStream.java	2001/11/26 03:34:53	1.3
  +++ MultiPartRelatedInputStream.java	2001/11/26 19:09:31	1.4
  @@ -70,6 +70,7 @@
   public class MultiPartRelatedInputStream extends java.io.FilterInputStream {
       public static final String MIME_MULTIPART_RELATED = "multipart/related";
       protected java.util.HashMap parts =  new java.util.HashMap();
  +    protected java.util.LinkedList orderedParts =  new java.util.LinkedList();
       protected int rootPartLength = 0;
       protected boolean closed = false; //If true the stream has been closed.
       protected boolean eos = false;  //This is set once the SOAP packet has reached the
end of stream.
  @@ -162,14 +163,36 @@
                   contentType = headers.getHeader(HTTPConstants.HEADER_CONTENT_TYPE, null);
                   if (contentType != null) contentType = contentType.trim();
   
  -                contentTransferEncoding = headers.getHeader("Content-Transfer-Encoding",
null);
  +                contentTransferEncoding = headers.getHeader(HTTPConstants.HEADER_CONTENT_TRANSFER_ENCODING,
null);
                   if (contentTransferEncoding != null ) contentTransferEncoding = contentTransferEncoding.trim();
                   //TODO still need to add support for bas64 and quoted printable.
   
                   if (rootPartContentId != null && !rootPartContentId.equals( contentId))
{ //This is a part that has come in prior to the root part. Need to buffer it up.
                       javax.activation.DataHandler dh = new javax.activation.DataHandler(new
org.apache.axis.attachments.ManagedMemoryDataSource(boundaryDelimitedStream, 16 * 1024, contentType,
true));
   
  -                    addPart(contentId, contentLocation, dh);
  +                    AttachmentPart ap= new AttachmentPart(dh);
  +                    if(contentId != null) 
  +                        ap.addMimeHeader(HTTPConstants.HEADER_CONTENT_ID, contentId); 
  +
  +                    if (contentLocation != null)
  +                        ap.addMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION, contentLocation);

  +                    
  +
  +                    for( java.util.Enumeration en= headers.getNonMatchingHeaders(
  +                            new String[]{HTTPConstants.HEADER_CONTENT_ID,
  +                             HTTPConstants.HEADER_CONTENT_LOCATION,
  +                             HTTPConstants.HEADER_CONTENT_TYPE }); en.hasMoreElements();
){
  +                             javax.mail.Header header= (javax.mail.Header) en.nextElement();
  +                             String name= header.getName();
  +                             String value= header.getValue();
  +                             if(name != null && value != null){
  +                                 name= name.trim();
  +                                 if(name.length() != 0)
  +                                     ap.addMimeHeader(name , value); 
  +                             }
  +                    }         
  +
  +                    addPart(contentId, contentLocation, ap);
                       boundaryDelimitedStream = boundaryDelimitedStream.getNextStream();
//Gets the next stream.
                   }
   
  @@ -198,7 +221,9 @@
           //First see if we have read it in yet.
           DataHandler ret = null; 
           for(int i= id.length -1; ret== null && i > -1; --i){
  -            ret = (DataHandler) parts.get(id[i]);
  +            AttachmentPart p=(AttachmentPart) parts.get(id[i]);
  +            if(null != p)
  +               ret=  p.getActiviationDataHandler();
           }
   
           if ( null == ret) {
  @@ -206,12 +231,23 @@
           }
           return ret;
       }
  +
  +    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);
  +        orderedParts.add(ap); 
  +    }
  +
  +    protected final static String[] READ_ALL= { " * \0 ".intern()}; //Shouldn't never match
   
  -    protected void addPart(String contentId, String locationId, javax.activation.DataHandler
dh) {
  -        if (contentId != null && contentId.trim().length() != 0) parts.put(contentId,
dh);
  -        if (locationId != null && locationId.trim().length() != 0)parts.put(locationId,
dh);
  +    protected void readAll( ) throws org.apache.axis.AxisFault {
  +       readTillFound(READ_ALL ); 
       }
   
  +    public java.util.Collection getAttachments() throws org.apache.axis.AxisFault {
  +       readAll();
  +       return 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
  @@ -258,16 +294,38 @@
                       if (contentId.endsWith(">")) contentId = contentId.substring(0,
contentId.length() - 1);
                       if (!contentId.startsWith("cid:")) contentId = "cid:" + contentId;
                   }
  -                contentType = headers.getHeader("Content-Type", null);
  +                contentType = headers.getHeader(HTTPConstants.HEADER_CONTENT_TYPE, null);
                   if (contentType != null) contentType = contentType.trim();
  -                contentLocation = headers.getHeader("Content-Location", null);
  +                contentLocation = headers.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION,
null);
                   if (contentLocation != null) contentLocation = contentLocation.trim();
  -                contentTransferEncoding = headers.getHeader("Content-Transfer-Encoding",
null);
  +                contentTransferEncoding = headers.getHeader(HTTPConstants.HEADER_CONTENT_TRANSFER_ENCODING
, null);
                   if (contentTransferEncoding != null ) contentTransferEncoding = contentTransferEncoding.trim();
   
                   DataHandler dh= new DataHandler(new ManagedMemoryDataSource(boundaryDelimitedStream,
1024, contentType, true));
  +
  +                AttachmentPart ap= new AttachmentPart(dh);
  +                if(contentId != null) 
  +                    ap.addMimeHeader(HTTPConstants.HEADER_CONTENT_ID, contentId); 
  +
  +                if (contentLocation != null)
  +                    ap.addMimeHeader(HTTPConstants.HEADER_CONTENT_LOCATION, contentLocation);

  +                
  +
  +                for( java.util.Enumeration en= headers.getNonMatchingHeaders(
  +                        new String[]{HTTPConstants.HEADER_CONTENT_ID,
  +                         HTTPConstants.HEADER_CONTENT_LOCATION,
  +                         HTTPConstants.HEADER_CONTENT_TYPE }); en.hasMoreElements(); ){
  +                         javax.mail.Header header= (javax.mail.Header) en.nextElement();
  +                         String name= header.getName();
  +                         String value= header.getValue();
  +                         if(name != null && value != null){
  +                             name= name.trim();
  +                             if(name.length() != 0)
  +                                 ap.addMimeHeader(name , value); 
  +                         }
  +                }         
   
  -                addPart(contentId, contentLocation, dh);
  +                addPart(contentId, contentLocation, ap);
   
                   for(int i= id.length -1; ret== null && i > -1; --i){
                       if (contentId != null && id[i].equals( contentId)) { //This
is the part being sought
  
  
  

Mime
View raw message