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);