mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Rename remote operations
This commit is contained in:
		
							parent
							
								
									3829a1ca32
								
							
						
					
					
						commit
						4f07187fa2
					
				| @ -31,7 +31,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; | ||||
| import com.owncloud.android.lib.common.operations.RemoteOperation; | ||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult; | ||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; | ||||
| import com.owncloud.android.lib.resources.server.CheckPathExistenceOperation; | ||||
| import com.owncloud.android.lib.resources.server.CheckPathExistenceRemoteOperation; | ||||
| import timber.log.Timber; | ||||
| 
 | ||||
| import java.io.File; | ||||
| @ -124,8 +124,9 @@ public class RenameRemoteFileOperation extends RemoteOperation { | ||||
|      * @return 'True' if the target path is already used by an existing file. | ||||
|      */ | ||||
|     private boolean targetPathIsUsed(OwnCloudClient client) { | ||||
|         CheckPathExistenceOperation checkPathExistenceOperation = new CheckPathExistenceOperation(mNewRemotePath, false); | ||||
|         RemoteOperationResult exists = checkPathExistenceOperation.execute(client); | ||||
|         CheckPathExistenceRemoteOperation checkPathExistenceRemoteOperation = | ||||
|                 new CheckPathExistenceRemoteOperation(mNewRemotePath, false); | ||||
|         RemoteOperationResult exists = checkPathExistenceRemoteOperation.execute(client); | ||||
|         return exists.isSuccess(); | ||||
|     } | ||||
| } | ||||
| @ -27,7 +27,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||
| import com.owncloud.android.lib.resources.status.OwnCloudVersion | ||||
| 
 | ||||
| interface AnonymousService { | ||||
|     fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Any> | ||||
|     fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> | ||||
| 
 | ||||
|     fun getRemoteStatus(path: String): RemoteOperationResult<OwnCloudVersion> | ||||
| } | ||||
|  | ||||
| @ -47,10 +47,10 @@ import java.util.concurrent.TimeUnit | ||||
|  * @param isUserLogged    When `true`, the username won't be added at the end of the PROPFIND url since is not | ||||
|  *                        needed to check user credentials | ||||
|  */ | ||||
| class CheckPathExistenceOperation( | ||||
| class CheckPathExistenceRemoteOperation( | ||||
|     val remotePath: String? = "", | ||||
|     val isUserLogged: Boolean | ||||
| ) : RemoteOperation<Any>() { | ||||
| ) : RemoteOperation<Boolean>() { | ||||
|     /** | ||||
|      * Gets the sequence of redirections followed during the execution of the operation. | ||||
|      * | ||||
| @ -59,7 +59,7 @@ class CheckPathExistenceOperation( | ||||
|     var redirectionPath: RedirectionPath? = null | ||||
|         private set | ||||
| 
 | ||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<Any> { | ||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> { | ||||
|         val previousFollowRedirects = client.followRedirects() | ||||
|         return try { | ||||
|             val stringUrl = | ||||
| @ -82,14 +82,13 @@ class CheckPathExistenceOperation( | ||||
|              * 207 MULTI_STATUS: path exists. | ||||
|              */ | ||||
|             Timber.d( | ||||
|                 "Existence check for $stringUrl${WebdavUtils.encodePath(remotePath)} finished with HTTP status $status${if (!isSuccess( | ||||
|                         status | ||||
|                 "Existence check for $stringUrl finished with HTTP status $status${if (!isSuccess(status)) "(FAIL)" else ""}" | ||||
|             ) | ||||
|                 ) "(FAIL)" else ""}" | ||||
|             ) | ||||
|             if (isSuccess(status)) RemoteOperationResult(ResultCode.OK) else RemoteOperationResult(propFindMethod) | ||||
|             if (isSuccess(status)) RemoteOperationResult<Boolean>(ResultCode.OK).apply { data = true } | ||||
|             else RemoteOperationResult<Boolean>(propFindMethod).apply { data = false } | ||||
| 
 | ||||
|         } catch (e: Exception) { | ||||
|             val result = RemoteOperationResult<Any>(e) | ||||
|             val result = RemoteOperationResult<Boolean>(e) | ||||
|             Timber.e( | ||||
|                 e, | ||||
|                 "Existence check for ${client.userFilesWebDavUri}${WebdavUtils.encodePath(remotePath)} : ${result.logMessage}" | ||||
| @ -103,7 +102,7 @@ class CheckPathExistenceOperation( | ||||
|     /** | ||||
|      * @return 'True' if the operation was executed and at least one redirection was followed. | ||||
|      */ | ||||
|     fun wasRedirected() = (redirectionPath!=null && redirectionPath!!.redirectionsCount > 0) | ||||
|     fun wasRedirected() = redirectionPath?.redirectionsCount ?: 0 > 0 | ||||
| 
 | ||||
|     private fun isSuccess(status: Int) = status == HttpConstants.HTTP_OK || status == HttpConstants.HTTP_MULTI_STATUS | ||||
| 
 | ||||
| @ -46,7 +46,7 @@ import javax.net.ssl.SSLException | ||||
|  * @author David González Verdugo | ||||
|  * @author Abel García de Prada | ||||
|  */ | ||||
| class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() { | ||||
| class GetStatusRemoteOperation : RemoteOperation<OwnCloudVersion>() { | ||||
|     private lateinit var latestResult: RemoteOperationResult<OwnCloudVersion> | ||||
| 
 | ||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<OwnCloudVersion> { | ||||
| @ -27,5 +27,5 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||||
| import com.owncloud.android.lib.resources.Service | ||||
| 
 | ||||
| interface ServerService: Service { | ||||
|     fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Any> | ||||
|     fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean> | ||||
| } | ||||
|  | ||||
| @ -45,7 +45,7 @@ import java.net.URL | ||||
|  * @author David González Verdugo | ||||
|  * @author Abel García de Prada | ||||
|  */ | ||||
| class GetRemoteUserInfoOperation : RemoteOperation<RemoteUserInfo>() { | ||||
| class GetUserInfoRemoteOperation : RemoteOperation<RemoteUserInfo>() { | ||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteUserInfo> { | ||||
|         var result: RemoteOperationResult<RemoteUserInfo> | ||||
|         //Get the user | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user