Эх сурвалжийг харах

Merge pull request #303 from owncloud/refactor_remote_operation_to_rename_folder

Refactored remote operation to rename folder into oc_framework
David A. Velasco 11 жил өмнө
parent
commit
f3b45c8d20

+ 3 - 3
oc_framework-test-project/.classpath

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
-	<classpathentry exported="true" kind="lib" path="/oc_framework/bin/oc_framework.jar"/>
+	<classpathentry exported="true" kind="lib" path="/oc_framework/bin/oc_framework.jar" sourcepath="/oc_framework"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="output" path="bin/classes"/>
 </classpath>

BIN
oc_framework-test-project/libs/android-support-v4.jar


+ 2 - 2
oc_framework-test-project/oc_framework-test-test/.classpath

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="gen"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/oc_framework-test-project"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="output" path="bin/classes"/>
 </classpath>

+ 1 - 1
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<TestActiv
 	
 	
 	/**
-	 * Test to Create Folder with special characters
+	 * Test to Create Folder with special characters: /  \  < >  :  "  |  ?  *
 	 */
 	public void testCreateFolderSpecialCharacters() {		
 		boolean createFullPath = true;

+ 147 - 0
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<TestActivity> {
+
+	/* 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());
+	}
+	
+}

+ 1 - 0
oc_framework-test-project/res/values/strings.xml

@@ -4,5 +4,6 @@
     <string name="app_name">oc_framework-test-project</string>
     <string name="action_settings">Settings</string>
     <string name="hello_world">Hello world!</string>
+    <string name="test_account_not_found">The test account %1$s could not be found in the device</string>
 
 </resources>

+ 27 - 66
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<Context, Void, WebdavClient> {
-
-		@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;
 	}
+	
 }

+ 129 - 0
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;
+        }
+            
+    }
+
+}

+ 0 - 1
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;

+ 0 - 2
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;

+ 18 - 74
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;
-        }
-            
-    }
-    
-
 }

+ 3 - 0
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();

+ 3 - 0
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();