Fix variable naming conventions
[pub/Android/ownCloud.git] / src / eu / alefzero / webdav / WebdavClient.java
index 880995d..4b719fb 100644 (file)
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URLDecoder;\r
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URLDecoder;\r
+import java.net.URLEncoder;\r
 
 import org.apache.commons.httpclient.Credentials;\r
 import org.apache.commons.httpclient.HttpClient;\r
 
 import org.apache.commons.httpclient.Credentials;\r
 import org.apache.commons.httpclient.HttpClient;\r
@@ -30,6 +31,7 @@ import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;\r
 import org.apache.commons.httpclient.methods.HeadMethod;\r
 import org.apache.commons.httpclient.methods.PutMethod;\r
 import org.apache.commons.httpclient.methods.GetMethod;\r
 import org.apache.commons.httpclient.methods.HeadMethod;\r
 import org.apache.commons.httpclient.methods.PutMethod;\r
+import org.apache.commons.httpclient.methods.RequestEntity;\r
 import org.apache.commons.httpclient.params.HttpMethodParams;\r
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.http.HttpStatus;\r
 import org.apache.commons.httpclient.params.HttpMethodParams;\r
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.http.HttpStatus;\r
@@ -71,12 +73,13 @@ public class WebdavClient extends HttpClient {
     //HttpGet get = new HttpGet(mUri.toString() + filepath.replace(" ", "%20"));\r
    \r
     Log.e("ASD", mUri.toString() + URLDecoder.decode(filepath) + "");\r
     //HttpGet get = new HttpGet(mUri.toString() + filepath.replace(" ", "%20"));\r
    \r
     Log.e("ASD", mUri.toString() + URLDecoder.decode(filepath) + "");\r
-    GetMethod get = new GetMethod(mUri.toString() + URLDecoder.decode(filepath));\r
+    GetMethod get = new GetMethod(mUri.toString() + URLEncoder.encode(filepath));\r
     
 //    get.setHeader("Host", mUri.getHost());
 //    get.setHeader("User-Agent", "Android-ownCloud");
     
     
 //    get.setHeader("Host", mUri.getHost());
 //    get.setHeader("User-Agent", "Android-ownCloud");
     
-    try {
+    try {\r
+      Log.e("ASD", get.toString());
       int status = executeMethod(get);
       if (status != HttpStatus.SC_OK) {
         return false;
       int status = executeMethod(get);
       if (status != HttpStatus.SC_OK) {
         return false;
@@ -100,10 +103,14 @@ public class WebdavClient extends HttpClient {
                   String contentType) {
     boolean result = true;
 
                   String contentType) {
     boolean result = true;
 
-    try {
-      FileRequestEntity entity = new FileRequestEntity(new File(localFile), contentType);\r
-      PutMethod put = new PutMethod(mUri.toString() + remoteTarget.substring(1));\r
+    try {\r
+      Log.e("ASD", contentType+"");\r
+      File f = new File(localFile);
+      RequestEntity entity = new FileRequestEntity(f, contentType);\r
+      Log.e("ASD", f.exists()+" " + entity.getContentLength());\r
+      PutMethod put = new PutMethod(mUri.toString() + remoteTarget);\r
       put.setRequestEntity(entity);\r
       put.setRequestEntity(entity);\r
+      Log.d(TAG, "" + put.getURI().toString());\r
       int status = executeMethod(put);\r
       Log.d(TAG, "PUT method return with status "+status);
 
       int status = executeMethod(put);\r
       Log.d(TAG, "PUT method return with status "+status);