Loading src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +4 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ public class CopyRemoteFileOperation extends RemoteOperation { return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT); } if (!new ExistenceCheckRemoteOperation(mSrcRemotePath, Boolean.FALSE).run(getClient()).isSuccess()) { return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); } /// perform remote operation CopyMethod copyMethod = null; RemoteOperationResult result = null; Loading src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java +16 −18 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.HeadMethod; import android.content.Context; import android.net.ConnectivityManager; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.RedirectionPath; Loading @@ -50,7 +49,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { private static final String TAG = ExistenceCheckRemoteOperation.class.getSimpleName(); private String mPath; private Context mContext; private boolean mSuccessIfAbsent; /** Sequence of redirections followed. Available only after executing the operation */ Loading @@ -61,22 +59,29 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { * Full constructor. Success of the operation will depend upon the value of successIfAbsent. * * @param remotePath Path to append to the URL owned by the client instance. * @param context Android application context. * @param successIfAbsent When 'true', the operation finishes in success if the path does * NOT exist in the remote server (HTTP 404). */ public ExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent) { public ExistenceCheckRemoteOperation(String remotePath, boolean successIfAbsent) { mPath = (remotePath != null) ? remotePath : ""; mContext = context; mSuccessIfAbsent = successIfAbsent; } /** * Full constructor. Success of the operation will depend upon the value of successIfAbsent. * * @param remotePath Path to append to the URL owned by the client instance. * @param context Android application context. * @param successIfAbsent When 'true', the operation finishes in success if the path does * NOT exist in the remote server (HTTP 404). * @deprecated */ public ExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent) { this(remotePath, successIfAbsent); } @Override protected RemoteOperationResult run(OwnCloudClient client) { if (!isOnline()) { return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); } RemoteOperationResult result = null; HeadMethod head = null; boolean previousFollowRedirects = client.getFollowRedirects(); Loading Loading @@ -112,13 +117,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { return result; } private boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); return cm != null && cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); } /** * Gets the sequence of redirections followed during the execution of the operation. Loading test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> // copy a folder into a descendant copyOperation = new CopyRemoteFileOperation( getContext(), SRC_BASE_FOLDER, SRC_PATH_TO_EMPTY_FOLDER, false Loading Loading
src/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +4 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ public class CopyRemoteFileOperation extends RemoteOperation { return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT); } if (!new ExistenceCheckRemoteOperation(mSrcRemotePath, Boolean.FALSE).run(getClient()).isSuccess()) { return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); } /// perform remote operation CopyMethod copyMethod = null; RemoteOperationResult result = null; Loading
src/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java +16 −18 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.HeadMethod; import android.content.Context; import android.net.ConnectivityManager; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.RedirectionPath; Loading @@ -50,7 +49,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { private static final String TAG = ExistenceCheckRemoteOperation.class.getSimpleName(); private String mPath; private Context mContext; private boolean mSuccessIfAbsent; /** Sequence of redirections followed. Available only after executing the operation */ Loading @@ -61,22 +59,29 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { * Full constructor. Success of the operation will depend upon the value of successIfAbsent. * * @param remotePath Path to append to the URL owned by the client instance. * @param context Android application context. * @param successIfAbsent When 'true', the operation finishes in success if the path does * NOT exist in the remote server (HTTP 404). */ public ExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent) { public ExistenceCheckRemoteOperation(String remotePath, boolean successIfAbsent) { mPath = (remotePath != null) ? remotePath : ""; mContext = context; mSuccessIfAbsent = successIfAbsent; } /** * Full constructor. Success of the operation will depend upon the value of successIfAbsent. * * @param remotePath Path to append to the URL owned by the client instance. * @param context Android application context. * @param successIfAbsent When 'true', the operation finishes in success if the path does * NOT exist in the remote server (HTTP 404). * @deprecated */ public ExistenceCheckRemoteOperation(String remotePath, Context context, boolean successIfAbsent) { this(remotePath, successIfAbsent); } @Override protected RemoteOperationResult run(OwnCloudClient client) { if (!isOnline()) { return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); } RemoteOperationResult result = null; HeadMethod head = null; boolean previousFollowRedirects = client.getFollowRedirects(); Loading Loading @@ -112,13 +117,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { return result; } private boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); return cm != null && cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting(); } /** * Gets the sequence of redirections followed during the execution of the operation. Loading
test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2<TestActivity> // copy a folder into a descendant copyOperation = new CopyRemoteFileOperation( getContext(), SRC_BASE_FOLDER, SRC_PATH_TO_EMPTY_FOLDER, false Loading