haul        2003/01/21 07:55:50

  Modified:    .        changes.xml
               src/java/org/apache/cocoon/components/request/multipart
                        FilePart.java FilePartArray.java FilePartFile.java
                        MultipartParser.java
               src/blocks/databases/java/org/apache/cocoon/util
                        JDBCTypeConversions.java
  Log:
    <action dev="CH" type="add" due-to="Geoff Howard" 
due-to-email="[EMAIL PROTECTED]">
      modular.DatabaseActions: added ability to store FileParts from uploads to
      "ascii", "clob", "blob", and "binary" columns. Added getSize() method to 
FilePart.
    </action>
  
  Revision  Changes    Path
  1.340     +5 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.339
  retrieving revision 1.340
  diff -u -r1.339 -r1.340
  --- changes.xml       17 Jan 2003 11:29:22 -0000      1.339
  +++ changes.xml       21 Jan 2003 15:55:50 -0000      1.340
  @@ -40,6 +40,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="CH" type="add" due-to="Geoff Howard" 
due-to-email="[EMAIL PROTECTED]">
  +    modular.DatabaseActions: added ability to store FileParts from uploads to
  +    "ascii", "clob", "blob", and "binary" columns. Added getSize() method to 
FilePart.
  +  </action>
     <action dev="CH" type="add" fixes-bug="9075"
                       due-to="Michael Gerzabek" 
due-to-email="[EMAIL PROTECTED]">
       SAP R/3 connectivity components added.
  
  
  
  1.4       +8 -1      
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePart.java
  
  Index: FilePart.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePart.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FilePart.java     23 May 2002 12:01:08 -0000      1.3
  +++ FilePart.java     21 Jan 2003 15:55:50 -0000      1.4
  @@ -53,6 +53,7 @@
   import java.io.InputStream;
   import java.util.Map;
   
  +
   /**
    * This (abstract) class represents a file part parsed from a http post stream.
    * It is subclassed by FilePartFile (which is a file allready written to disk) and
  @@ -83,6 +84,12 @@
        *
        */
       public abstract String getFileName();
  +    
  +    /**
  +     * Returns the length of the file content
  +     * 
  +     */
  +    public abstract int getSize();
   
       /**
        * Returns the filepath
  
  
  
  1.5       +9 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java
  
  Index: FilePartArray.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FilePartArray.java        17 Sep 2002 15:56:09 -0000      1.4
  +++ FilePartArray.java        21 Jan 2003 15:55:50 -0000      1.5
  @@ -64,16 +64,19 @@
   
       /** Field in           */
       private InputStream in = null;
  +    private int size;
   
       /**
        * Constructor FilePartArray
        *
        * @param headers
        * @param in
  +     * @param size
        */
  -    protected FilePartArray(Map headers, InputStream in) {
  +    protected FilePartArray(Map headers, InputStream in, int size) {
           super(headers);
           this.in = in;
  +        this.size = size;
       }
   
       /**
  @@ -83,6 +86,10 @@
       public String getFileName() {
           File f = new File((String) headers.get("filename"));
           return f.getName();
  +    }
  +
  +    public int getSize() {
  +        return this.size;
       }
   
       /**
  
  
  
  1.6       +7 -1      
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java
  
  Index: FilePartFile.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FilePartFile.java 3 Oct 2002 04:18:23 -0000       1.5
  +++ FilePartFile.java 21 Jan 2003 15:55:50 -0000      1.6
  @@ -65,6 +65,7 @@
   
       /** Field file           */
       private File file = null;
  +    private int size;
   
       /**
        * Constructor FilePartFile
  @@ -75,6 +76,7 @@
       protected FilePartFile(Map headers, File file) {
           super(headers);
           this.file = file;
  +        this.size = (int) file.length();
       }
   
       /**
  @@ -82,6 +84,10 @@
        */
       public String getFileName() {
           return file.getName();
  +    }
  +
  +    public int getSize() {
  +        return this.size;
       }
   
       /**
  
  
  
  1.5       +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java
  
  Index: MultipartParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MultipartParser.java      21 Sep 2002 16:29:33 -0000      1.4
  +++ MultipartParser.java      21 Jan 2003 15:55:50 -0000      1.5
  @@ -270,7 +270,7 @@
               byte[] bytes = ((ByteArrayOutputStream) out).toByteArray();
   
               put(headers.get("name"),
  -                    new FilePartArray(headers, new ByteArrayInputStream(bytes)));
  +                    new FilePartArray(headers, new 
ByteArrayInputStream(bytes),bytes.length));
           } else {
               put(headers.get("name"), new FilePartFile(headers, file));
           }
  
  
  
  1.6       +16 -0     
xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/util/JDBCTypeConversions.java
  
  Index: JDBCTypeConversions.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/util/JDBCTypeConversions.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDBCTypeConversions.java  9 Jan 2003 16:53:36 -0000       1.5
  +++ JDBCTypeConversions.java  21 Jan 2003 15:55:50 -0000      1.6
  @@ -68,6 +68,7 @@
   import java.util.HashMap;
   import java.util.Collections;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.cocoon.components.request.multipart.FilePart;
   import org.apache.excalibur.source.Source;
   
   
  @@ -305,6 +306,11 @@
                   asciiStream = new BufferedInputStream(new 
FileInputStream(asciiFile));
                   length = (int) asciiFile.length();
                   clob = new ClobHelper(asciiStream, length);
  +            } else if (value instanceof FilePart) {
  +                FilePart anyFile = (FilePart) value;
  +                asciiStream = new BufferedInputStream(anyFile.getInputStream());
  +                length = (int) anyFile.getSize();
  +                clob = new ClobHelper(asciiStream, length);
               } else if (value instanceof JDBCxlobHelper) {
                   asciiStream = ((JDBCxlobHelper) value).inputStream;
                   length = ((JDBCxlobHelper) value).length;
  @@ -336,6 +342,11 @@
               } else if (value instanceof Source) {
                   asciiStream = ((Source) value).getInputStream();
                   length = (int)((Source) value).getContentLength();
  +            } else if (value instanceof FilePart) {
  +                FilePart anyFile = (FilePart) value;
  +                asciiStream = new BufferedInputStream(anyFile.getInputStream());
  +                length = (int) anyFile.getSize();
  +                clob = new ClobHelper(asciiStream, length);
               } else {
                   String asciiText = (String) value;
                   asciiStream = new BufferedInputStream(new 
ByteArrayInputStream(asciiText.getBytes()));
  @@ -498,6 +509,9 @@
                   } else if (value instanceof String) {
                       file = new File((String)value);
                       blob = new BlobHelper(new FileInputStream(file), (int) 
file.length());
  +                } else if (value instanceof FilePart) {
  +                    FilePart anyFile = (FilePart) value;
  +                    blob = new BlobHelper(new 
BufferedInputStream(anyFile.getInputStream()), anyFile.getSize());
                   } else {
                       throw new SQLException("Invalid type for blob: 
"+value.getClass().getName());
                   }
  @@ -511,6 +525,8 @@
                   statement.setBinaryStream(position, 
((JDBCxlobHelper)value).inputStream, ((JDBCxlobHelper)value).length);
               } else if (value instanceof Source){
                   statement.setBinaryStream(position, 
((Source)value).getInputStream(), (int)((Source)value).getContentLength());
  +            } else if (value instanceof FilePart) {
  +                statement.setBinaryStream(position, 
((FilePart)value).getInputStream(), ((FilePart)value).getSize());
               } else {
                   if (value instanceof File) {
                       file = (File)value;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to