Author: rgoers
Date: Tue Jun  9 06:42:16 2009
New Revision: 782895

URL: http://svn.apache.org/viewvc?rev=782895&view=rev
Log:
make HttpOutputStream and VFSURLStreamHandler private. Limit 
VerifiableOutputStream to package scope

Removed:
    
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/HttpOutputStream.java
    
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSURLStreamHandler.java
Modified:
    
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultFileSystem.java
    
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSFileSystem.java
    
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VerifiableOutputStream.java

Modified: 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultFileSystem.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultFileSystem.java?rev=782895&r1=782894&r2=782895&view=diff
==============================================================================
--- 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultFileSystem.java
 (original)
+++ 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultFileSystem.java
 Tue Jun  9 06:42:16 2009
@@ -278,4 +278,63 @@
             }
         }
     }
+    /**
+     * Wraps the output stream so errors can be detected in the HTTP response.
+     * @since 1.7
+     * @author <a
+     * href="http://commons.apache.org/configuration/team-list.html";>Commons 
Configuration team</a>
+     */
+    private static class HttpOutputStream extends VerifiableOutputStream
+    {
+        /** The wrapped OutputStream */
+        private final OutputStream stream;
+
+        /** The HttpURLConnection */
+        private final HttpURLConnection connection;
+
+        public HttpOutputStream(OutputStream stream, HttpURLConnection 
connection)
+        {
+            this.stream = stream;
+            this.connection = connection;
+        }
+
+        public void write(byte[] bytes) throws IOException
+        {
+            stream.write(bytes);
+        }
+
+        public void write(byte[] bytes, int i, int i1) throws IOException
+        {
+            stream.write(bytes, i, i1);
+        }
+
+        public void flush() throws IOException
+        {
+            stream.flush();
+        }
+
+        public void close() throws IOException
+        {
+            stream.close();
+        }
+
+        public void write(int i) throws IOException
+        {
+            stream.write(i);
+        }
+
+        public String toString()
+        {
+            return stream.toString();
+        }
+
+        public void verify() throws IOException
+        {
+            if (connection.getResponseCode() >= 
HttpURLConnection.HTTP_BAD_REQUEST)
+            {
+                throw new IOException("HTTP Error " + 
connection.getResponseCode()
+                        + " " + connection.getResponseMessage());
+            }
+        }
+    }
 }

Modified: 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSFileSystem.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSFileSystem.java?rev=782895&r1=782894&r2=782895&view=diff
==============================================================================
--- 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSFileSystem.java
 (original)
+++ 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VFSFileSystem.java
 Tue Jun  9 06:42:16 2009
@@ -33,9 +33,11 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.net.URLStreamHandler;
 import java.net.MalformedURLException;
+import java.net.URLConnection;
 import java.util.Map;
 
 /**
@@ -425,4 +427,23 @@
         }
         return opts;
     }
+
+    /**
+     * Stream handler required to create URL.
+     */
+    private static class VFSURLStreamHandler extends URLStreamHandler
+    {
+        /** The Protocol used */
+        private final String protocol;
+
+        public VFSURLStreamHandler(FileName file)
+        {
+            this.protocol = file.getScheme();
+        }
+
+        protected URLConnection openConnection(URL url) throws IOException
+        {
+            throw new IOException("VFS URLs can only be used with VFS APIs");
+        }
+    }
 }

Modified: 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VerifiableOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VerifiableOutputStream.java?rev=782895&r1=782894&r2=782895&view=diff
==============================================================================
--- 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VerifiableOutputStream.java
 (original)
+++ 
commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/VerifiableOutputStream.java
 Tue Jun  9 06:42:16 2009
@@ -25,7 +25,7 @@
  * @author <a
  * href="http://commons.apache.org/configuration/team-list.html";>Commons 
Configuration team</a>
  */
-public abstract class VerifiableOutputStream extends OutputStream
+abstract class VerifiableOutputStream extends OutputStream
 {
     public abstract void verify() throws IOException;
 }


Reply via email to