Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit aebd728

Browse files
committed
Migrate DavUtils to kotlin and fix a compilation error
1 parent 7f2d94b commit aebd728

File tree

6 files changed

+48
-22
lines changed

6 files changed

+48
-22
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavUtils.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* ownCloud Android Library is available under MIT license
2+
* Copyright (C) 2020 ownCloud GmbH.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*
23+
*/
24+
package com.owncloud.android.lib.common.http.methods.webdav
25+
26+
import at.bitfire.dav4android.Property
27+
import at.bitfire.dav4android.PropertyUtils.getAllPropSet
28+
import at.bitfire.dav4android.PropertyUtils.getQuotaPropset
29+
30+
object DavUtils {
31+
@JvmStatic val allPropset: Array<Property.Name>
32+
get() = getAllPropSet()
33+
34+
val quotaPropSet: Array<Property.Name>
35+
get() = getQuotaPropset()
36+
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CheckPathExistenceRemoteOperation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package com.owncloud.android.lib.resources.files
2525

2626
import com.owncloud.android.lib.common.OwnCloudClient
2727
import com.owncloud.android.lib.common.http.HttpConstants
28-
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils.getAllPropset
28+
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils.allPropset
2929
import com.owncloud.android.lib.common.http.methods.webdav.PropfindMethod
3030
import com.owncloud.android.lib.common.network.RedirectionPath
3131
import com.owncloud.android.lib.common.network.WebdavUtils
@@ -66,7 +66,7 @@ class CheckPathExistenceRemoteOperation(
6666
if (isUserLogged) client.baseFilesWebDavUri.toString()
6767
else client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(remotePath)
6868

69-
val propFindMethod = PropfindMethod(URL(stringUrl), 0, getAllPropset()).apply {
69+
val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropset).apply {
7070
setReadTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS)
7171
setConnectionTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS)
7272
}

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.owncloud.android.lib.common.OwnCloudClient;
2727
import com.owncloud.android.lib.common.accounts.AccountUtils;
2828
import com.owncloud.android.lib.common.http.HttpConstants;
29-
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils;
3029
import com.owncloud.android.lib.common.network.WebdavUtils;
3130
import com.owncloud.android.lib.common.operations.RemoteOperation;
3231
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.owncloud.android.lib.common.accounts.AccountUtils;
3030
import com.owncloud.android.lib.common.http.HttpConstants;
3131
import com.owncloud.android.lib.common.http.methods.webdav.DavConstants;
32-
import com.owncloud.android.lib.common.http.methods.webdav.DavUtils;
3332
import com.owncloud.android.lib.common.network.WebdavUtils;
3433
import com.owncloud.android.lib.common.operations.RemoteOperation;
3534
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
5252
val propfindMethod = PropfindMethod(
5353
URL(client.userFilesWebDavUri.toString()),
5454
DavConstants.DEPTH_0,
55-
DavUtils.getQuotaPropSet()
55+
DavUtils.quotaPropSet
5656
)
5757
with(client.executeHttpMethod(propfindMethod)) {
5858
if (isSuccess(this)) {
5959
RemoteOperationResult<RemoteQuota>(ResultCode.OK).apply {
60-
data = readData(propfindMethod.root.properties)
60+
data = readData(propfindMethod.root?.properties)
6161
}.also {
6262
Timber.i("Get quota completed: ${it.data} and message: ${it.logMessage}")
6363
}
@@ -81,9 +81,16 @@ class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
8181
* @param properties WebDAV properties containing quota data
8282
* @return new [RemoteQuota] instance representing the data read from the server
8383
*/
84-
private fun readData(properties: List<Property>): RemoteQuota {
84+
private fun readData(properties: List<Property>?): RemoteQuota {
8585
var quotaAvailable: Long = 0
8686
var quotaUsed: Long = 0
87+
88+
if (properties == null) {
89+
// Should not happen
90+
Timber.d("Unable to get quota")
91+
return RemoteQuota(0, 0, 0, 0.0)
92+
}
93+
8794
for (property in properties) {
8895
if (property is QuotaAvailableBytes) {
8996
quotaAvailable = property.quotaAvailableBytes

0 commit comments

Comments
 (0)