Convert to kt

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-04-26 15:06:26 +02:00 committed by Alper Öztürk
parent 2b257fb67e
commit a690674b5d

View file

@ -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<Void> {
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<RemoteOperationResult<Void>, DeleteMethod> {
val encryptionUtilsV2 = EncryptionUtilsV2()
@ -156,31 +179,6 @@ class RemoveRemoteEncryptedFileOperation internal constructor(
return Pair(result, delete)
}
private fun deleteForV1(client: OwnCloudClient, token: String?): RemoteOperationResult<Void> {
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