Skip to content

Commit 818bfff

Browse files
committed
Add oc/nc counterpart for remaining methods
- added classes to retrieve extended properties - moved WebdavUtils helper to Kotlin object - renamed some methods to reflect property name - adjusted nullability of attributes to better match pre-existing values - minor refactoring - added missing licences - replaced client with library licence - removed initial Dav4JVM.kt test cases Signed-off-by: ZetaTom <[email protected]>
1 parent 6bcfb3a commit 818bfff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2096
-1031
lines changed

library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt

Lines changed: 0 additions & 285 deletions
This file was deleted.

library/src/main/java/com/nextcloud/operations/PropFindMethod.kt

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,70 @@
1-
/*
2-
*
3-
* Nextcloud Android client application
4-
*
5-
* @author Tobias Kaminsky
6-
* Copyright (C) 2023 Tobias Kaminsky
7-
* Copyright (C) 2023 Nextcloud GmbH
8-
*
9-
* This program is free software: you can redistribute it and/or modify
10-
* it under the terms of the GNU Affero General Public License as published by
11-
* the Free Software Foundation, either version 3 of the License, or
12-
* (at your option) any later version.
13-
*
14-
* This program is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17-
* GNU Affero General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Affero General Public License
20-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21-
*/
1+
/* Nextcloud Android Library is available under MIT license
2+
*
3+
* @author Tobias Kaminsky
4+
* Copyright (C) 2023 Tobias Kaminsky
5+
* Copyright (C) 2023 Nextcloud GmbH
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*
26+
*/
27+
2228
package com.nextcloud.operations
2329

2430
import android.net.Uri
2531
import at.bitfire.dav4jvm.DavResource
32+
import at.bitfire.dav4jvm.Property
2633
import at.bitfire.dav4jvm.Response
2734
import com.nextcloud.common.DavMethod
2835
import com.owncloud.android.lib.common.network.WebdavUtils
2936
import com.owncloud.android.lib.common.utils.WebDavFileUtils
3037
import okhttp3.HttpUrl
3138
import okhttp3.OkHttpClient
32-
import org.apache.jackrabbit.webdav.DavConstants
3339

34-
class PropFindMethod(httpUrl: HttpUrl) : DavMethod<PropFindResult>(httpUrl) {
40+
class PropFindMethod
41+
@JvmOverloads constructor(
42+
httpUrl: HttpUrl,
43+
private val propertySet: Array<Property.Name> = WebdavUtils.PROPERTYSETS.ALL,
44+
private val depth: Int = 1
45+
) : DavMethod<PropFindResult>(httpUrl) {
46+
3547
override fun apply(client: OkHttpClient, httpUrl: HttpUrl, filesDavUri: Uri): PropFindResult {
3648
val webDavFileUtils = WebDavFileUtils()
3749
val result = PropFindResult()
3850

39-
DavResource(client, httpUrl)
40-
.propfind(
41-
DavConstants.DEPTH_1,
42-
*WebdavUtils.getAllPropertiesList()
43-
) { response: Response, hrefRelation: Response.HrefRelation? ->
44-
result.success = response.isSuccess()
51+
DavResource(client, httpUrl).propfind(
52+
depth, *propertySet
53+
) { response: Response, hrefRelation: Response.HrefRelation? ->
54+
result.success = response.isSuccess()
4555

46-
when (hrefRelation) {
47-
Response.HrefRelation.MEMBER -> result.children.add(
48-
webDavFileUtils.parseResponse(response, filesDavUri)
49-
)
56+
when (hrefRelation) {
57+
Response.HrefRelation.MEMBER -> result.children.add(
58+
webDavFileUtils.parseResponse(response, filesDavUri)
59+
)
5060

51-
Response.HrefRelation.SELF -> result.root =
52-
webDavFileUtils.parseResponse(response, filesDavUri)
61+
Response.HrefRelation.SELF -> result.root =
62+
webDavFileUtils.parseResponse(response, filesDavUri)
5363

54-
Response.HrefRelation.OTHER -> {}
55-
else -> {}
56-
}
64+
Response.HrefRelation.OTHER -> {}
65+
else -> {}
5766
}
67+
}
5868

5969
return result
6070
}

0 commit comments

Comments
 (0)