From a690674b5db8ed97cf267b96dd86a4b0a4e9399e Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 26 Apr 2024 15:06:26 +0200 Subject: [PATCH] Convert to kt Signed-off-by: alperozturk --- .../RemoveRemoteEncryptedFileOperation.kt | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.kt b/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.kt index 862623f6b1..e55e5014bd 100644 --- a/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.kt +++ b/app/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.kt @@ -29,9 +29,7 @@ import org.apache.jackrabbit.webdav.client.methods.DeleteMethod /** * Remote operation performing the removal of a remote encrypted file or folder - */ - -/** + * * Constructor * * @param remotePath RemotePath of the remote file or folder to remove from the server @@ -124,6 +122,31 @@ class RemoveRemoteEncryptedFileOperation internal constructor( return metadata } + private fun deleteForV1(client: OwnCloudClient, token: String?): RemoteOperationResult { + val arbitraryDataProvider: ArbitraryDataProvider = ArbitraryDataProviderImpl(context) + val metadata = getMetadataV1(arbitraryDataProvider) + val (first) = deleteRemoteFile(client, token) + + val serializedMetadata: String = if (metadata.metadata.getMetadataKey() != null) { + EncryptionUtils.serializeJSON(metadata, true) + } else { + EncryptionUtils.serializeJSON(metadata) + } + + EncryptionUtils.uploadMetadata( + parentFolder, + serializedMetadata, + token, + client, + true, E2EVersion.V1_2, + "", + arbitraryDataProvider, + user + ) + + return first + } + private fun deleteForV2(client: OwnCloudClient, token: String?): Pair, DeleteMethod> { val encryptionUtilsV2 = EncryptionUtilsV2() @@ -156,31 +179,6 @@ class RemoveRemoteEncryptedFileOperation internal constructor( return Pair(result, delete) } - private fun deleteForV1(client: OwnCloudClient, token: String?): RemoteOperationResult { - val arbitraryDataProvider: ArbitraryDataProvider = ArbitraryDataProviderImpl(context) - val metadata = getMetadataV1(arbitraryDataProvider) - val (first) = deleteRemoteFile(client, token) - - val serializedMetadata: String = if (metadata.metadata.getMetadataKey() != null) { - EncryptionUtils.serializeJSON(metadata, true) - } else { - EncryptionUtils.serializeJSON(metadata) - } - - EncryptionUtils.uploadMetadata( - parentFolder, - serializedMetadata, - token, - client, - true, E2EVersion.V1_2, - "", - arbitraryDataProvider, - user - ) - - return first - } - companion object { private val TAG = RemoveRemoteEncryptedFileOperation::class.java.getSimpleName() private const val REMOVE_READ_TIMEOUT = 30000