You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/06/19 10:46:06 UTC

svn commit: r191330 - in /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider: URLFileName.java http/HttpFileObject.java http/HttpFileSystemConfigBuilder.java webdav/WebdavFileObject.java webdav/WebdavFileSystemConfigBuilder.java

Author: imario
Date: Sun Jun 19 01:46:06 2005
New Revision: 191330

URL: http://svn.apache.org/viewcvs?rev=191330&view=rev
Log:
allow configuration of url charset through
WebdavFileSystemConfigBuilder
HttpFileSystemConfigBuilder

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java?rev=191330&r1=191329&r2=191330&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java Sun Jun 19 01:46:06 2005
@@ -48,16 +48,31 @@
 
     /**
      * get the path encoded suitable for url like filesystem e.g. (http, webdav)
+     * @param charset the charset used for the path encoding
      */
-    public String getPathQueryEncoded() throws URIException, FileSystemException
+    public String getPathQueryEncoded(String charset) throws URIException, FileSystemException
     {
         if (getQueryString() == null)
         {
-            return URIUtil.encodePath(getPathDecoded());
+            if (charset != null)
+            {
+                return URIUtil.encodePath(getPathDecoded(), charset);
+            }
+            else
+            {
+                return URIUtil.encodePath(getPathDecoded());
+            }
         }
 
         StringBuffer sb = new StringBuffer(250);
-        sb.append(URIUtil.encodePath(getPathDecoded()));
+        if (charset != null)
+        {
+            sb.append(URIUtil.encodePath(getPathDecoded(), charset));
+        }
+        else
+        {
+            sb.append(URIUtil.encodePath(getPathDecoded()));
+        }
         sb.append("?");
         sb.append(getQueryString());
         return sb.toString();

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java?rev=191330&r1=191329&r2=191330&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileObject.java Sun Jun 19 01:46:06 2005
@@ -48,6 +48,7 @@
     extends AbstractFileObject
 {
     private final HttpFileSystem fileSystem;
+    private final String urlCharset;
     private HeadMethod method;
 
     protected HttpFileObject(final FileName name,
@@ -55,6 +56,7 @@
     {
         super(name, fileSystem);
         this.fileSystem = fileSystem;
+        urlCharset = HttpFileSystemConfigBuilder.getInstance().getUrlCharset(getFileSystem().getFileSystemOptions());
     }
 
     /**
@@ -167,7 +169,7 @@
      */
     void setupMethod(final HttpMethod method) throws FileSystemException, URIException
     {
-        String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded();
+        String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded(urlCharset);
         method.setPath(pathEncoded);
         method.setFollowRedirects(true);
         method.setRequestHeader("User-Agent", "Jakarta-Commons-VFS");

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java?rev=191330&r1=191329&r2=191330&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileSystemConfigBuilder.java Sun Jun 19 01:46:06 2005
@@ -38,6 +38,26 @@
     }
 
     /**
+     * Set the charset used for url encoding<br>
+     *
+     * @param chaset the chaset
+     */
+    public void setUrlCharset(FileSystemOptions opts, String chaset)
+    {
+        setParam(opts, "urlCharset", chaset);
+    }
+
+    /**
+     * Set the charset used for url encoding<br>
+     *
+     * @return the chaset
+     */
+    public String getUrlCharset(FileSystemOptions opts)
+    {
+        return (String) getParam(opts, "urlCharset");
+    }
+
+    /**
      * Set the proxy to use for http connection.<br>
      * You have to set the ProxyPort too if you would like to have the proxy relly used.
      *

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?rev=191330&r1=191329&r2=191330&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Sun Jun 19 01:46:06 2005
@@ -56,6 +56,7 @@
     implements FileObject
 {
     private final WebDavFileSystem fileSystem;
+    private final String urlCharset;
     private WebdavResource resource;
     private boolean redirectionResolved = false;
     private Set allowedMethods = null;
@@ -66,6 +67,7 @@
     {
         super(name, fileSystem);
         this.fileSystem = fileSystem;
+        this.urlCharset = WebdavFileSystemConfigBuilder.getInstance().getUrlCharset(getFileSystem().getFileSystemOptions());
     }
 
     /**
@@ -75,7 +77,7 @@
     {
         if (resource == null)
         {
-            setDavResource(null, true);
+            setDavResource(null);
         }
     }
 
@@ -96,10 +98,9 @@
      * set the davResource
      *
      * @param resource
-     * @param bCheckExists might be removed soon
      * @throws Exception
      */
-    private void setDavResource(WebdavResource resource, boolean bCheckExists) throws Exception
+    private void setDavResource(WebdavResource resource) throws Exception
     {
         redirectionResolved = false;
 
@@ -109,7 +110,7 @@
         if (resource == null)
         {
             // HttpURL url = new HttpURL(name.getHostName(), name.getPort(), name.getPath());
-            String pathEncoded = name.getPathQueryEncoded();
+            String pathEncoded = name.getPathQueryEncoded(urlCharset);
             HttpURL url = new HttpURL(name.getUserName(), name.getPassword(), name.getHostName(), name.getPort());
             url.setEscapedPath(pathEncoded);
             resource = new WebdavResource(fileSystem.getClient())
@@ -123,7 +124,7 @@
         // if (bCheckExists)
         {
             /* now fill the dav properties */
-            String pathEncoded = name.getPathQueryEncoded();
+            String pathEncoded = name.getPathQueryEncoded(urlCharset);
             final OptionsMethod optionsMethod = new OptionsMethod(pathEncoded);
             optionsMethod.setFollowRedirects(true);
             final int status = fileSystem.getClient().executeMethod(optionsMethod);
@@ -313,7 +314,7 @@
                     getName(),
                     davName,
                     NameScope.CHILD));
-            fo.setDavResource(dav, false);
+            fo.setDavResource(dav);
 
             // vfs[i] = fo;
             vfs.add(fo);

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java?rev=191330&r1=191329&r2=191330&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileSystemConfigBuilder.java Sun Jun 19 01:46:06 2005
@@ -38,6 +38,26 @@
     }
 
     /**
+     * Set the charset used for url encoding<br>
+     *
+     * @param chaset the chaset
+     */
+    public void setUrlCharset(FileSystemOptions opts, String chaset)
+    {
+        setParam(opts, "urlCharset", chaset);
+    }
+
+    /**
+     * Set the charset used for url encoding<br>
+     *
+     * @return the chaset
+     */
+    public String getUrlCharset(FileSystemOptions opts)
+    {
+        return (String) getParam(opts, "urlCharset");
+    }
+
+    /**
      * Set the proxy to use for webdav connection.<br>
      * You have to set the ProxyPort too if you would like to have the proxy relly used.
      *



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