Fixes in coments
authorDavid A. Velasco <dvelasco@solidgear.es>
Thu, 12 Dec 2013 13:22:13 +0000 (14:22 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Thu, 12 Dec 2013 13:22:13 +0000 (14:22 +0100)
oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteFile.java
oc_framework/src/com/owncloud/android/oc_framework/operations/remote/ReadRemoteFileOperation.java
oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java

index 07f45b7..922b270 100644 (file)
@@ -22,6 +22,7 @@ import java.io.Serializable;
 import android.os.Parcel;
 import android.os.Parcelable;
 
+import com.owncloud.android.oc_framework.network.webdav.WebdavEntry;
 import com.owncloud.android.oc_framework.utils.FileUtils;
 
 /**
@@ -33,7 +34,7 @@ import com.owncloud.android.oc_framework.utils.FileUtils;
 public class RemoteFile implements Parcelable, Serializable {
 
        /** Generated - should be refreshed every time the class changes!! */
-       private static final long serialVersionUID = 7256606476031992757L;
+       private static final long serialVersionUID = 532139091191390616L;
        
        private String mRemotePath;
        private String mMimeType;
@@ -108,6 +109,15 @@ public class RemoteFile implements Parcelable, Serializable {
         }
         mRemotePath = path;
        }
+       
+       public RemoteFile(WebdavEntry we) {
+        this(we.decodedPath());
+        this.setCreationTimestamp(we.createTimestamp());
+        this.setLength(we.contentLength());
+        this.setMimeType(we.contentType());
+        this.setModifiedTimestamp(we.modifiedTimestamp());
+        this.setEtag(we.etag());
+       }
 
        /**
      * Used internally. Reset all file properties
index 7e62376..6cdacad 100644 (file)
@@ -31,7 +31,6 @@ import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
 import com.owncloud.android.oc_framework.operations.RemoteFile;
 import com.owncloud.android.oc_framework.operations.RemoteOperation;
 import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
-import com.owncloud.android.oc_framework.utils.FileUtils;
 
 
 /**
@@ -79,19 +78,17 @@ public class ReadRemoteFileOperation extends RemoteOperation {
 
                boolean isMultiStatus = status == HttpStatus.SC_MULTI_STATUS;
                if (isMultiStatus) {
+                       // Parse response
                        MultiStatus resp = propfind.getResponseBodyAsMultiStatus();
+                               WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getBaseUri().getPath());
+                               RemoteFile remoteFile = new RemoteFile(we);
+                               ArrayList<RemoteFile> files = new ArrayList<RemoteFile>();
+                               files.add(remoteFile);
+
                        // Result of the operation
                        result = new RemoteOperationResult(true, status, propfind.getResponseHeaders());
+                       result.setData(files);
                        
-                       // Add data to the result
-                       if (result.isSuccess()) {
-                               WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getBaseUri().getPath());
-                               RemoteFile remoteFile = FileUtils.fillOCFile(we);
-                               ArrayList<RemoteFile> files = new ArrayList<RemoteFile>();
-                               files.add(remoteFile);
-                               result.setData(files); 
-                       }
-
                } else {
                        client.exhaustResponse(propfind.getResponseBodyAsStream());
                        result = new RemoteOperationResult(false, status, propfind.getResponseHeaders());
index 0f4009b..192c267 100644 (file)
@@ -19,9 +19,6 @@ package com.owncloud.android.oc_framework.utils;
 
 import java.io.File;
 
-import com.owncloud.android.oc_framework.network.webdav.WebdavEntry;
-import com.owncloud.android.oc_framework.operations.RemoteFile;
-
 import android.util.Log;
 
 public class FileUtils {
@@ -69,21 +66,6 @@ public class FileUtils {
                }
                return result;
        }
+
        
-       /**
-     * Creates and populates a new {@link RemoteFile} object with the data read from the server.
-     * 
-     * @param we        WebDAV entry read from the server for a WebDAV resource (remote file or folder).
-     * @return          New OCFile instance representing the remote resource described by we.
-     */
-    public static RemoteFile fillOCFile(WebdavEntry we) {
-        RemoteFile file = new RemoteFile(we.decodedPath());
-        file.setCreationTimestamp(we.createTimestamp());
-        file.setLength(we.contentLength());
-        file.setMimeType(we.contentType());
-        file.setModifiedTimestamp(we.modifiedTimestamp());
-        file.setEtag(we.etag());
-        return file;
-    }
-    
 }