mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Rename WebFinger classes to make them consistent
This commit is contained in:
		
							parent
							
								
									0017079a69
								
							
						
					
					
						commit
						ff90598a2d
					
				| @ -31,12 +31,12 @@ import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod | |||||||
| import com.owncloud.android.lib.common.http.methods.nonwebdav.HttpMethod | import com.owncloud.android.lib.common.http.methods.nonwebdav.HttpMethod | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperation | import com.owncloud.android.lib.common.operations.RemoteOperation | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||||
| import com.owncloud.android.lib.resources.webfinger.responses.WebfingerJrdResponse | import com.owncloud.android.lib.resources.webfinger.responses.WebFingerResponse | ||||||
| import com.squareup.moshi.Moshi | import com.squareup.moshi.Moshi | ||||||
| import timber.log.Timber | import timber.log.Timber | ||||||
| import java.net.URL | import java.net.URL | ||||||
| 
 | 
 | ||||||
| class GetInstancesViaWebfingerOperation( | class GetInstancesViaWebFingerOperation( | ||||||
|     private val lockupServerDomain: String, |     private val lockupServerDomain: String, | ||||||
|     private val rel: String, |     private val rel: String, | ||||||
|     private val resource: String, |     private val resource: String, | ||||||
| @ -51,9 +51,9 @@ class GetInstancesViaWebfingerOperation( | |||||||
| 
 | 
 | ||||||
|     private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK |     private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK | ||||||
| 
 | 
 | ||||||
|     private fun parseResponse(response: String): WebfingerJrdResponse { |     private fun parseResponse(response: String): WebFingerResponse { | ||||||
|         val moshi = Moshi.Builder().build() |         val moshi = Moshi.Builder().build() | ||||||
|         val adapter = moshi.adapter(WebfingerJrdResponse::class.java) |         val adapter = moshi.adapter(WebFingerResponse::class.java) | ||||||
|         return adapter.fromJson(response)!! |         return adapter.fromJson(response)!! | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -62,7 +62,7 @@ class GetInstancesViaWebfingerOperation( | |||||||
|         response: String?, |         response: String?, | ||||||
|         status: Int |         status: Int | ||||||
|     ): RemoteOperationResult<List<String>> { |     ): RemoteOperationResult<List<String>> { | ||||||
|         Timber.e("Failed requesting webfinger info") |         Timber.e("Failed requesting WebFinger info") | ||||||
|         if (response != null) { |         if (response != null) { | ||||||
|             Timber.e("*** status code: $status; response message: $response") |             Timber.e("*** status code: $status; response message: $response") | ||||||
|         } else { |         } else { | ||||||
| @ -73,7 +73,7 @@ class GetInstancesViaWebfingerOperation( | |||||||
| 
 | 
 | ||||||
|     private fun onRequestSuccessful(rawResponse: String): RemoteOperationResult<List<String>> { |     private fun onRequestSuccessful(rawResponse: String): RemoteOperationResult<List<String>> { | ||||||
|         val response = parseResponse(rawResponse) |         val response = parseResponse(rawResponse) | ||||||
|         Timber.d("Successful Webfinger request: $response") |         Timber.d("Successful WebFinger request: $response") | ||||||
|         val operationResult = RemoteOperationResult<List<String>>(RemoteOperationResult.ResultCode.OK) |         val operationResult = RemoteOperationResult<List<String>>(RemoteOperationResult.ResultCode.OK) | ||||||
|         operationResult.data = response.links.map { it.href } |         operationResult.data = response.links.map { it.href } | ||||||
|         return operationResult |         return operationResult | ||||||
| @ -92,7 +92,7 @@ class GetInstancesViaWebfingerOperation( | |||||||
|                 onResultUnsuccessful(getMethod, response, status) |                 onResultUnsuccessful(getMethod, response, status) | ||||||
|             } |             } | ||||||
|         } catch (e: Exception) { |         } catch (e: Exception) { | ||||||
|             Timber.e(e, "Requesting webfinger info failed") |             Timber.e(e, "Requesting WebFinger info failed") | ||||||
|             RemoteOperationResult<List<String>>(e) |             RemoteOperationResult<List<String>>(e) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -27,13 +27,13 @@ package com.owncloud.android.lib.resources.webfinger.responses | |||||||
| import com.squareup.moshi.JsonClass | import com.squareup.moshi.JsonClass | ||||||
| 
 | 
 | ||||||
| @JsonClass(generateAdapter = true) | @JsonClass(generateAdapter = true) | ||||||
| data class WebfingerJrdResponse( | data class WebFingerResponse( | ||||||
|     val subject: String, |     val subject: String, | ||||||
|     val links: List<LinkItem> |     val links: List<LinkItem> | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @JsonClass(generateAdapter = true) | @JsonClass(generateAdapter = true) | ||||||
| data class LinkItem( | data class LinkItem( | ||||||
|  |     val rel: String, | ||||||
|     val href: String, |     val href: String, | ||||||
|     val rel: String |  | ||||||
| ) | ) | ||||||
|  | |||||||
| @ -20,10 +20,10 @@ package com.owncloud.android.lib.resources.webfinger.services | |||||||
| import com.owncloud.android.lib.common.OwnCloudClient | import com.owncloud.android.lib.common.OwnCloudClient | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||||
| 
 | 
 | ||||||
| interface WebfingerService { | interface WebFingerService { | ||||||
|     fun getInstancesFromWebfinger( |     fun getInstancesFromWebFinger( | ||||||
|         lookupServer: String, |         lookupServer: String, | ||||||
|         username: String, |         resource: String, | ||||||
|         rel: String, |         rel: String, | ||||||
|         client: OwnCloudClient, |         client: OwnCloudClient, | ||||||
|     ): RemoteOperationResult<List<String>> |     ): RemoteOperationResult<List<String>> | ||||||
|  | |||||||
| @ -19,16 +19,16 @@ package com.owncloud.android.lib.resources.webfinger.services.implementation | |||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient | import com.owncloud.android.lib.common.OwnCloudClient | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||||
| import com.owncloud.android.lib.resources.webfinger.GetInstancesViaWebfingerOperation | import com.owncloud.android.lib.resources.webfinger.GetInstancesViaWebFingerOperation | ||||||
| import com.owncloud.android.lib.resources.webfinger.services.WebfingerService | import com.owncloud.android.lib.resources.webfinger.services.WebFingerService | ||||||
| 
 | 
 | ||||||
| class OCWebfingerService : WebfingerService { | class OCWebFingerService : WebFingerService { | ||||||
| 
 | 
 | ||||||
|     override fun getInstancesFromWebfinger( |     override fun getInstancesFromWebFinger( | ||||||
|         lookupServer: String, |         lookupServer: String, | ||||||
|         username: String, |         resource: String, | ||||||
|         rel: String, |         rel: String, | ||||||
|         client: OwnCloudClient, |         client: OwnCloudClient, | ||||||
|     ): RemoteOperationResult<List<String>> = |     ): RemoteOperationResult<List<String>> = | ||||||
|         GetInstancesViaWebfingerOperation(lookupServer, rel, username).execute(client) |         GetInstancesViaWebFingerOperation(lookupServer, rel, resource).execute(client) | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,15 +8,15 @@ import org.junit.Before | |||||||
| import org.junit.Test | import org.junit.Test | ||||||
| import java.io.File | import java.io.File | ||||||
| 
 | 
 | ||||||
| class WebfingerResponseTest { | class WebFingerResponseTest { | ||||||
|     lateinit var adapter: JsonAdapter<WebfingerJrdResponse> |     lateinit var adapter: JsonAdapter<WebFingerResponse> | ||||||
| 
 | 
 | ||||||
|     private fun loadResponses(fileName: String) = adapter.fromJson(File(fileName).readText()) |     private fun loadResponses(fileName: String) = adapter.fromJson(File(fileName).readText()) | ||||||
| 
 | 
 | ||||||
|     @Before |     @Before | ||||||
|     fun prepare() { |     fun prepare() { | ||||||
|         val moshi = Moshi.Builder().build() |         val moshi = Moshi.Builder().build() | ||||||
|         adapter = moshi.adapter(WebfingerJrdResponse::class.java) |         adapter = moshi.adapter(WebFingerResponse::class.java) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user