From 6e2ab7d97201eb5aab804035e6938e007a851660 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 11 Jan 2019 21:32:24 +0000 Subject: [PATCH] UserInfoManager: fix the wrong conversion to kotlin. --- .../etesync/syncadapter/journalmanager/UserInfoManager.kt | 2 +- .../java/com/etesync/syncadapter/ui/AddMemberFragment.kt | 2 +- .../syncadapter/ui/setup/SetupEncryptionFragment.kt | 2 +- .../etesync/syncadapter/ui/setup/SetupUserInfoFragment.kt | 2 +- .../com/etesync/syncadapter/journalmanager/ServiceTest.kt | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/journalmanager/UserInfoManager.kt b/app/src/main/java/com/etesync/syncadapter/journalmanager/UserInfoManager.kt index d8ae1ffd..055661f8 100644 --- a/app/src/main/java/com/etesync/syncadapter/journalmanager/UserInfoManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/journalmanager/UserInfoManager.kt @@ -19,7 +19,7 @@ class UserInfoManager(httpClient: OkHttpClient, remote: HttpUrl) : BaseManager() } @Throws(Exceptions.HttpException::class) - operator fun get(owner: String): UserInfo? { + fun fetch(owner: String): UserInfo? { val remote = this.remote!!.newBuilder().addPathSegment(owner).addPathSegment("").build() val request = Request.Builder() .get() diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AddMemberFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/AddMemberFragment.kt index 336ad510..31b73ed7 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AddMemberFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AddMemberFragment.kt @@ -60,7 +60,7 @@ class AddMemberFragment : DialogFragment() { val httpClient = HttpClient.create(ctx!!, settings!!) val userInfoManager = UserInfoManager(httpClient, remote!!) - val userInfo = userInfoManager[memberEmail] + val userInfo = userInfoManager.fetch(memberEmail) ?: throw Exception(getString(R.string.collection_members_error_user_not_found, memberEmail)) memberPubKey = userInfo.pubkey!! return AddResult(null) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupEncryptionFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupEncryptionFragment.kt index 7f13fa5b..3f54cb02 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupEncryptionFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupEncryptionFragment.kt @@ -97,7 +97,7 @@ class SetupEncryptionFragment : DialogFragment() { val httpClient = HttpClient.create(getContext(), config.url, config.authtoken!!) val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(config.url)!!) - val userInfo = userInfoManager[config.userName] + val userInfo = userInfoManager.fetch(config.userName) if (userInfo != null) { App.log.info("Fetched userInfo for " + config.userName) cryptoManager = Crypto.CryptoManager(userInfo.version!!.toInt(), config.password!!, "userInfo") diff --git a/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupUserInfoFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupUserInfoFragment.kt index 760561bd..c36a11af 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupUserInfoFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/setup/SetupUserInfoFragment.kt @@ -50,7 +50,7 @@ class SetupUserInfoFragment : DialogFragment() { val httpClient = HttpClient.create(context, settings) val userInfoManager = UserInfoManager(httpClient, HttpUrl.get(settings.uri!!)!!) - var userInfo: UserInfoManager.UserInfo? = userInfoManager[account.name] + var userInfo: UserInfoManager.UserInfo? = userInfoManager.fetch(account.name) if (userInfo == null) { App.log.info("Creating userInfo for " + account.name) diff --git a/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt b/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt index 54e47b68..2696ca81 100644 --- a/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt +++ b/app/src/test/java/com/etesync/syncadapter/journalmanager/ServiceTest.kt @@ -206,7 +206,7 @@ class ServiceTest { val manager = UserInfoManager(httpClient!!, remote!!) // Get when there's nothing - userInfo = manager[Helpers.USER] + userInfo = manager.fetch(Helpers.USER) assertNull(userInfo) // Create @@ -214,20 +214,20 @@ class ServiceTest { manager.create(userInfo) // Get - userInfo2 = manager[Helpers.USER] + userInfo2 = manager.fetch(Helpers.USER) assertNotNull(userInfo2) assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager)) // Update userInfo.setContent(cryptoManager, "test".toByteArray()) manager.update(userInfo) - userInfo2 = manager[Helpers.USER] + userInfo2 = manager.fetch(Helpers.USER) assertNotNull(userInfo2) assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager)) // Delete manager.delete(userInfo) - userInfo = manager[Helpers.USER] + userInfo = manager.fetch(Helpers.USER) assertNull(userInfo) }