Skip to content

Commit

Permalink
Add remaining dav4jvm methods: SEARCH and PROPPATCH
Browse files Browse the repository at this point in the history
Add first tests for PROPFIND

Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Oct 14, 2022
1 parent cc77f32 commit c674812
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 50 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ configurations {
dependencies {
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.10'
implementation 'com.github.bitfireAT:dav4jvm:2.1.4'
implementation 'com.github.tobiasKaminsky:dav4jvm:addSearch-SNAPSHOT'
// in transition phase, we use old and new libs
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.1'
implementation 'androidx.annotation:annotation:1.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android
Expand All @@ -35,6 +35,9 @@ import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation
import com.owncloud.android.lib.resources.shares.OCShare
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.lib.resources.status.OCCapability
import okhttp3.HttpUrl.Companion.toHttpUrl
import org.apache.jackrabbit.webdav.DavConstants
Expand All @@ -43,7 +46,10 @@ import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.IOException

class Dav4JVMtest : AbstractIT() {
/*
can be removed after fully switching to dav4jvm as other tests should cover it
*/
class Dav4JVM : AbstractIT() {
@Test
@Throws(IOException::class)
fun singlePropfind() {
Expand All @@ -61,6 +67,20 @@ class Dav4JVMtest : AbstractIT() {
// add favorite
assertTrue(ToggleFavoriteRemoteOperation(true, path).execute(client).isSuccess)

// share it
assertTrue(
CreateShareRemoteOperation(
path,
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER,
true
).execute(client)
.isSuccess
)

// do old read folder operation to compare data against it
val result = ReadFolderRemoteOperation(path).execute(client).data as List<RemoteFile>
val oldRemoteFile = result[0]
Expand Down Expand Up @@ -131,7 +151,7 @@ class Dav4JVMtest : AbstractIT() {
assertEquals(oldRemoteFile.unreadCommentsCount, remoteFile.unreadCommentsCount)
assertEquals(oldRemoteFile.isHasPreview, remoteFile.isHasPreview)
assertEquals(oldRemoteFile.note, remoteFile.note)
//assertEquals(oldRemoteFile.sharees, remoteFile.sharees)
assertEquals(oldRemoteFile.sharees.size, remoteFile.sharees.size)
assertEquals(oldRemoteFile.richWorkspace, remoteFile.richWorkspace)
assertEquals(oldRemoteFile.isLocked, remoteFile.isLocked)
assertEquals(oldRemoteFile.lockType, remoteFile.lockType)
Expand All @@ -142,21 +162,19 @@ class Dav4JVMtest : AbstractIT() {
assertEquals(oldRemoteFile.lockTimeout, remoteFile.lockTimeout)
assertEquals(oldRemoteFile.lockToken, remoteFile.lockToken)
assertEquals(oldRemoteFile.localId, remoteFile.localId)

// assertEquals(oldRemoteFile, remoteFile)
}

@Test
fun search() {
val path = "/testFolder/"

// create folder
// assertTrue(
CreateFolderRemoteOperation(
path,
true
).execute(client).isSuccess
// )
assertTrue(
CreateFolderRemoteOperation(
path,
true
).execute(client).isSuccess
)

// create file
val filePath = createFile("text")
Expand Down Expand Up @@ -210,7 +228,20 @@ class Dav4JVMtest : AbstractIT() {
}

@Test
fun proppatch() {
assertTrue(false)
fun propPatch() {
val path = "/testFolder/"

// create folder
assertTrue(CreateFolderRemoteOperation(path, true).execute(client).isSuccess)

// make it favorite
assertTrue(
ToggleFavoriteRemoteOperation(true, path).execute(nextcloudClient).isSuccess
)

val result = ReadFolderRemoteOperation(path).execute(client)
assertTrue(result.isSuccess)
val list = result.data as List<RemoteFile>
assertTrue(list[0].isFavorite)
}
}
11 changes: 5 additions & 6 deletions library/src/main/java/com/nextcloud/operations/SearchMethod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.nextcloud.operations

class SearchMethod {
}
class SearchMethod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.owncloud.android.lib.resources.files.webdav.NCMountType;
import com.owncloud.android.lib.resources.files.webdav.NCPermissions;
import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace;
import com.owncloud.android.lib.resources.files.webdav.NCSharee;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethod;
Expand Down Expand Up @@ -178,6 +179,7 @@ public static Property.Name[] getAllPropertiesList() {
list.add(CreationDate.NAME);
list.add(GetETag.NAME);
list.add(ResourceType.NAME);
list.add(NCSharee.NAME);

// list.add(NCPermission.NAME);
// list.add(OCId.NAME);
Expand Down Expand Up @@ -332,6 +334,7 @@ public static void registerCustomFactories() {
list.add(new OCOwnerId.Factory());
list.add(new OCOwnerDisplayName.Factory());
list.add(new NCRichWorkspace.Factory());
list.add(new NCSharee.Factory());

PropertyRegistry.INSTANCE.register(list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.owncloud.android.lib.resources.files.webdav.NCMountType;
import com.owncloud.android.lib.resources.files.webdav.NCPermissions;
import com.owncloud.android.lib.resources.files.webdav.NCRichWorkspace;
import com.owncloud.android.lib.resources.files.webdav.NCSharee;

import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
Expand Down Expand Up @@ -160,6 +161,10 @@ public RemoteFile parseResponse(Response response, Uri filesDavUri) {
if (property instanceof NCRichWorkspace) {
remoteFile.setRichWorkspace(((NCRichWorkspace) property).getRichWorkspace());
}

if (property instanceof NCSharee) {
remoteFile.setSharees(((NCSharee) property).getSharees());
}
}

remoteFile.setRemotePath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android.lib.resources.files.webdav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android.lib.resources.files.webdav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android.lib.resources.files.webdav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android.lib.resources.files.webdav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/

package com.owncloud.android.lib.resources.files.webdav
Expand Down
Loading

0 comments on commit c674812

Please sign in to comment.