From: David A. Velasco Date: Wed, 20 Nov 2013 07:45:58 +0000 (-0800) Subject: Merge pull request #303 from owncloud/refactor_remote_operation_to_rename_folder X-Git-Tag: oc-android-1.5.5~123 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/f3b45c8d2020527e6b97c4b84b638990c7324678?hp=d82d6a6d043d157f4ae5e3f3d7dd8d2898fb6bb6 Merge pull request #303 from owncloud/refactor_remote_operation_to_rename_folder Refactored remote operation to rename folder into oc_framework --- diff --git a/oc_framework-test-project/.classpath b/oc_framework-test-project/.classpath index d3d9f2d8..394360f0 100644 --- a/oc_framework-test-project/.classpath +++ b/oc_framework-test-project/.classpath @@ -1,10 +1,10 @@ - - - + + + diff --git a/oc_framework-test-project/libs/android-support-v4.jar b/oc_framework-test-project/libs/android-support-v4.jar index 9056828a..feaf44f8 100644 Binary files a/oc_framework-test-project/libs/android-support-v4.jar and b/oc_framework-test-project/libs/android-support-v4.jar differ diff --git a/oc_framework-test-project/oc_framework-test-test/.classpath b/oc_framework-test-project/oc_framework-test-test/.classpath index 49a8ebcf..6c54c1c9 100644 --- a/oc_framework-test-project/oc_framework-test-test/.classpath +++ b/oc_framework-test-project/oc_framework-test-test/.classpath @@ -1,10 +1,10 @@ - - + + diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java index 0c4b8efa..84145022 100644 --- a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java @@ -54,7 +54,7 @@ public class CreateFolderTest extends ActivityInstrumentationTestCase2 : " | ? * */ public void testCreateFolderSpecialCharacters() { boolean createFullPath = true; diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java new file mode 100644 index 00000000..fe30550b --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/RenameFileTest.java @@ -0,0 +1,147 @@ +package com.owncloud.android.oc_framework_test_project.test; + +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +public class RenameFileTest extends ActivityInstrumentationTestCase2 { + + /* Folder data to rename. This folder must exist on the account */ + private final String mOldFolderName = "folderToRename"; + private final String mOldFolderPath = "/folderToRename"; + private final String mNewFolderName = "renamedFolder"; + private final String mNewFolderPath = "/renamedFolder"; + + /* File data to rename. This file must exist on the account */ + private final String mOldFileName = "fileToRename.png"; + private final String mOldFilePath = "/fileToRename.png"; + private final String mNewFileName = "renamedFile"; + private final String mFileExtension = ".png"; + private final String mNewFilePath ="/renamedFile.png"; + + + private TestActivity mActivity; + + public RenameFileTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Rename Folder + */ + public void testRenameFolder() { + + RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName, true); + assertTrue(result.isSuccess()); + } + + /** + * Test Rename Folder with forbidden characters : \ < > : " | ? * + */ + public void testRenameFolderForbiddenChars() { + + RemoteOperationResult result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "\\", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "<", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + ">", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + ":", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "\"", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "|", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "?", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFolderName, mOldFolderPath, + mNewFolderName + "*", true); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + } + + /** + * Test Rename File + */ + public void testRenameFile() { + RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + mFileExtension, false); + assertTrue(result.isSuccess()); + } + + + /** + * Test Rename Folder with forbidden characters: \ < > : " | ? * + */ + public void testRenameFileForbiddenChars() { + RemoteOperationResult result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "\\" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "<" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + ">" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + ":" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "\"" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "|" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "?" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + result = mActivity.renameFile(mOldFileName, mOldFilePath, + mNewFileName + "*" + mFileExtension, false); + assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); + + } + + + /** + * Restore initial conditions + */ + public void testRestoreInitialConditions() { + RemoteOperationResult result = mActivity.renameFile(mNewFolderName, mNewFolderPath, mOldFolderName, true); + assertTrue(result.isSuccess()); + + result = mActivity.renameFile(mNewFileName + mFileExtension, mNewFilePath, mOldFileName, false); + assertTrue(result.isSuccess()); + } + +} diff --git a/oc_framework-test-project/res/values/strings.xml b/oc_framework-test-project/res/values/strings.xml index e50b40df..3a21cff9 100644 --- a/oc_framework-test-project/res/values/strings.xml +++ b/oc_framework-test-project/res/values/strings.xml @@ -4,5 +4,6 @@ oc_framework-test-project Settings Hello world! + The test account %1$s could not be found in the device diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java index e1c1edcb..7687bb2f 100644 --- a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -1,62 +1,38 @@ package com.owncloud.android.oc_framework_test_project; -import java.io.IOException; - -import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException; import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation; +import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; -import android.os.AsyncTask; +import android.net.Uri; import android.os.Bundle; -import android.accounts.Account; -import android.accounts.AccountManager; -import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; import android.app.Activity; -import android.content.Context; -import android.util.Log; import android.view.Menu; /** * Activity to test OC framework * @author masensio - * + * @author David A. Velasco */ public class TestActivity extends Activity { - private static final String TAG = "TestActivity"; + // This account must exists on the simulator / device + private static final String mServerUri = "https://beta.owncloud.com/owncloud/remote.php/webdav"; + private static final String mUser = "testandroid"; + private static final String mPass = "testandroid"; - private Account mAccount = null; + //private Account mAccount = null; private WebdavClient mClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); - - // This account must exists on the simulator / device - String accountHost = "beta.owncloud.com"; - String accountUser = "testandroid"; - String accountName = accountUser + "@"+ accountHost; - String accountPass = "testandroid"; - String accountType = "owncloud"; - - AccountManager am = AccountManager.get(this); - - Account[] ocAccounts = am.getAccountsByType(accountType); - for (Account ac : ocAccounts) { - if (ac.name.equals(accountName)) { - mAccount = ac; - break; - } - } - - // Get the WebDavClient - AuthTask task = new AuthTask(); - task.execute(this.getApplicationContext()); - + Uri uri = Uri.parse(mServerUri); + mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true); + mClient.setBasicCredentials(mUser, mPass); } @Override @@ -70,6 +46,7 @@ public class TestActivity extends Activity { * Access to the library method to Create a Folder * @param remotePath * @param createFullPath + * * @return */ public RemoteOperationResult createFolder(String remotePath, boolean createFullPath) { @@ -80,38 +57,22 @@ public class TestActivity extends Activity { return result; } - private class AuthTask extends AsyncTask { - - @Override - protected WebdavClient doInBackground(Context... params) { - WebdavClient client = null; - try { - client = OwnCloudClientFactory.createOwnCloudClient(mAccount, (Context) params[0] ); - } catch (OperationCanceledException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (AuthenticatorException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (AccountNotFoundException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (IOException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } catch (IllegalStateException e) { - Log.e(TAG, "Error while trying to access to " + mAccount.name, e); - e.printStackTrace(); - } - return client; - } + /** + * Access to the library method to Rename a File or Folder + * @param oldName Old name of the file. + * @param oldRemotePath Old remote path of the file. For folders it starts and ends by "/" + * @param newName New name to set as the name of file. + * @param isFolder 'true' for folder and 'false' for files + * + * @return + */ - @Override - protected void onPostExecute(WebdavClient result) { - // TODO Auto-generated method stub - super.onPostExecute(result); - mClient = result; - } + public RemoteOperationResult renameFile(String oldName, String oldRemotePath, String newName, boolean isFolder) { + + RenameRemoteFileOperation renameOperation = new RenameRemoteFileOperation(oldName, oldRemotePath, newName, isFolder); + RemoteOperationResult result = renameOperation.execute(mClient); + return result; } + } diff --git a/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java new file mode 100644 index 00000000..ad6fffc8 --- /dev/null +++ b/oc_framework/src/com/owncloud/android/oc_framework/operations/remote/RenameRemoteFileOperation.java @@ -0,0 +1,129 @@ +package com.owncloud.android.oc_framework.operations.remote; + +import java.io.File; + +import org.apache.jackrabbit.webdav.client.methods.DavMethodBase; + +import android.util.Log; + +import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; +import com.owncloud.android.oc_framework.operations.RemoteOperation; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.utils.FileUtils; + + +/** + * Remote operation performing the rename of a remote file or folder in the ownCloud server. + * + * @author David A. Velasco + * @author masensio + */ +public class RenameRemoteFileOperation extends RemoteOperation { + + private static final String TAG = RenameRemoteFileOperation.class.getSimpleName(); + + private static final int RENAME_READ_TIMEOUT = 10000; + private static final int RENAME_CONNECTION_TIMEOUT = 5000; + + private String mOldName; + private String mOldRemotePath; + private String mNewName; + private String mNewRemotePath; + + + /** + * Constructor + * + * @param oldName Old name of the file. + * @param oldRemotePath Old remote path of the file. + * @param newName New name to set as the name of file. + * @param isFolder 'true' for folder and 'false' for files + */ + public RenameRemoteFileOperation(String oldName, String oldRemotePath, String newName, boolean isFolder) { + mOldName = oldName; + mOldRemotePath = oldRemotePath; + mNewName = newName; + + String parent = (new File(mOldRemotePath)).getParent(); + parent = (parent.endsWith(FileUtils.PATH_SEPARATOR)) ? parent : parent + FileUtils.PATH_SEPARATOR; + mNewRemotePath = parent + mNewName; + if (isFolder) { + mNewRemotePath += FileUtils.PATH_SEPARATOR; + } + } + + /** + * Performs the rename operation. + * + * @param client Client object to communicate with the remote ownCloud server. + */ + @Override + protected RemoteOperationResult run(WebdavClient client) { + RemoteOperationResult result = null; + + LocalMoveMethod move = null; + + boolean noInvalidChars = FileUtils.isValidPath(mNewRemotePath); + + if (noInvalidChars) { + try { + + if (mNewName.equals(mOldName)) { + return new RemoteOperationResult(ResultCode.OK); + } + + + // check if a file with the new name already exists + if (client.existsFile(mNewRemotePath)) { + return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE); + } + + move = new LocalMoveMethod( client.getBaseUri() + WebdavUtils.encodePath(mOldRemotePath), + client.getBaseUri() + WebdavUtils.encodePath(mNewRemotePath)); + int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT); + + move.getResponseBodyAsString(); // exhaust response, although not interesting + result = new RemoteOperationResult(move.succeeded(), status, move.getResponseHeaders()); + Log.i(TAG, "Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " + result.getLogMessage()); + + } catch (Exception e) { + result = new RemoteOperationResult(e); + Log.e(TAG, "Rename " + mOldRemotePath + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " + result.getLogMessage(), e); + + } finally { + if (move != null) + move.releaseConnection(); + } + } else { + result = new RemoteOperationResult(ResultCode.INVALID_CHARACTER_IN_NAME); + } + + return result; + } + + /** + * Move operation + * + */ + private class LocalMoveMethod extends DavMethodBase { + + public LocalMoveMethod(String uri, String dest) { + super(uri); + addRequestHeader(new org.apache.commons.httpclient.Header("Destination", dest)); + } + + @Override + public String getName() { + return "MOVE"; + } + + @Override + protected boolean isSuccess(int status) { + return status == 201 || status == 204; + } + + } + +} diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 6928d414..85f4914a 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -23,7 +23,6 @@ import android.accounts.AccountManager; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; -import android.content.ContentResolver; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index d9f3a32c..61f61791 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -33,9 +33,7 @@ import org.apache.jackrabbit.webdav.DavConstants; import org.apache.jackrabbit.webdav.MultiStatus; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; -import com.owncloud.android.MainApp; import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountAuthenticator; import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; diff --git a/src/com/owncloud/android/operations/RenameFileOperation.java b/src/com/owncloud/android/operations/RenameFileOperation.java index 2b352bdd..9aa573ab 100644 --- a/src/com/owncloud/android/operations/RenameFileOperation.java +++ b/src/com/owncloud/android/operations/RenameFileOperation.java @@ -20,23 +20,20 @@ package com.owncloud.android.operations; import java.io.File; import java.io.IOException; -import org.apache.jackrabbit.webdav.client.methods.DavMethodBase; - +import org.apache.commons.httpclient.HttpException; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.oc_framework.network.webdav.WebdavClient; -import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; import com.owncloud.android.oc_framework.operations.RemoteOperation; import com.owncloud.android.oc_framework.operations.RemoteOperationResult; import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.oc_framework.operations.remote.RenameRemoteFileOperation; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.Log_OC; -//import org.apache.jackrabbit.webdav.client.methods.MoveMethod; import android.accounts.Account; - /** * Remote operation performing the rename of a remote file (or folder?) in the ownCloud server. * @@ -45,9 +42,6 @@ import android.accounts.Account; public class RenameFileOperation extends RemoteOperation { private static final String TAG = RenameFileOperation.class.getSimpleName(); - - private static final int RENAME_READ_TIMEOUT = 10000; - private static final int RENAME_CONNECTION_TIMEOUT = 5000; private OCFile mFile; @@ -87,69 +81,41 @@ public class RenameFileOperation extends RemoteOperation { protected RemoteOperationResult run(WebdavClient client) { RemoteOperationResult result = null; - LocalMoveMethod move = null; - mNewRemotePath = null; + // check if the new name is valid in the local file system try { - if (mNewName.equals(mFile.getFileName())) { - return new RemoteOperationResult(ResultCode.OK); + if (!isValidNewName()) { + return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME); } - String parent = (new File(mFile.getRemotePath())).getParent(); parent = (parent.endsWith(OCFile.PATH_SEPARATOR)) ? parent : parent + OCFile.PATH_SEPARATOR; mNewRemotePath = parent + mNewName; if (mFile.isFolder()) { mNewRemotePath += OCFile.PATH_SEPARATOR; } - - // check if the new name is valid in the local file system - if (!isValidNewName()) { - return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME); - } - - // check if a file with the new name already exists - if (client.existsFile(mNewRemotePath) || // remote check could fail by network failure. by indeterminate behavior of HEAD for folders ... - mStorageManager.getFileByPath(mNewRemotePath) != null) { // ... so local check is convenient + + // ckeck local overwrite + if (mStorageManager.getFileByPath(mNewRemotePath) != null) { return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE); } - move = new LocalMoveMethod( client.getBaseUri() + WebdavUtils.encodePath(mFile.getRemotePath()), - client.getBaseUri() + WebdavUtils.encodePath(mNewRemotePath)); - int status = client.executeMethod(move, RENAME_READ_TIMEOUT, RENAME_CONNECTION_TIMEOUT); - if (move.succeeded()) { + + RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(), mFile.getRemotePath(), + mNewName, mFile.isFolder()); + result = operation.execute(client); + if (result.isSuccess()) { if (mFile.isFolder()) { saveLocalDirectory(); - + } else { saveLocalFile(); - } - - /* - *} else if (mFile.isDirectory() && (status == 207 || status >= 500)) { - * // TODO - * // if server fails in the rename of a folder, some children files could have been moved to a folder with the new name while some others - * // stayed in the old folder; - * // - * // easiest and heaviest solution is synchronizing the parent folder (or the full account); - * // - * // a better solution is synchronizing the folders with the old and new names; - *} - */ - } - move.getResponseBodyAsString(); // exhaust response, although not interesting - result = new RemoteOperationResult(move.succeeded(), status, move.getResponseHeaders()); - Log_OC.i(TAG, "Rename " + mFile.getRemotePath() + " to " + mNewRemotePath + ": " + result.getLogMessage()); - - } catch (Exception e) { - result = new RemoteOperationResult(e); - Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " + result.getLogMessage(), e); - - } finally { - if (move != null) - move.releaseConnection(); + } catch (IOException e) { + Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " + + ((result!= null) ? result.getLogMessage() : ""), e); } + return result; } @@ -225,26 +191,4 @@ public class RenameFileOperation extends RemoteOperation { return result; } - - // move operation - private class LocalMoveMethod extends DavMethodBase { - - public LocalMoveMethod(String uri, String dest) { - super(uri); - addRequestHeader(new org.apache.commons.httpclient.Header("Destination", dest)); - } - - @Override - public String getName() { - return "MOVE"; - } - - @Override - protected boolean isSuccess(int status) { - return status == 201 || status == 204; - } - - } - - } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 685cff24..0bf82075 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1375,6 +1375,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa Toast msg = Toast.makeText(this, R.string.rename_local_fail_msg, Toast.LENGTH_LONG); msg.show(); // TODO throw again the new rename dialog + } if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) { + Toast msg = Toast.makeText(this, R.string.filename_forbidden_characters, Toast.LENGTH_LONG); + msg.show(); } else { Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG); msg.show(); diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 01ef8d07..ea0f814c 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -816,6 +816,9 @@ public class FileDetailFragment extends FileFragment implements Toast msg = Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG); msg.show(); // TODO throw again the new rename dialog + } if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) { + Toast msg = Toast.makeText(getActivity(), R.string.filename_forbidden_characters, Toast.LENGTH_LONG); + msg.show(); } else { Toast msg = Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG); msg.show();