OCFile stores again decoded remote paths; WebdavUtils.encode(...) added; fixed space...
[pub/Android/ownCloud.git] / src / eu / alefzero / webdav / WebdavClient.java
index dd3b4ea..9eafddc 100644 (file)
@@ -113,9 +113,16 @@ public class WebdavClient extends HttpClient {
                 new EasySSLSocketFactory(), 443));\r
     }\r
 \r
+    /**\r
+     * Downloads a file in remoteFilepath to the local targetPath.\r
+     * \r
+     * @param remoteFilepath    Path to the file in the remote server, URL DECODED. \r
+     * @param targetPath        Local path to save the downloaded file.\r
+     * @return                  'True' when the file is successfully downloaded.\r
+     */\r
     public boolean downloadFile(String remoteFilepath, File targetPath) {\r
         boolean ret = false;\r
-        GetMethod get = new GetMethod(mUri.toString() + remoteFilepath);\r
+        GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encode(remoteFilepath));\r
         HttpMethodParams params = get.getParams();\r
         params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
         get.setParams(params);\r
@@ -152,11 +159,11 @@ public class WebdavClient extends HttpClient {
     \r
     /**\r
      * Deletes a remote file via webdav\r
-     * @param remoteFilePath\r
+     * @param remoteFilePath       Remote file path of the file to delete, in URL DECODED format.\r
      * @return\r
      */\r
     public boolean deleteFile(String remoteFilePath){\r
-        DavMethod delete = new DeleteMethod(mUri.toString() + remoteFilePath);\r
+        DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encode(remoteFilePath));\r
         try {\r
             executeMethod(delete);\r
         }  catch (Throwable e) {\r
@@ -170,6 +177,15 @@ public class WebdavClient extends HttpClient {
         mDataTransferListener = listener;\r
     }\r
     \r
+    /**\r
+     * Creates or update a file in the remote server with the contents of a local file.\r
+     * \r
+     * \r
+     * @param localFile         Path to the local file to upload.\r
+     * @param remoteTarget      Remote path to the file to create or update, URL DECODED\r
+     * @param contentType       MIME type of the file.\r
+     * @return                  'True' then the upload was successfully completed\r
+     */\r
     public boolean putFile(String localFile, String remoteTarget,\r
             String contentType) {\r
         boolean result = true;\r
@@ -180,7 +196,7 @@ public class WebdavClient extends HttpClient {
             FileRequestEntity entity = new FileRequestEntity(f, contentType);\r
             entity.setOnDatatransferProgressListener(mDataTransferListener);\r
             Log.e("ASD", f.exists() + " " + entity.getContentLength());\r
-            PutMethod put = new PutMethod(mUri.toString() + remoteTarget);\r
+            PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encode(remoteTarget));\r
             HttpMethodParams params = put.getParams();\r
             params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit\r
             put.setParams(params);\r
@@ -218,9 +234,15 @@ public class WebdavClient extends HttpClient {
         return returnCode;\r
     }\r
 \r
+    /**\r
+     * Creates a remote directory with the received path.\r
+     * \r
+     * @param path      Path of the directory to create, URL DECODED\r
+     * @return          'True' when the directory is successfully created\r
+     */\r
     public boolean createDirectory(String path) {\r
         try {\r
-            MkColMethod mkcol = new MkColMethod(mUri.toString() + path);\r
+            MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encode(path));\r
             int status = executeMethod(mkcol);\r
             Log.d(TAG, "Status returned " + status);\r
             Log.d(TAG, "uri: " + mkcol.getURI().toString());\r