[jboss-cvs] jboss-seam/src/main/org/jboss/seam/servlet ...

Shane Bryzak Shane_Bryzak at symantec.com
Tue Jan 23 00:19:36 EST 2007


  User: sbryzak2
  Date: 07/01/23 00:19:36

  Modified:    src/main/org/jboss/seam/servlet  MultipartRequest.java
  Log:
  separate value bindings for data, content type and filename
  
  Revision  Changes    Path
  1.2       +56 -1     jboss-seam/src/main/org/jboss/seam/servlet/MultipartRequest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MultipartRequest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/servlet/MultipartRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- MultipartRequest.java	22 Jan 2007 16:19:28 -0000	1.1
  +++ MultipartRequest.java	23 Jan 2007 05:19:36 -0000	1.2
  @@ -26,6 +26,8 @@
      {
         private Map<String,String> params;
         private byte[] data;
  +      private String contentType;
  +      private String fileName;
         
         public PartWrapper()
         {
  @@ -46,6 +48,26 @@
         {
            return data;
         }
  +      
  +      public String getContentType()
  +      {
  +         return contentType;
  +      }
  +      
  +      public void setContentType(String contentType)
  +      {
  +         this.contentType = contentType;
  +      }
  +      
  +      public String getFileName()
  +      {
  +         return fileName;
  +      }
  +      
  +      public void setFileName(String fileName)
  +      {
  +         this.fileName = fileName;
  +      }
      }
   
      private HttpServletRequest request;
  @@ -96,6 +118,9 @@
         }
      }
      
  +   private static final String FILE_CONTENT_TYPE = "Content-Type";
  +   private static final String FILE_NAME = "filename";
  +   
      private void parseBoundary(byte[] boundary)
      {
         PartWrapper entry = new PartWrapper();
  @@ -121,6 +146,18 @@
            }         
         }
         
  +      for (String key : entry.getParams().keySet())
  +      {
  +         String val = entry.getParams().get(key);
  +         if (val != null)
  +         {        
  +            if (entry.getContentType() == null && FILE_CONTENT_TYPE.equalsIgnoreCase(key))
  +               entry.setContentType(val);
  +            else if (entry.getFileName() == null && FILE_NAME.equalsIgnoreCase(key))
  +               entry.setFileName(val);
  +         }
  +      }
  +      
         byte[] data = new byte[boundary.length - start];
         System.arraycopy(boundary, start, data, 0, data.length);
         entry.setData(data);
  @@ -316,6 +353,24 @@
         return wrapper != null ? wrapper.getData() : null;
      }
   
  +   public String getFileContentType(String name)
  +   {
  +      if (parameters == null)
  +         parseRequest();
  +      
  +      PartWrapper wrapper = parameters.get(name);      
  +      return wrapper != null ? wrapper.getContentType() : null;
  +   }
  +   
  +   public String getFileName(String name)
  +   {
  +      if (parameters == null)
  +         parseRequest();
  +      
  +      PartWrapper wrapper = parameters.get(name);
  +      return wrapper != null ? wrapper.getFileName() : null;
  +   }   
  +   
      @Override
      public String getParameter(String name)
      {
  
  
  



More information about the jboss-cvs-commits mailing list