diff --git a/src/com/owncloud/android/lib/common/network/WebdavEntry.java b/src/com/owncloud/android/lib/common/network/WebdavEntry.java index db7fb383..21a8051a 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavEntry.java +++ b/src/com/owncloud/android/lib/common/network/WebdavEntry.java @@ -37,13 +37,13 @@ import android.net.Uri; import com.owncloud.android.lib.common.utils.Log_OC; public class WebdavEntry { - private static final String NAMESPACE_OC = "http://owncloud.org/ns"; - private static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions"; - private static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id"; - private static final String EXTENDED_PROPERTY_NAME_SIZE = "size"; + public static final String NAMESPACE_OC = "http://owncloud.org/ns"; + public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions"; + public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id"; + public static final String EXTENDED_PROPERTY_NAME_SIZE = "size"; - private static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes"; - private static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes"; + public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes"; + public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes"; private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId; private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java index 3fb695a4..b3e53fb9 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java @@ -29,6 +29,9 @@ import org.apache.http.HttpStatus; import org.apache.jackrabbit.webdav.DavConstants; import org.apache.jackrabbit.webdav.MultiStatus; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; +import org.apache.jackrabbit.webdav.property.DavPropertyName; +import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; +import org.apache.jackrabbit.webdav.xml.Namespace; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.WebdavEntry; @@ -75,8 +78,27 @@ public class ReadRemoteFileOperation extends RemoteOperation { /// take the duty of check the server for the current state of the file there try { + // PropFind Properties ( instead of DavConstants.PROPFIND_ALL_PROP ) + DavPropertyNameSet propSet = new DavPropertyNameSet(); + propSet.add(DavPropertyName.DISPLAYNAME); + propSet.add(DavPropertyName.GETCONTENTTYPE); + propSet.add(DavPropertyName.RESOURCETYPE); + propSet.add(DavPropertyName.GETCONTENTLENGTH); + propSet.add(DavPropertyName.GETLASTMODIFIED); + propSet.add(DavPropertyName.CREATIONDATE); + propSet.add(DavPropertyName.GETETAG); + propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES)); + propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + + // remote request propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), - DavConstants.PROPFIND_ALL_PROP, + propSet, DavConstants.DEPTH_0); int status; status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT); @@ -88,7 +110,8 @@ public class ReadRemoteFileOperation extends RemoteOperation { if (isSuccess) { // Parse response MultiStatus resp = propfind.getResponseBodyAsMultiStatus(); - WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getWebdavUri().getPath()); + WebdavEntry we = new WebdavEntry(resp.getResponses()[0], + client.getWebdavUri().getPath()); RemoteFile remoteFile = new RemoteFile(we); ArrayList files = new ArrayList(); files.add(remoteFile); @@ -105,7 +128,8 @@ public class ReadRemoteFileOperation extends RemoteOperation { } catch (Exception e) { result = new RemoteOperationResult(e); e.printStackTrace(); - Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(), result.getException()); + Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(), + result.getException()); } finally { if (propfind != null) propfind.releaseConnection(); diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index 84926b7c..fb9c34c8 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -30,6 +30,9 @@ import org.apache.http.HttpStatus; import org.apache.jackrabbit.webdav.DavConstants; import org.apache.jackrabbit.webdav.MultiStatus; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; +import org.apache.jackrabbit.webdav.property.DavPropertyName; +import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; +import org.apache.jackrabbit.webdav.xml.Namespace; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.WebdavEntry; @@ -72,9 +75,27 @@ public class ReadRemoteFolderOperation extends RemoteOperation { PropFindMethod query = null; try { - // remote request + // PropFind Properties ( instead of DavConstants.PROPFIND_ALL_PROP ) + DavPropertyNameSet propSet = new DavPropertyNameSet(); + propSet.add(DavPropertyName.DISPLAYNAME); + propSet.add(DavPropertyName.GETCONTENTTYPE); + propSet.add(DavPropertyName.RESOURCETYPE); + propSet.add(DavPropertyName.GETCONTENTLENGTH); + propSet.add(DavPropertyName.GETLASTMODIFIED); + propSet.add(DavPropertyName.CREATIONDATE); + propSet.add(DavPropertyName.GETETAG); + propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES)); + propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, + Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); + + // remote request query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), - DavConstants.PROPFIND_ALL_PROP, + propSet, DavConstants.DEPTH_1); int status = client.executeMethod(query); @@ -111,7 +132,8 @@ public class ReadRemoteFolderOperation extends RemoteOperation { Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); } else { if (result.isException()) { - Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(), result.getException()); + Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(), + result.getException()); } else { Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); } @@ -139,7 +161,8 @@ public class ReadRemoteFolderOperation extends RemoteOperation { mFolderAndFiles = new ArrayList(); // parse data from remote folder - WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getWebdavUri().getPath()); + WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], + client.getWebdavUri().getPath()); mFolderAndFiles.add(fillOCFile(we)); // loop to update every child