From b281585c93a7eec52e467f51850811f8b0a92955 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Tue, 18 Aug 2015 13:27:44 +0200 Subject: [PATCH] Updated CopyRemoteFileOperation constructor --- .../resources/files/CopyRemoteFileOperation.java | 12 ++++-------- .../resources/files/MoveRemoteFileOperation.java | 2 -- .../lib/test_project/test/CopyFileTest.java | 14 -------------- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java index bd7f118e..f9f9d346 100644 --- a/src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java @@ -24,7 +24,6 @@ package com.owncloud.android.lib.resources.files; -import android.content.Context; import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; @@ -62,7 +61,6 @@ public class CopyRemoteFileOperation extends RemoteOperation { private String mTargetRemotePath; private boolean mOverwrite; - private Context mContext; /** @@ -73,9 +71,8 @@ public class CopyRemoteFileOperation extends RemoteOperation { * @param srcRemotePath Remote path of the file/folder to move. * @param targetRemotePath Remove path desired for the file/folder after moving it. */ - public CopyRemoteFileOperation(Context context, String srcRemotePath, String targetRemotePath, boolean overwrite + public CopyRemoteFileOperation(String srcRemotePath, String targetRemotePath, boolean overwrite ) { - mContext = context; mSrcRemotePath = srcRemotePath; mTargetRemotePath = targetRemotePath; mOverwrite = overwrite; @@ -108,10 +105,6 @@ public class CopyRemoteFileOperation extends RemoteOperation { return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT); } - if (!new ExistenceCheckRemoteOperation(mSrcRemotePath, mContext, Boolean.FALSE).run(getClient()).isSuccess()) { - return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); - } - /// perform remote operation CopyMethod copyMethod = null; RemoteOperationResult result = null; @@ -136,6 +129,9 @@ public class CopyRemoteFileOperation extends RemoteOperation { /// for other errors that could be explicitly handled, check first: /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4 + } else if (status == 400) { + result = new RemoteOperationResult(copyMethod.succeeded(), + copyMethod.getResponseBodyAsString(), status); } else { result = new RemoteOperationResult( isSuccess(status), // copy.succeeded()? trustful? diff --git a/src/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/src/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java index ed68535d..919b7926 100644 --- a/src/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java @@ -39,7 +39,6 @@ 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.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; @@ -137,7 +136,6 @@ public class MoveRemoteFileOperation extends RemoteOperation { } else if (status == 400) { result = new RemoteOperationResult(move.succeeded(), move.getResponseBodyAsString(), status); - Log_OC.d(TAG, move.getResponseBodyAsString()); } else { result = new RemoteOperationResult( isSuccess(status), // move.succeeded()? trustful? diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java index 2b36ddbd..468d2de1 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java @@ -277,7 +277,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy file CopyRemoteFileOperation copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_1, TARGET_PATH_TO_FILE_1, false @@ -287,7 +286,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy & rename file, different location copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_2, TARGET_PATH_TO_FILE_2_RENAMED, false @@ -297,7 +295,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy & rename file, same location (rename file) copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_3, SRC_PATH_TO_FILE_3_RENAMED, false @@ -307,7 +304,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy empty folder copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_EMPTY_FOLDER, TARGET_PATH_TO_EMPTY_FOLDER, false @@ -317,7 +313,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy non-empty folder copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FULL_FOLDER_1, TARGET_PATH_TO_FULL_FOLDER_1, false @@ -327,7 +322,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy & rename folder, different location copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FULL_FOLDER_2, TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, false @@ -337,7 +331,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy & rename folder, same location (rename folder) copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FULL_FOLDER_3, SRC_PATH_TO_FULL_FOLDER_3_RENAMED, false @@ -347,7 +340,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy for nothing (success, but no interaction with network) copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_4, SRC_PATH_TO_FILE_4, false @@ -357,7 +349,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy overwriting copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FULL_FOLDER_4, TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, true @@ -370,7 +361,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // file to copy does not exist copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_NON_EXISTENT_FILE, TARGET_PATH_TO_NON_EXISTENT_FILE, false @@ -380,7 +370,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // folder to copy into does no exist copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_5, TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, false @@ -390,7 +379,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // target location (renaming) has invalid characters copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_6, TARGET_PATH_RENAMED_WITH_INVALID_CHARS, false @@ -400,7 +388,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // name collision copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_PATH_TO_FILE_1, TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, false @@ -410,7 +397,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 // copy a folder into a descendant copyOperation = new CopyRemoteFileOperation( - getContext(), SRC_BASE_FOLDER, SRC_PATH_TO_EMPTY_FOLDER, false