From 47dfdd23961c900b0a167971acfb227b03ec3ca9 Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 4 Mar 2015 13:07:57 +0100 Subject: [PATCH 1/8] Read oc:size property in WebDavEntry --- .../lib/common/network/WebdavEntry.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/WebdavEntry.java b/src/com/owncloud/android/lib/common/network/WebdavEntry.java index d8b88fa8..2b4060c2 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavEntry.java +++ b/src/com/owncloud/android/lib/common/network/WebdavEntry.java @@ -40,9 +40,10 @@ 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"; private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId; - private long mContentLength, mCreateTimestamp, mModifiedTimestamp; + private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; public WebdavEntry(MultiStatusResponse ms, String splitElement) { resetData(); @@ -70,7 +71,8 @@ public class WebdavEntry { prop = propSet.get(DavPropertyName.GETCONTENTTYPE); if (prop != null) { mContentType = (String) prop.getValue(); - // dvelasco: some builds of ownCloud server 4.0.x added a trailing ';' to the MIME type ; if looks fixed, but let's be cautious + // dvelasco: some builds of ownCloud server 4.0.x added a trailing ';' + // to the MIME type ; if looks fixed, but let's be cautious if (mContentType.indexOf(";") >= 0) { mContentType = mContentType.substring(0, mContentType.indexOf(";")); } @@ -81,7 +83,10 @@ public class WebdavEntry { if (prop!= null) { Object value = prop.getValue(); if (value != null) { - mContentType = "DIR"; // a specific attribute would be better, but this is enough; unless while we have no reason to distinguish MIME types for folders + mContentType = "DIR"; // a specific attribute would be better, + // but this is enough; + // unless while we have no reason to distinguish + // MIME types for folders } } @@ -125,6 +130,14 @@ public class WebdavEntry { mRemoteId = prop.getValue().toString(); } + // OC size property + prop = propSet.get( + EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC) + ); + if (prop != null) { + mSize = Long.parseLong((String) prop.getValue()); + } + } else { Log_OC.e("WebdavEntry", "General fuckup, no status for webdav response"); @@ -179,8 +192,13 @@ public class WebdavEntry { return mRemoteId; } + public long size(){ + return mSize; + } + private void resetData() { mName = mUri = mContentType = mPermissions = null; mRemoteId = null; mContentLength = mCreateTimestamp = mModifiedTimestamp = 0; + mSize = 0; } } From 690e85eb930315da533ebf396b86e3928eb0df0e Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 4 Mar 2015 13:11:54 +0100 Subject: [PATCH 2/8] Add size value into RemoteFile --- .../android/lib/resources/files/RemoteFile.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/owncloud/android/lib/resources/files/RemoteFile.java b/src/com/owncloud/android/lib/resources/files/RemoteFile.java index 0db4e591..a8aa6159 100644 --- a/src/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/src/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -50,6 +50,7 @@ public class RemoteFile implements Parcelable, Serializable { private String mEtag; private String mPermissions; private String mRemoteId; + private long mSize; /** * Getters and Setters @@ -119,6 +120,14 @@ public class RemoteFile implements Parcelable, Serializable { this.mRemoteId = remoteId; } + public long getSize() { + return mSize; + } + + public void setSize (long size){ + mSize = size; + } + public RemoteFile() { resetData(); } @@ -147,6 +156,7 @@ public class RemoteFile implements Parcelable, Serializable { this.setEtag(we.etag()); this.setPermissions(we.permissions()); this.setRemoteId(we.remoteId()); + this.setSize(we.size()); } /** @@ -161,6 +171,7 @@ public class RemoteFile implements Parcelable, Serializable { mEtag = null; mPermissions = null; mRemoteId = null; + mSize = 0; } /** @@ -197,6 +208,7 @@ public class RemoteFile implements Parcelable, Serializable { mEtag = source.readString(); mPermissions= source.readString(); mRemoteId = source.readString(); + mSize = source.readLong(); } @Override @@ -214,7 +226,7 @@ public class RemoteFile implements Parcelable, Serializable { dest.writeString(mEtag); dest.writeString(mPermissions); dest.writeString(mRemoteId); + dest.writeLong(mSize); } - } From f899fbee6f8e58c8a17eab776d3a7472ab829f98 Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 4 Mar 2015 21:31:28 +0100 Subject: [PATCH 3/8] Add quota-used-bytes and quota-available-bytes to WebDavEntry --- .../lib/common/network/WebdavEntry.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/WebdavEntry.java b/src/com/owncloud/android/lib/common/network/WebdavEntry.java index 2b4060c2..db7fb383 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavEntry.java +++ b/src/com/owncloud/android/lib/common/network/WebdavEntry.java @@ -42,8 +42,12 @@ public class WebdavEntry { private static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id"; private 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"; + private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId; private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; + private long mQuotaUsedBytes, mQuotaAvailableBytes; public WebdavEntry(MultiStatusResponse ms, String splitElement) { resetData(); @@ -67,6 +71,7 @@ public class WebdavEntry { } // use unknown mimetype as default behavior + // {DAV:}getcontenttype mContentType = "application/octet-stream"; prop = propSet.get(DavPropertyName.GETCONTENTTYPE); if (prop != null) { @@ -78,7 +83,8 @@ public class WebdavEntry { } } - // check if it's a folder in the standard way: see RFC2518 12.2 . RFC4918 14.3 + // check if it's a folder in the standard way: see RFC2518 12.2 . RFC4918 14.3 + // {DAV:}resourcetype prop = propSet.get(DavPropertyName.RESOURCETYPE); if (prop!= null) { Object value = prop.getValue(); @@ -90,10 +96,12 @@ public class WebdavEntry { } } + // {DAV:}getcontentlength prop = propSet.get(DavPropertyName.GETCONTENTLENGTH); if (prop != null) mContentLength = Long.parseLong((String) prop.getValue()); + // {DAV:}getlastmodified prop = propSet.get(DavPropertyName.GETLASTMODIFIED); if (prop != null) { Date d = WebdavUtils @@ -107,13 +115,25 @@ public class WebdavEntry { .parseResponseDate((String) prop.getValue()); mCreateTimestamp = (d != null) ? d.getTime() : 0; } - + + // {DAV:}getetag prop = propSet.get(DavPropertyName.GETETAG); if (prop != null) { mEtag = (String) prop.getValue(); mEtag = mEtag.substring(1, mEtag.length()-1); } + // {DAV:}quota-used-bytes + prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_USED_BYTES)); + if (prop != null) { + mQuotaUsedBytes = Long.parseLong((String) prop.getValue()); + } + + // {DAV:}quota-available-bytes + prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_AVAILABLE_BYTES)); + if (prop != null) { + mQuotaAvailableBytes = Long.parseLong((String) prop.getValue()); + } // OC permissions property prop = propSet.get( EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC) @@ -130,6 +150,7 @@ public class WebdavEntry { mRemoteId = prop.getValue().toString(); } + // TODO: is it necessary? // OC size property prop = propSet.get( EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC) @@ -196,9 +217,19 @@ public class WebdavEntry { return mSize; } + public long quotaUsedBytes() { + return mQuotaUsedBytes; + } + + public long quotaAvailableBytes() { + return mQuotaAvailableBytes; + } + private void resetData() { mName = mUri = mContentType = mPermissions = null; mRemoteId = null; mContentLength = mCreateTimestamp = mModifiedTimestamp = 0; mSize = 0; + mQuotaUsedBytes = 0; + mQuotaAvailableBytes = 0; } } From bbe8836365fd36f15bbdf1af3a7d2a8d13d72466 Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 4 Mar 2015 21:38:22 +0100 Subject: [PATCH 4/8] Complete RemoteFile with new parameters in WebDavEntry --- .../files/ReadRemoteFolderOperation.java | 3 +++ .../lib/resources/files/RemoteFile.java | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index af92d8fe..84926b7c 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -168,6 +168,9 @@ public class ReadRemoteFolderOperation extends RemoteOperation { file.setEtag(we.etag()); file.setPermissions(we.permissions()); file.setRemoteId(we.remoteId()); + file.setSize(we.size()); + file.setQuotaUsedBytes(we.quotaUsedBytes()); + file.setQuotaAvailableBytes(we.quotaAvailableBytes()); return file; } } diff --git a/src/com/owncloud/android/lib/resources/files/RemoteFile.java b/src/com/owncloud/android/lib/resources/files/RemoteFile.java index a8aa6159..0d9bfd60 100644 --- a/src/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/src/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -51,6 +51,8 @@ public class RemoteFile implements Parcelable, Serializable { private String mPermissions; private String mRemoteId; private long mSize; + private long mQuotaUsedBytes; + private long mQuotaAvailableBytes; /** * Getters and Setters @@ -128,6 +130,14 @@ public class RemoteFile implements Parcelable, Serializable { mSize = size; } + public void setQuotaUsedBytes (long quotaUsedBytes) { + mQuotaUsedBytes = quotaUsedBytes; + } + + public void setQuotaAvailableBytes (long quotaAvailableBytes) { + mQuotaAvailableBytes = quotaAvailableBytes; + } + public RemoteFile() { resetData(); } @@ -157,6 +167,8 @@ public class RemoteFile implements Parcelable, Serializable { this.setPermissions(we.permissions()); this.setRemoteId(we.remoteId()); this.setSize(we.size()); + this.setQuotaUsedBytes(we.quotaUsedBytes()); + this.setQuotaAvailableBytes(we.quotaAvailableBytes()); } /** @@ -172,6 +184,8 @@ public class RemoteFile implements Parcelable, Serializable { mPermissions = null; mRemoteId = null; mSize = 0; + mQuotaUsedBytes = 0; + mQuotaAvailableBytes = 0; } /** @@ -209,6 +223,8 @@ public class RemoteFile implements Parcelable, Serializable { mPermissions= source.readString(); mRemoteId = source.readString(); mSize = source.readLong(); + mQuotaUsedBytes = source.readLong(); + mQuotaAvailableBytes = source.readLong(); } @Override @@ -227,6 +243,8 @@ public class RemoteFile implements Parcelable, Serializable { dest.writeString(mPermissions); dest.writeString(mRemoteId); dest.writeLong(mSize); + dest.writeLong(mQuotaUsedBytes); + dest.writeLong(mQuotaAvailableBytes); } - + } From 8edf9fdaf673cab4ed3a1e32c685477f8f5095b4 Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 5 Mar 2015 10:55:10 +0100 Subject: [PATCH 5/8] Modify requests to get the properties, adding properties specifically instead of DavConstants.PROPFIND_ALL_PROP --- .../lib/common/network/WebdavEntry.java | 12 +++---- .../files/ReadRemoteFileOperation.java | 30 ++++++++++++++++-- .../files/ReadRemoteFolderOperation.java | 31 ++++++++++++++++--- 3 files changed, 60 insertions(+), 13 deletions(-) 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 From 91e4a4415765ec4232fe775ab29f4af196821706 Mon Sep 17 00:00:00 2001 From: masensio Date: Fri, 6 Mar 2015 10:13:21 +0100 Subject: [PATCH 6/8] Fix bug: No files are shown when login in oc8.1 --- .../owncloud/android/lib/common/network/WebdavEntry.java | 5 +++++ .../owncloud/android/lib/resources/files/RemoteFile.java | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/WebdavEntry.java b/src/com/owncloud/android/lib/common/network/WebdavEntry.java index 64bc8246..e5c5b764 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavEntry.java +++ b/src/com/owncloud/android/lib/common/network/WebdavEntry.java @@ -45,6 +45,8 @@ public class WebdavEntry { public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes"; public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes"; + private static final int CODE_PROP_NOT_FOUND = 404; + private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId; private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; private long mQuotaUsedBytes, mQuotaAvailableBytes; @@ -57,6 +59,9 @@ public class WebdavEntry { mPath = mUri.split(splitElement, 2)[1]; int status = ms.getStatus()[0].getStatusCode(); + if ( status == CODE_PROP_NOT_FOUND ) { + status = ms.getStatus()[1].getStatusCode(); + } DavPropertySet propSet = ms.getProperties(status); @SuppressWarnings("rawtypes") DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME); diff --git a/src/com/owncloud/android/lib/resources/files/RemoteFile.java b/src/com/owncloud/android/lib/resources/files/RemoteFile.java index 1591f3c9..1a5d13f9 100644 --- a/src/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/src/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -39,9 +39,9 @@ import com.owncloud.android.lib.common.network.WebdavEntry; public class RemoteFile implements Parcelable, Serializable { - /** Generated - should be refreshed every time the class changes!! */ - private static final long serialVersionUID = 532139091191390616L; - + /** Generated - should be refreshed every time the class changes!! */ + private static final long serialVersionUID = 3130865437811248451L; + private String mRemotePath; private String mMimeType; private long mLength; From 2f32ffbc1f3cf5d97d5c5835b4494833506c37d8 Mon Sep 17 00:00:00 2001 From: masensio Date: Mon, 9 Mar 2015 11:34:14 +0100 Subject: [PATCH 7/8] Changes from comments in PR#55 --- .../lib/common/network/WebdavUtils.java | 54 ++++++++++++++++++- .../files/ReadRemoteFileOperation.java | 20 +------ .../files/ReadRemoteFolderOperation.java | 20 +------ 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/WebdavUtils.java b/src/com/owncloud/android/lib/common/network/WebdavUtils.java index 7c2a1bb4..7ffa629c 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavUtils.java +++ b/src/com/owncloud/android/lib/common/network/WebdavUtils.java @@ -32,6 +32,10 @@ import java.util.Locale; import android.net.Uri; +import org.apache.jackrabbit.webdav.property.DavPropertyName; +import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; +import org.apache.jackrabbit.webdav.xml.Namespace; + public class WebdavUtils { public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat( "dd.MM.yyyy hh:mm"); @@ -78,5 +82,53 @@ public class WebdavUtils { encodedPath = "/" + encodedPath; return encodedPath; } - + + /** + * Builds a DavPropertyNameSet with all prop + * For using instead of DavConstants.PROPFIND_ALL_PROP + * @return + */ + public static DavPropertyNameSet getAllPropSet(){ + 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)); + + return propSet; + } + + /** + * Builds a DavPropertyNameSet with properties for files + * @return + */ + public static DavPropertyNameSet getFilePropSet(){ + 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(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)); + + return propSet; + } } diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java index d82c594f..eda5ee85 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java @@ -78,27 +78,9 @@ 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), - propSet, + WebdavUtils.getFilePropSet(), // PropFind Properties DavConstants.DEPTH_0); int status; status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT); diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index b8e5a847..3afe3e6a 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -75,27 +75,9 @@ public class ReadRemoteFolderOperation extends RemoteOperation { PropFindMethod query = null; 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 query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), - propSet, + WebdavUtils.getAllPropSet(), // PropFind Properties DavConstants.DEPTH_1); int status = client.executeMethod(query); From b36670adb14cb5c431de4af14b8af9ba7da18f7a Mon Sep 17 00:00:00 2001 From: masensio Date: Mon, 9 Mar 2015 14:19:12 +0100 Subject: [PATCH 8/8] Update imports --- src/com/owncloud/android/lib/common/network/WebdavUtils.java | 2 +- .../android/lib/resources/files/ReadRemoteFileOperation.java | 3 --- .../android/lib/resources/files/ReadRemoteFolderOperation.java | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/com/owncloud/android/lib/common/network/WebdavUtils.java b/src/com/owncloud/android/lib/common/network/WebdavUtils.java index 7ffa629c..bf2e986d 100644 --- a/src/com/owncloud/android/lib/common/network/WebdavUtils.java +++ b/src/com/owncloud/android/lib/common/network/WebdavUtils.java @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * Copyright (C) 2015 ownCloud Inc. - * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2012 Bartek Przybylski * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java index eda5ee85..12c2017f 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java @@ -29,9 +29,6 @@ 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; diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index 3afe3e6a..1e93aa22 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -30,9 +30,6 @@ 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;