mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Move network operation adapted to spaces
This commit is contained in:
		
							parent
							
								
									b65efc2b69
								
							
						
					
					
						commit
						e9f291371d
					
				| @ -1,5 +1,5 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /* ownCloud Android Library is available under MIT license | ||||||
| *   Copyright (C) 2020 ownCloud GmbH. | *   Copyright (C) 2023 ownCloud GmbH. | ||||||
| * | * | ||||||
| *   Permission is hereby granted, free of charge, to any person obtaining a copy | *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
| *   of this software and associated documentation files (the "Software"), to deal | *   of this software and associated documentation files (the "Software"), to deal | ||||||
| @ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit | |||||||
|  * @author David A. Velasco |  * @author David A. Velasco | ||||||
|  * @author David González Verdugo |  * @author David González Verdugo | ||||||
|  * @author Abel García de Prada |  * @author Abel García de Prada | ||||||
|  |  * @author Juan Carlos Garrote Gascón | ||||||
|  * |  * | ||||||
|  * @param remotePath      Path to append to the URL owned by the client instance. |  * @param remotePath      Path to append to the URL owned by the client instance. | ||||||
|  * @param isUserLoggedIn    When `true`, the username won't be added at the end of the PROPFIND url since is not |  * @param isUserLoggedIn    When `true`, the username won't be added at the end of the PROPFIND url since is not | ||||||
| @ -48,21 +49,23 @@ import java.util.concurrent.TimeUnit | |||||||
|  */ |  */ | ||||||
| class CheckPathExistenceRemoteOperation( | class CheckPathExistenceRemoteOperation( | ||||||
|     val remotePath: String? = "", |     val remotePath: String? = "", | ||||||
|     val isUserLoggedIn: Boolean |     val isUserLoggedIn: Boolean, | ||||||
|  |     val spaceWebDavUrl: String? = null, | ||||||
| ) : RemoteOperation<Boolean>() { | ) : RemoteOperation<Boolean>() { | ||||||
| 
 | 
 | ||||||
|     override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> { |     override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> { | ||||||
|         return try { |         val baseStringUrl = spaceWebDavUrl ?: | ||||||
|             val stringUrl = |  | ||||||
|         if (isUserLoggedIn) client.baseFilesWebDavUri.toString() |         if (isUserLoggedIn) client.baseFilesWebDavUri.toString() | ||||||
|                 else client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(remotePath) |         else client.userFilesWebDavUri.toString() | ||||||
|  |         val stringUrl = baseStringUrl + WebdavUtils.encodePath(remotePath) | ||||||
| 
 | 
 | ||||||
|  |         return try { | ||||||
|             val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropset).apply { |             val propFindMethod = PropfindMethod(URL(stringUrl), 0, allPropset).apply { | ||||||
|                 setReadTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) |                 setReadTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) | ||||||
|                 setConnectionTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) |                 setConnectionTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             var status = client.executeHttpMethod(propFindMethod) |             val status = client.executeHttpMethod(propFindMethod) | ||||||
|             /* PROPFIND method |             /* PROPFIND method | ||||||
|              * 404 NOT FOUND: path doesn't exist, |              * 404 NOT FOUND: path doesn't exist, | ||||||
|              * 207 MULTI_STATUS: path exists. |              * 207 MULTI_STATUS: path exists. | ||||||
| @ -77,7 +80,7 @@ class CheckPathExistenceRemoteOperation( | |||||||
|             val result = RemoteOperationResult<Boolean>(e) |             val result = RemoteOperationResult<Boolean>(e) | ||||||
|             Timber.e( |             Timber.e( | ||||||
|                 e, |                 e, | ||||||
|                 "Existence check for ${client.userFilesWebDavUri}${WebdavUtils.encodePath(remotePath)} : ${result.logMessage}" |                 "Existence check for $stringUrl : ${result.logMessage}" | ||||||
|             ) |             ) | ||||||
|             result |             result | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /* ownCloud Android Library is available under MIT license | ||||||
|  *   Copyright (C) 2021 ownCloud GmbH. |  *   Copyright (C) 2023 ownCloud GmbH. | ||||||
|  * |  * | ||||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy |  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  *   of this software and associated documentation files (the "Software"), to deal |  *   of this software and associated documentation files (the "Software"), to deal | ||||||
| @ -38,17 +38,22 @@ import java.util.concurrent.TimeUnit | |||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Remote operation moving a remote file or folder in the ownCloud server to a different folder |  * Remote operation moving a remote file or folder in the ownCloud server to a different folder | ||||||
|  * in the same account. |  * in the same account and space. | ||||||
|  * |  * | ||||||
|  * Allows renaming the moving file/folder at the same time. |  * Allows renaming the moving file/folder at the same time. | ||||||
|  * |  * | ||||||
|  * @author David A. Velasco |  * @author David A. Velasco | ||||||
|  * @author David González Verdugo |  * @author David González Verdugo | ||||||
|  * @author Abel García de Prada |  * @author Abel García de Prada | ||||||
|  |  * @author Juan Carlos Garrote Gascón | ||||||
|  |  * | ||||||
|  |  * @param sourceRemotePath  Remote path of the file/folder to copy. | ||||||
|  |  * @param targetRemotePath  Remote path desired for the file/folder to copy it. | ||||||
|  */ |  */ | ||||||
| open class MoveRemoteFileOperation( | open class MoveRemoteFileOperation( | ||||||
|     private val sourceRemotePath: String, |     private val sourceRemotePath: String, | ||||||
|     private val targetRemotePath: String, |     private val targetRemotePath: String, | ||||||
|  |     private val spaceWebDavUrl: String? = null, | ||||||
| ) : RemoteOperation<Unit>() { | ) : RemoteOperation<Unit>() { | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -73,8 +78,8 @@ open class MoveRemoteFileOperation( | |||||||
|             // so this uri has to be customizable |             // so this uri has to be customizable | ||||||
|             val srcWebDavUri = getSrcWebDavUriForClient(client) |             val srcWebDavUri = getSrcWebDavUriForClient(client) | ||||||
|             val moveMethod = MoveMethod( |             val moveMethod = MoveMethod( | ||||||
|                 url = URL(srcWebDavUri.toString() + WebdavUtils.encodePath(sourceRemotePath)), |                 url = URL((spaceWebDavUrl ?: srcWebDavUri.toString()) + WebdavUtils.encodePath(sourceRemotePath)), | ||||||
|                 destinationUrl = client.userFilesWebDavUri.toString() + WebdavUtils.encodePath(targetRemotePath), |                 destinationUrl = (spaceWebDavUrl ?: client.userFilesWebDavUri.toString()) + WebdavUtils.encodePath(targetRemotePath), | ||||||
|             ).apply { |             ).apply { | ||||||
|                 addRequestHeaders(this) |                 addRequestHeaders(this) | ||||||
|                 setReadTimeout(MOVE_READ_TIMEOUT, TimeUnit.SECONDS) |                 setReadTimeout(MOVE_READ_TIMEOUT, TimeUnit.SECONDS) | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /* ownCloud Android Library is available under MIT license | ||||||
|  *   Copyright (C) 2020 ownCloud GmbH. |  *   Copyright (C) 2023 ownCloud GmbH. | ||||||
|  * |  * | ||||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy |  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  *   of this software and associated documentation files (the "Software"), to deal |  *   of this software and associated documentation files (the "Software"), to deal | ||||||
| @ -32,7 +32,8 @@ interface FileService : Service { | |||||||
| 
 | 
 | ||||||
|     fun checkPathExistence( |     fun checkPathExistence( | ||||||
|         path: String, |         path: String, | ||||||
|         isUserLogged: Boolean |         isUserLogged: Boolean, | ||||||
|  |         spaceWebDavUrl: String? = null, | ||||||
|     ): RemoteOperationResult<Boolean> |     ): RemoteOperationResult<Boolean> | ||||||
| 
 | 
 | ||||||
|     fun copyFile( |     fun copyFile( | ||||||
| @ -55,6 +56,7 @@ interface FileService : Service { | |||||||
|     fun moveFile( |     fun moveFile( | ||||||
|         sourceRemotePath: String, |         sourceRemotePath: String, | ||||||
|         targetRemotePath: String, |         targetRemotePath: String, | ||||||
|  |         spaceWebDavUrl: String?, | ||||||
|     ): RemoteOperationResult<Unit> |     ): RemoteOperationResult<Unit> | ||||||
| 
 | 
 | ||||||
|     fun readFile( |     fun readFile( | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| /* ownCloud Android Library is available under MIT license | /* ownCloud Android Library is available under MIT license | ||||||
|  *   Copyright (C) 2022 ownCloud GmbH. |  *   Copyright (C) 2023 ownCloud GmbH. | ||||||
|  * |  * | ||||||
|  *   Permission is hereby granted, free of charge, to any person obtaining a copy |  *   Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
|  *   of this software and associated documentation files (the "Software"), to deal |  *   of this software and associated documentation files (the "Software"), to deal | ||||||
| @ -42,11 +42,13 @@ class OCFileService(override val client: OwnCloudClient) : FileService { | |||||||
| 
 | 
 | ||||||
|     override fun checkPathExistence( |     override fun checkPathExistence( | ||||||
|         path: String, |         path: String, | ||||||
|         isUserLogged: Boolean |         isUserLogged: Boolean, | ||||||
|  |         spaceWebDavUrl: String?, | ||||||
|     ): RemoteOperationResult<Boolean> = |     ): RemoteOperationResult<Boolean> = | ||||||
|         CheckPathExistenceRemoteOperation( |         CheckPathExistenceRemoteOperation( | ||||||
|             remotePath = path, |             remotePath = path, | ||||||
|             isUserLoggedIn = isUserLogged |             isUserLoggedIn = isUserLogged, | ||||||
|  |             spaceWebDavUrl = spaceWebDavUrl, | ||||||
|         ).execute(client) |         ).execute(client) | ||||||
| 
 | 
 | ||||||
|     override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String> = |     override fun getUrlToOpenInWeb(openWebEndpoint: String, fileId: String): RemoteOperationResult<String> = | ||||||
| @ -86,10 +88,12 @@ class OCFileService(override val client: OwnCloudClient) : FileService { | |||||||
|     override fun moveFile( |     override fun moveFile( | ||||||
|         sourceRemotePath: String, |         sourceRemotePath: String, | ||||||
|         targetRemotePath: String, |         targetRemotePath: String, | ||||||
|  |         spaceWebDavUrl: String?, | ||||||
|     ): RemoteOperationResult<Unit> = |     ): RemoteOperationResult<Unit> = | ||||||
|         MoveRemoteFileOperation( |         MoveRemoteFileOperation( | ||||||
|             sourceRemotePath = sourceRemotePath, |             sourceRemotePath = sourceRemotePath, | ||||||
|             targetRemotePath = targetRemotePath, |             targetRemotePath = targetRemotePath, | ||||||
|  |             spaceWebDavUrl = spaceWebDavUrl, | ||||||
|         ).execute(client) |         ).execute(client) | ||||||
| 
 | 
 | ||||||
|     override fun readFile( |     override fun readFile( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user