From b1286fb92a935dfd8a356aa80982e6bf21c9974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Mon, 16 Jan 2023 15:32:44 +0100 Subject: [PATCH] Adapt the propfind to work with specific webdavurl from the space --- .../lib/resources/files/ReadRemoteFolderOperation.kt | 11 +++++++++-- .../lib/resources/files/services/FileService.kt | 3 ++- .../files/services/implementation/OCFileService.kt | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.kt index 40747ace..ee0b0a03 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.kt @@ -48,7 +48,8 @@ import java.net.URL * @author David González Verdugo */ class ReadRemoteFolderOperation( - val remotePath: String + val remotePath: String, + val spaceWebDavUrl: String? = null, ) : RemoteOperation>() { /** @@ -61,7 +62,7 @@ class ReadRemoteFolderOperation( PropertyRegistry.register(OCShareTypes.Factory()) val propfindMethod = PropfindMethod( - URL(client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(remotePath)), + getFinalWebDavUrl(), DavConstants.DEPTH_1, DavUtils.allPropset ) @@ -107,5 +108,11 @@ class ReadRemoteFolderOperation( } } + private fun getFinalWebDavUrl(): URL { + val baseWebDavUrl = spaceWebDavUrl ?: client.userFilesWebDavUri.toString() + + return URL(baseWebDavUrl + WebdavUtils.encodePath(remotePath)) + } + private fun isSuccess(status: Int): Boolean = status.isOneOf(HTTP_OK, HTTP_MULTI_STATUS) } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt index 51a85c46..4798f234 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/FileService.kt @@ -61,7 +61,8 @@ interface FileService : Service { ): RemoteOperationResult fun refreshFolder( - remotePath: String + remotePath: String, + spaceWebDavUrl: String? = null, ): RemoteOperationResult> fun removeFile( diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt index 32ac22ca..037e5ef2 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/services/implementation/OCFileService.kt @@ -98,10 +98,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService { ).execute(client) override fun refreshFolder( - remotePath: String + remotePath: String, + spaceWebDavUrl: String?, ): RemoteOperationResult> = ReadRemoteFolderOperation( - remotePath = remotePath + remotePath = remotePath, + spaceWebDavUrl = spaceWebDavUrl, ).execute(client) override fun removeFile(