cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: cocoon-2.2/src/java/org/apache/cocoon/servlet/multipart MultipartParser.java
Date Wed, 29 Oct 2003 19:44:53 GMT
vgritsenko    2003/10/29 11:44:53

  Modified:    src/java/org/apache/cocoon/servlet/multipart
                        MultipartParser.java
  Log:
  Add a method allowing to use parser out of servlet environment
  
  Revision  Changes    Path
  1.3       +25 -22    cocoon-2.2/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java
  
  Index: MultipartParser.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/servlet/multipart/MultipartParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultipartParser.java	7 May 2003 05:09:39 -0000	1.2
  +++ MultipartParser.java	29 Oct 2003 19:44:53 -0000	1.3
  @@ -111,13 +111,12 @@
        * @param maxUploadSize The maximum content length accepted.
        * @param characterEncoding The character encoding to be used.
        */
  -    public MultipartParser(
  -            boolean saveUploadedFilesToDisk, 
  -            File uploadDirectory, 
  -            boolean allowOverwrite, 
  -            boolean silentlyRename, 
  -            int maxUploadSize,
  -            String characterEncoding)
  +    public MultipartParser(boolean saveUploadedFilesToDisk,
  +                           File uploadDirectory,
  +                           boolean allowOverwrite,
  +                           boolean silentlyRename,
  +                           int maxUploadSize,
  +                           String characterEncoding)
       {
           this.saveUploadedFilesToDisk = saveUploadedFilesToDisk;
           this.uploadDirectory = uploadDirectory;
  @@ -127,21 +126,25 @@
           this.characterEncoding = characterEncoding;
       }
   
  -    public Hashtable getParts(HttpServletRequest request) throws IOException, MultipartException
{
  -        if (request.getContentLength() > this.maxUploadSize) {
  -             throw new IOException("Content length exceeds maximum upload size");
  -         }
  +    public Hashtable getParts(int contentLength, String contentType, InputStream requestStream)
  +    throws IOException, MultipartException {
  +        if (contentLength > this.maxUploadSize) {
  +            throw new IOException("Content length exceeds maximum upload size");
  +        }
  +
  +        this.parts = new Hashtable();
   
  -         this.parts = new Hashtable();
  +        BufferedInputStream bufferedStream = new BufferedInputStream(requestStream);
  +        PushbackInputStream pushbackStream = new PushbackInputStream(bufferedStream, MAX_BOUNDARY_SIZE);
  +        TokenStream stream = new TokenStream(pushbackStream);
   
  -         InputStream requestStream = request.getInputStream();
  -         BufferedInputStream bufferedStream = new BufferedInputStream(requestStream);
  -         PushbackInputStream pushbackStream = new PushbackInputStream(bufferedStream, MAX_BOUNDARY_SIZE);
  -         TokenStream stream = new TokenStream(pushbackStream);
  -                        
  -         parseMultiPart(stream,getBoundary(request.getContentType()));
  +        parseMultiPart(stream, getBoundary(contentType));
   
  -         return this.parts;    
  +        return this.parts;    
  +    }
  +    
  +    public Hashtable getParts(HttpServletRequest request) throws IOException, MultipartException
{
  +        return getParts(request.getContentLength(), request.getContentType(), request.getInputStream());
   
       }
       
       /**
  
  
  

Mime
View raw message