mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 08:26:10 +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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
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 timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
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.
|
* @return 'True' if the target path is already used by an existing file.
|
||||||
*/
|
*/
|
||||||
private boolean targetPathIsUsed(OwnCloudClient client) {
|
private boolean targetPathIsUsed(OwnCloudClient client) {
|
||||||
CheckPathExistenceOperation checkPathExistenceOperation = new CheckPathExistenceOperation(mNewRemotePath, false);
|
CheckPathExistenceRemoteOperation checkPathExistenceRemoteOperation =
|
||||||
RemoteOperationResult exists = checkPathExistenceOperation.execute(client);
|
new CheckPathExistenceRemoteOperation(mNewRemotePath, false);
|
||||||
|
RemoteOperationResult exists = checkPathExistenceRemoteOperation.execute(client);
|
||||||
return exists.isSuccess();
|
return exists.isSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
|||||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||||
|
|
||||||
interface AnonymousService {
|
interface AnonymousService {
|
||||||
fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Any>
|
fun checkPathExistence(path: String, isUserLogged: Boolean): RemoteOperationResult<Boolean>
|
||||||
|
|
||||||
fun getRemoteStatus(path: String): RemoteOperationResult<OwnCloudVersion>
|
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
|
* @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
|
* needed to check user credentials
|
||||||
*/
|
*/
|
||||||
class CheckPathExistenceOperation(
|
class CheckPathExistenceRemoteOperation(
|
||||||
val remotePath: String? = "",
|
val remotePath: String? = "",
|
||||||
val isUserLogged: Boolean
|
val isUserLogged: Boolean
|
||||||
) : RemoteOperation<Any>() {
|
) : RemoteOperation<Boolean>() {
|
||||||
/**
|
/**
|
||||||
* Gets the sequence of redirections followed during the execution of the operation.
|
* Gets the sequence of redirections followed during the execution of the operation.
|
||||||
*
|
*
|
||||||
@ -59,7 +59,7 @@ class CheckPathExistenceOperation(
|
|||||||
var redirectionPath: RedirectionPath? = null
|
var redirectionPath: RedirectionPath? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<Any> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<Boolean> {
|
||||||
val previousFollowRedirects = client.followRedirects()
|
val previousFollowRedirects = client.followRedirects()
|
||||||
return try {
|
return try {
|
||||||
val stringUrl =
|
val stringUrl =
|
||||||
@ -82,14 +82,13 @@ class CheckPathExistenceOperation(
|
|||||||
* 207 MULTI_STATUS: path exists.
|
* 207 MULTI_STATUS: path exists.
|
||||||
*/
|
*/
|
||||||
Timber.d(
|
Timber.d(
|
||||||
"Existence check for $stringUrl${WebdavUtils.encodePath(remotePath)} finished with HTTP status $status${if (!isSuccess(
|
"Existence check for $stringUrl finished with HTTP status $status${if (!isSuccess(status)) "(FAIL)" else ""}"
|
||||||
status
|
|
||||||
)
|
)
|
||||||
) "(FAIL)" else ""}"
|
if (isSuccess(status)) RemoteOperationResult<Boolean>(ResultCode.OK).apply { data = true }
|
||||||
)
|
else RemoteOperationResult<Boolean>(propFindMethod).apply { data = false }
|
||||||
if (isSuccess(status)) RemoteOperationResult(ResultCode.OK) else RemoteOperationResult(propFindMethod)
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
val result = RemoteOperationResult<Any>(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 ${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.
|
* @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
|
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 David González Verdugo
|
||||||
* @author Abel García de Prada
|
* @author Abel García de Prada
|
||||||
*/
|
*/
|
||||||
class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() {
|
class GetStatusRemoteOperation : RemoteOperation<OwnCloudVersion>() {
|
||||||
private lateinit var latestResult: RemoteOperationResult<OwnCloudVersion>
|
private lateinit var latestResult: RemoteOperationResult<OwnCloudVersion>
|
||||||
|
|
||||||
override fun run(client: OwnCloudClient): 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
|
import com.owncloud.android.lib.resources.Service
|
||||||
|
|
||||||
interface ServerService: 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 David González Verdugo
|
||||||
* @author Abel García de Prada
|
* @author Abel García de Prada
|
||||||
*/
|
*/
|
||||||
class GetRemoteUserInfoOperation : RemoteOperation<RemoteUserInfo>() {
|
class GetUserInfoRemoteOperation : RemoteOperation<RemoteUserInfo>() {
|
||||||
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteUserInfo> {
|
override fun run(client: OwnCloudClient): RemoteOperationResult<RemoteUserInfo> {
|
||||||
var result: RemoteOperationResult<RemoteUserInfo>
|
var result: RemoteOperationResult<RemoteUserInfo>
|
||||||
//Get the user
|
//Get the user
|
Loading…
x
Reference in New Issue
Block a user