You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by oz...@apache.org on 2004/08/09 12:27:11 UTC

cvs commit: jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms StoreContentZip.java OracleRDBMSAdapter.java CommonRDBMSAdapter.java

ozeigermann    2004/08/09 03:27:10

  Modified:    src/stores/org/apache/slide/store/impl/rdbms
                        StoreContentZip.java OracleRDBMSAdapter.java
                        CommonRDBMSAdapter.java
  Log:
  Applied patch contributed by Davide Savazzi in
  http://issues.apache.org/bugzilla/show_bug.cgi?id=30317
  
  Revision  Changes    Path
  1.6       +11 -4     jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StoreContentZip.java
  
  Index: StoreContentZip.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StoreContentZip.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StoreContentZip.java	28 Jul 2004 09:34:16 -0000	1.5
  +++ StoreContentZip.java	9 Aug 2004 10:27:10 -0000	1.6
  @@ -46,6 +46,7 @@
   
   	protected static final int ZIP_BUFFER = 2048;
   	private long contentLength	= 0;
  +	private long initialContentLength = -1;
   	private OutputStream theOS	= null;
   
   	/**
  @@ -67,12 +68,14 @@
   						throws IOException, ZipException{
   		int byteCount = 0;
   		contentLength = 0;
  +                initialContentLength = 0;
   		byte data[] = new byte[ZIP_BUFFER];
   		ByteArrayOutputStream baos = new ByteArrayOutputStream();
   		ZipOutputStream zoutp = new ZipOutputStream(baos);
   		zoutp.putNextEntry(new ZipEntry("zippedfile"));
   		while((byteCount = inIPS.read(data,0,ZIP_BUFFER)) != -1 ) {
   			zoutp.write(data,0,byteCount);
  +                        initialContentLength += byteCount;
   		}
   		zoutp.finish();
   		zoutp.flush();
  @@ -139,4 +142,8 @@
   		return contentLength;
   	}
   
  +        public long getInitialContentLength() {
  +		return initialContentLength;
  +	}
  +        
   }
  
  
  
  1.9       +14 -7     jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/OracleRDBMSAdapter.java
  
  Index: OracleRDBMSAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/OracleRDBMSAdapter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- OracleRDBMSAdapter.java	4 Aug 2004 11:45:59 -0000	1.8
  +++ OracleRDBMSAdapter.java	9 Aug 2004 10:27:10 -0000	1.9
  @@ -136,15 +136,22 @@
                   InputStream in = revisionContent.streamContent();
                   OutputStream out = ((oracle.sql.BLOB) blob).getBinaryOutputStream();
   
  +                StoreContentZip ziputil = new StoreContentZip();
                   if (bcompress) {
  -                    getLogger().log("Compressing the data", LOG_CHANNEL, 6);
  -                    StoreContentZip ziputil = new StoreContentZip();
  +                    getLogger().log("Compressing the data", LOG_CHANNEL, Logger.DEBUG);
                       ziputil.Zip(in);
                       in = ziputil.getInputStream();
                   }
   
                   try {
  -                    copy(in, out, ((oracle.sql.BLOB) blob).getBufferSize());
  +                    long writtenBytes = copy(in, out, ((oracle.sql.BLOB) blob).getBufferSize());
  +                    if (revisionDescriptor.getContentLength() == -1) {
  +                        if (bcompress) {
  +                            revisionDescriptor.setContentLength(ziputil.getInitialContentLength());
  +                        } else {
  +                            revisionDescriptor.setContentLength(writtenBytes);
  +                        }
  +                    }
                   } finally {
                       close(out);
                   }
  
  
  
  1.4       +9 -4      jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
  
  Index: CommonRDBMSAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CommonRDBMSAdapter.java	4 Aug 2004 11:45:59 -0000	1.3
  +++ CommonRDBMSAdapter.java	9 Aug 2004 10:27:10 -0000	1.4
  @@ -313,14 +313,19 @@
           }
       }
   
  -    public static void copy(InputStream in, OutputStream out, int bufferSize)
  +    public static long copy(InputStream in, OutputStream out, int bufferSize)
           throws IOException
       {
  +        long writtenBytes = 0;
  +        
           int read = 0;
           byte buffer[] = new byte[bufferSize];
           while ((read = in.read(buffer, 0, bufferSize)) != -1) {
               out.write(buffer, 0, read);
  +            writtenBytes += read;
           }
  +        
  +        return writtenBytes;
       }
   
       protected String convertRevisionNumberToComparable(String revisioNumber) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org