mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-30 01:48:14 +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.operations.RemoteOperation | ||||
| 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 timber.log.Timber | ||||
| import java.net.URL | ||||
| 
 | ||||
| class GetInstancesViaWebfingerOperation( | ||||
| class GetInstancesViaWebFingerOperation( | ||||
|     private val lockupServerDomain: String, | ||||
|     private val rel: String, | ||||
|     private val resource: String, | ||||
| @ -51,9 +51,9 @@ class GetInstancesViaWebfingerOperation( | ||||
| 
 | ||||
|     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 adapter = moshi.adapter(WebfingerJrdResponse::class.java) | ||||
|         val adapter = moshi.adapter(WebFingerResponse::class.java) | ||||
|         return adapter.fromJson(response)!! | ||||
|     } | ||||
| 
 | ||||
| @ -62,7 +62,7 @@ class GetInstancesViaWebfingerOperation( | ||||
|         response: String?, | ||||
|         status: Int | ||||
|     ): RemoteOperationResult<List<String>> { | ||||
|         Timber.e("Failed requesting webfinger info") | ||||
|         Timber.e("Failed requesting WebFinger info") | ||||
|         if (response != null) { | ||||
|             Timber.e("*** status code: $status; response message: $response") | ||||
|         } else { | ||||
| @ -73,7 +73,7 @@ class GetInstancesViaWebfingerOperation( | ||||
| 
 | ||||
|     private fun onRequestSuccessful(rawResponse: String): RemoteOperationResult<List<String>> { | ||||
|         val response = parseResponse(rawResponse) | ||||
|         Timber.d("Successful Webfinger request: $response") | ||||
|         Timber.d("Successful WebFinger request: $response") | ||||
|         val operationResult = RemoteOperationResult<List<String>>(RemoteOperationResult.ResultCode.OK) | ||||
|         operationResult.data = response.links.map { it.href } | ||||
|         return operationResult | ||||
| @ -92,7 +92,7 @@ class GetInstancesViaWebfingerOperation( | ||||
|                 onResultUnsuccessful(getMethod, response, status) | ||||
|             } | ||||
|         } catch (e: Exception) { | ||||
|             Timber.e(e, "Requesting webfinger info failed") | ||||
|             Timber.e(e, "Requesting WebFinger info failed") | ||||
|             RemoteOperationResult<List<String>>(e) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -27,13 +27,13 @@ package com.owncloud.android.lib.resources.webfinger.responses | ||||
| import com.squareup.moshi.JsonClass | ||||
| 
 | ||||
| @JsonClass(generateAdapter = true) | ||||
| data class WebfingerJrdResponse( | ||||
| data class WebFingerResponse( | ||||
|     val subject: String, | ||||
|     val links: List<LinkItem> | ||||
| ) | ||||
| 
 | ||||
| @JsonClass(generateAdapter = true) | ||||
| data class LinkItem( | ||||
|     val rel: 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.operations.RemoteOperationResult | ||||
| 
 | ||||
| interface WebfingerService { | ||||
|     fun getInstancesFromWebfinger( | ||||
| interface WebFingerService { | ||||
|     fun getInstancesFromWebFinger( | ||||
|         lookupServer: String, | ||||
|         username: String, | ||||
|         resource: String, | ||||
|         rel: String, | ||||
|         client: OwnCloudClient, | ||||
|     ): 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.operations.RemoteOperationResult | ||||
| import com.owncloud.android.lib.resources.webfinger.GetInstancesViaWebfingerOperation | ||||
| import com.owncloud.android.lib.resources.webfinger.services.WebfingerService | ||||
| import com.owncloud.android.lib.resources.webfinger.GetInstancesViaWebFingerOperation | ||||
| import com.owncloud.android.lib.resources.webfinger.services.WebFingerService | ||||
| 
 | ||||
| class OCWebfingerService : WebfingerService { | ||||
| class OCWebFingerService : WebFingerService { | ||||
| 
 | ||||
|     override fun getInstancesFromWebfinger( | ||||
|     override fun getInstancesFromWebFinger( | ||||
|         lookupServer: String, | ||||
|         username: String, | ||||
|         resource: String, | ||||
|         rel: String, | ||||
|         client: OwnCloudClient, | ||||
|     ): 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 java.io.File | ||||
| 
 | ||||
| class WebfingerResponseTest { | ||||
|     lateinit var adapter: JsonAdapter<WebfingerJrdResponse> | ||||
| class WebFingerResponseTest { | ||||
|     lateinit var adapter: JsonAdapter<WebFingerResponse> | ||||
| 
 | ||||
|     private fun loadResponses(fileName: String) = adapter.fromJson(File(fileName).readText()) | ||||
| 
 | ||||
|     @Before | ||||
|     fun prepare() { | ||||
|         val moshi = Moshi.Builder().build() | ||||
|         adapter = moshi.adapter(WebfingerJrdResponse::class.java) | ||||
|         adapter = moshi.adapter(WebFingerResponse::class.java) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user