chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1380555 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
Date Tue, 04 Sep 2012 11:21:31 GMT
Author: fmui
Date: Tue Sep  4 11:21:30 2012
New Revision: 1380555

URL: http://svn.apache.org/viewvc?rev=1380555&view=rev
Log:
Server: ThresholdOutputStream improvements

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java?rev=1380555&r1=1380554&r2=1380555&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
Tue Sep  4 11:21:30 2012
@@ -214,7 +214,7 @@ public class ThresholdOutputStream exten
     /**
      * Returns the data as an InputStream.
      */
-    public InputStream getInputStream() throws Exception {
+    public InputStream getInputStream() throws IOException {
         if (tmpStream != null) {
             close();
             buf = null;
@@ -266,6 +266,11 @@ public class ThresholdOutputStream exten
         public long length() {
             return size;
         }
+
+        /**
+         * Rewinds the stream so that it can be read from the beginning.
+         */
+        public abstract void rewind() throws IOException;
     }
 
     /**
@@ -285,6 +290,16 @@ public class ThresholdOutputStream exten
         }
 
         @Override
+        public void rewind() throws IOException {
+            if (buf == null) {
+                throw new IOException("Stream is already closed!");
+            }
+
+            pos = 0;
+            mark = -1;
+        }
+
+        @Override
         public boolean markSupported() {
             return true;
         }
@@ -363,7 +378,7 @@ public class ThresholdOutputStream exten
      */
     private class InternalTempFileInputStream extends ThresholdInputStream {
 
-        private final BufferedInputStream stream;
+        private BufferedInputStream stream;
         private boolean isDeleted = false;
         private boolean isClosed = false;
 
@@ -380,6 +395,17 @@ public class ThresholdOutputStream exten
         }
 
         @Override
+        public void rewind() throws IOException {
+            if (isClosed) {
+                throw new IOException("Stream is already closed!");
+            }
+
+            stream.close();
+
+            stream = new BufferedInputStream(new FileInputStream(tempFile), memoryThreshold);
+        }
+
+        @Override
         public int available() throws IOException {
             if (isClosed) {
                 throw new IOException("Stream is already closed!");



Mime
View raw message