Skip to content

Commit 6549214

Browse files
Add remaining dav4jvm methods: SEARCH and PROPPATCH
Add first tests for PROPFIND Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 0df000f commit 6549214

File tree

13 files changed

+204
-50
lines changed

13 files changed

+204
-50
lines changed

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ configurations {
5050
dependencies {
5151
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
5252
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.10'
53-
implementation 'com.github.bitfireAT:dav4jvm:2.1.4'
53+
implementation 'com.github.tobiasKaminsky:dav4jvm:addSearch-SNAPSHOT'
5454
// in transition phase, we use old and new libs
5555
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.1'
5656
implementation 'androidx.annotation:annotation:1.5.0'

library/src/androidTest/java/com/owncloud/android/Dav4JVMtest.kt renamed to library/src/androidTest/java/com/owncloud/android/Dav4JVM.kt

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android
@@ -35,6 +35,9 @@ import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation
3535
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation
3636
import com.owncloud.android.lib.resources.files.model.RemoteFile
3737
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
38+
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation
39+
import com.owncloud.android.lib.resources.shares.OCShare
40+
import com.owncloud.android.lib.resources.shares.ShareType
3841
import com.owncloud.android.lib.resources.status.OCCapability
3942
import okhttp3.HttpUrl.Companion.toHttpUrl
4043
import org.apache.jackrabbit.webdav.DavConstants
@@ -43,7 +46,10 @@ import org.junit.Assert.assertTrue
4346
import org.junit.Test
4447
import java.io.IOException
4548

46-
class Dav4JVMtest : AbstractIT() {
49+
/*
50+
can be removed after fully switching to dav4jvm as other tests should cover it
51+
*/
52+
class Dav4JVM : AbstractIT() {
4753
@Test
4854
@Throws(IOException::class)
4955
fun singlePropfind() {
@@ -61,6 +67,20 @@ class Dav4JVMtest : AbstractIT() {
6167
// add favorite
6268
assertTrue(ToggleFavoriteRemoteOperation(true, path).execute(client).isSuccess)
6369

70+
// share it
71+
assertTrue(
72+
CreateShareRemoteOperation(
73+
path,
74+
ShareType.USER,
75+
"admin",
76+
false,
77+
"",
78+
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
79+
true
80+
).execute(client)
81+
.isSuccess
82+
)
83+
6484
// do old read folder operation to compare data against it
6585
val result = ReadFolderRemoteOperation(path).execute(client).data as List<RemoteFile>
6686
val oldRemoteFile = result[0]
@@ -131,7 +151,7 @@ class Dav4JVMtest : AbstractIT() {
131151
assertEquals(oldRemoteFile.unreadCommentsCount, remoteFile.unreadCommentsCount)
132152
assertEquals(oldRemoteFile.isHasPreview, remoteFile.isHasPreview)
133153
assertEquals(oldRemoteFile.note, remoteFile.note)
134-
//assertEquals(oldRemoteFile.sharees, remoteFile.sharees)
154+
assertEquals(oldRemoteFile.sharees.size, remoteFile.sharees.size)
135155
assertEquals(oldRemoteFile.richWorkspace, remoteFile.richWorkspace)
136156
assertEquals(oldRemoteFile.isLocked, remoteFile.isLocked)
137157
assertEquals(oldRemoteFile.lockType, remoteFile.lockType)
@@ -142,21 +162,19 @@ class Dav4JVMtest : AbstractIT() {
142162
assertEquals(oldRemoteFile.lockTimeout, remoteFile.lockTimeout)
143163
assertEquals(oldRemoteFile.lockToken, remoteFile.lockToken)
144164
assertEquals(oldRemoteFile.localId, remoteFile.localId)
145-
146-
// assertEquals(oldRemoteFile, remoteFile)
147165
}
148166

149167
@Test
150168
fun search() {
151169
val path = "/testFolder/"
152170

153171
// create folder
154-
// assertTrue(
155-
CreateFolderRemoteOperation(
156-
path,
157-
true
158-
).execute(client).isSuccess
159-
// )
172+
assertTrue(
173+
CreateFolderRemoteOperation(
174+
path,
175+
true
176+
).execute(client).isSuccess
177+
)
160178

161179
// create file
162180
val filePath = createFile("text")
@@ -210,7 +228,20 @@ class Dav4JVMtest : AbstractIT() {
210228
}
211229

212230
@Test
213-
fun proppatch() {
214-
assertTrue(false)
231+
fun propPatch() {
232+
val path = "/testFolder/"
233+
234+
// create folder
235+
assertTrue(CreateFolderRemoteOperation(path, true).execute(client).isSuccess)
236+
237+
// make it favorite
238+
assertTrue(
239+
ToggleFavoriteRemoteOperation(true, path).execute(nextcloudClient).isSuccess
240+
)
241+
242+
val result = ReadFolderRemoteOperation(path).execute(client)
243+
assertTrue(result.isSuccess)
244+
val list = result.data as List<RemoteFile>
245+
assertTrue(list[0].isFavorite)
215246
}
216247
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.nextcloud.operations
2424

25-
class SearchMethod {
26-
}
25+
class SearchMethod

library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.owncloud.android.lib.resources.files.webdav.NCMountType;
3939
import com.owncloud.android.lib.resources.files.webdav.NCPermissions;
4040
import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace;
41+
import com.owncloud.android.lib.resources.files.webdav.NCSharee;
4142

4243
import org.apache.commons.httpclient.Header;
4344
import org.apache.commons.httpclient.HttpMethod;
@@ -178,6 +179,7 @@ public static Property.Name[] getAllPropertiesList() {
178179
list.add(CreationDate.NAME);
179180
list.add(GetETag.NAME);
180181
list.add(ResourceType.NAME);
182+
list.add(NCSharee.NAME);
181183

182184
// list.add(NCPermission.NAME);
183185
// list.add(OCId.NAME);
@@ -332,6 +334,7 @@ public static void registerCustomFactories() {
332334
list.add(new OCOwnerId.Factory());
333335
list.add(new OCOwnerDisplayName.Factory());
334336
list.add(new NCRichWorkspace.Factory());
337+
list.add(new NCSharee.Factory());
335338

336339
PropertyRegistry.INSTANCE.register(list);
337340
}

library/src/main/java/com/owncloud/android/lib/common/utils/WebDavFileUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.owncloud.android.lib.resources.files.webdav.NCMountType;
4141
import com.owncloud.android.lib.resources.files.webdav.NCPermissions;
4242
import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace;
43+
import com.owncloud.android.lib.resources.files.webdav.NCSharee;
4344

4445
import org.apache.jackrabbit.webdav.MultiStatus;
4546
import org.apache.jackrabbit.webdav.MultiStatusResponse;
@@ -160,6 +161,10 @@ public RemoteFile parseResponse(Response response, Uri filesDavUri) {
160161
if (property instanceof NCRichWorkspace) {
161162
remoteFile.setRichWorkspace(((NCRichWorkspace) property).getRichWorkspace());
162163
}
164+
165+
if (property instanceof NCSharee) {
166+
remoteFile.setSharees(((NCSharee) property).getSharees());
167+
}
163168
}
164169

165170
remoteFile.setRemotePath(path);

library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCEtag.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android.lib.resources.files.webdav

library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCFavorite.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android.lib.resources.files.webdav

library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCMountType.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android.lib.resources.files.webdav

library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCPermissions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android.lib.resources.files.webdav

library/src/main/java/com/owncloud/android/lib/resources/files/webdav/NCRichWorkspace.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* @author Tobias Kaminsky
55
* Copyright (C) 2022 Tobias Kaminsky
66
* Copyright (C) 2022 Nextcloud GmbH
7-
*
7+
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* This program is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Affero General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Affero General Public License
1919
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20-
*
20+
*
2121
*/
2222

2323
package com.owncloud.android.lib.resources.files.webdav

0 commit comments

Comments
 (0)