mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Updated CopyRemoteFileOperation constructor
This commit is contained in:
		
							parent
							
								
									6f12324930
								
							
						
					
					
						commit
						b281585c93
					
				| @ -24,7 +24,6 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.resources.files; | package com.owncloud.android.lib.resources.files; | ||||||
| 
 | 
 | ||||||
| import android.content.Context; |  | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
| @ -62,7 +61,6 @@ public class CopyRemoteFileOperation extends RemoteOperation { | |||||||
|     private String mTargetRemotePath; |     private String mTargetRemotePath; | ||||||
| 
 | 
 | ||||||
|     private boolean mOverwrite; |     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 srcRemotePath    Remote path of the file/folder to move. | ||||||
|      * @param targetRemotePath Remove path desired for the file/folder after moving it. |      * @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; |         mSrcRemotePath = srcRemotePath; | ||||||
|         mTargetRemotePath = targetRemotePath; |         mTargetRemotePath = targetRemotePath; | ||||||
|         mOverwrite = overwrite; |         mOverwrite = overwrite; | ||||||
| @ -108,10 +105,6 @@ public class CopyRemoteFileOperation extends RemoteOperation { | |||||||
|             return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT); |             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 |         /// perform remote operation | ||||||
|         CopyMethod copyMethod = null; |         CopyMethod copyMethod = null; | ||||||
|         RemoteOperationResult result = null; |         RemoteOperationResult result = null; | ||||||
| @ -136,6 +129,9 @@ public class CopyRemoteFileOperation extends RemoteOperation { | |||||||
|                 /// for other errors that could be explicitly handled, check first: |                 /// for other errors that could be explicitly handled, check first: | ||||||
|                 /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4 |                 /// 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 { |             } else { | ||||||
|                 result = new RemoteOperationResult( |                 result = new RemoteOperationResult( | ||||||
|                         isSuccess(status),    // copy.succeeded()? trustful? |                         isSuccess(status),    // copy.succeeded()? trustful? | ||||||
|  | |||||||
| @ -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.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.common.utils.Log_OC; |  | ||||||
| import com.owncloud.android.lib.resources.status.OwnCloudVersion; | import com.owncloud.android.lib.resources.status.OwnCloudVersion; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -137,7 +136,6 @@ public class MoveRemoteFileOperation extends RemoteOperation { | |||||||
|         	} else if (status == 400) { |         	} else if (status == 400) { | ||||||
| 				result = new RemoteOperationResult(move.succeeded(), | 				result = new RemoteOperationResult(move.succeeded(), | ||||||
| 						move.getResponseBodyAsString(), status); | 						move.getResponseBodyAsString(), status); | ||||||
| 				Log_OC.d(TAG, move.getResponseBodyAsString()); |  | ||||||
| 			} else { | 			} else { | ||||||
| 					result = new RemoteOperationResult( | 					result = new RemoteOperationResult( | ||||||
| 							isSuccess(status), 	// move.succeeded()? trustful? | 							isSuccess(status), 	// move.succeeded()? trustful? | ||||||
|  | |||||||
| @ -277,7 +277,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy file |         // copy file | ||||||
|         CopyRemoteFileOperation copyOperation = new CopyRemoteFileOperation( |         CopyRemoteFileOperation copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_1, |                 SRC_PATH_TO_FILE_1, | ||||||
|                 TARGET_PATH_TO_FILE_1, |                 TARGET_PATH_TO_FILE_1, | ||||||
|                 false |                 false | ||||||
| @ -287,7 +286,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy & rename file, different location |         // copy & rename file, different location | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_2, |                 SRC_PATH_TO_FILE_2, | ||||||
|                 TARGET_PATH_TO_FILE_2_RENAMED, |                 TARGET_PATH_TO_FILE_2_RENAMED, | ||||||
|                 false |                 false | ||||||
| @ -297,7 +295,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy & rename file, same location (rename file) |         // copy & rename file, same location (rename file) | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_3, |                 SRC_PATH_TO_FILE_3, | ||||||
|                 SRC_PATH_TO_FILE_3_RENAMED, |                 SRC_PATH_TO_FILE_3_RENAMED, | ||||||
|                 false |                 false | ||||||
| @ -307,7 +304,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy empty folder |         // copy empty folder | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_EMPTY_FOLDER, |                 SRC_PATH_TO_EMPTY_FOLDER, | ||||||
|                 TARGET_PATH_TO_EMPTY_FOLDER, |                 TARGET_PATH_TO_EMPTY_FOLDER, | ||||||
|                 false |                 false | ||||||
| @ -317,7 +313,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy non-empty folder |         // copy non-empty folder | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FULL_FOLDER_1, |                 SRC_PATH_TO_FULL_FOLDER_1, | ||||||
|                 TARGET_PATH_TO_FULL_FOLDER_1, |                 TARGET_PATH_TO_FULL_FOLDER_1, | ||||||
|                 false |                 false | ||||||
| @ -327,7 +322,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy & rename folder, different location |         // copy & rename folder, different location | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FULL_FOLDER_2, |                 SRC_PATH_TO_FULL_FOLDER_2, | ||||||
|                 TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, |                 TARGET_PATH_TO_FULL_FOLDER_2_RENAMED, | ||||||
|                 false |                 false | ||||||
| @ -337,7 +331,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy & rename folder, same location (rename folder) |         // copy & rename folder, same location (rename folder) | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FULL_FOLDER_3, |                 SRC_PATH_TO_FULL_FOLDER_3, | ||||||
|                 SRC_PATH_TO_FULL_FOLDER_3_RENAMED, |                 SRC_PATH_TO_FULL_FOLDER_3_RENAMED, | ||||||
|                 false |                 false | ||||||
| @ -347,7 +340,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy for nothing (success, but no interaction with network) |         // copy for nothing (success, but no interaction with network) | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_4, |                 SRC_PATH_TO_FILE_4, | ||||||
|                 SRC_PATH_TO_FILE_4, |                 SRC_PATH_TO_FILE_4, | ||||||
|                 false |                 false | ||||||
| @ -357,7 +349,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy overwriting |         // copy overwriting | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FULL_FOLDER_4, |                 SRC_PATH_TO_FULL_FOLDER_4, | ||||||
|                 TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, |                 TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4, | ||||||
|                 true |                 true | ||||||
| @ -370,7 +361,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // file to copy does not exist |         // file to copy does not exist | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_NON_EXISTENT_FILE, |                 SRC_PATH_TO_NON_EXISTENT_FILE, | ||||||
|                 TARGET_PATH_TO_NON_EXISTENT_FILE, |                 TARGET_PATH_TO_NON_EXISTENT_FILE, | ||||||
|                 false |                 false | ||||||
| @ -380,7 +370,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // folder to copy into does no exist |         // folder to copy into does no exist | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_5, |                 SRC_PATH_TO_FILE_5, | ||||||
|                 TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, |                 TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER, | ||||||
|                 false |                 false | ||||||
| @ -390,7 +379,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // target location (renaming) has invalid characters |         // target location (renaming) has invalid characters | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_6, |                 SRC_PATH_TO_FILE_6, | ||||||
|                 TARGET_PATH_RENAMED_WITH_INVALID_CHARS, |                 TARGET_PATH_RENAMED_WITH_INVALID_CHARS, | ||||||
|                 false |                 false | ||||||
| @ -400,7 +388,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // name collision |         // name collision | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_PATH_TO_FILE_1, |                 SRC_PATH_TO_FILE_1, | ||||||
|                 TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, |                 TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7, | ||||||
|                 false |                 false | ||||||
| @ -410,7 +397,6 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
|         // copy a folder into a descendant |         // copy a folder into a descendant | ||||||
|         copyOperation = new CopyRemoteFileOperation( |         copyOperation = new CopyRemoteFileOperation( | ||||||
|                 getContext(), |  | ||||||
|                 SRC_BASE_FOLDER, |                 SRC_BASE_FOLDER, | ||||||
|                 SRC_PATH_TO_EMPTY_FOLDER, |                 SRC_PATH_TO_EMPTY_FOLDER, | ||||||
|                 false |                 false | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user