RemoteOperationResult result = null;
MkColMethod mkcol = null;
-<<<<<<< HEAD
- boolean noInvalidChars = FileUtils.validateName(mRemotePath, true);
-=======
boolean noInvalidChars = FileUtils.validateName(mFolderName);
->>>>>>> refactor_remote_operation_to_create_folder
if (noInvalidChars) {
try {
mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
private String mOldRemotePath;
private String mNewName;
private String mNewRemotePath;
- private boolean mIsFolder;
/**
* @param newName New name to set as the name of file.
* @param newRemotePath New remote path to move the file, for folders it starts and ends by "/"
*/
- public RenameRemoteFileOperation(String oldName, String oldRemotePath, String newName, String newRemotePath, boolean isFolder) {
+ public RenameRemoteFileOperation(String oldName, String oldRemotePath, String newName, String newRemotePath) {
mOldName = oldName;
mOldRemotePath = oldRemotePath;
mNewName = newName;
mNewRemotePath = newRemotePath;
- mIsFolder = isFolder;
}
/**
LocalMoveMethod move = null;
- boolean noInvalidChars = true;
-
- if (mIsFolder)
- noInvalidChars = FileUtils.validateName(mNewRemotePath, mIsFolder);
- else
- noInvalidChars = FileUtils.validateName(mNewName, mIsFolder);
+ boolean noInvalidChars = FileUtils.validateName(mNewName);
if (noInvalidChars) {
try {
* @param fileName
* @return
*/
- public static boolean validateName(String fileName, boolean isFolder) {
+ public static boolean validateName(String fileName) {
boolean result = true;
Log.d("FileUtils", "fileName ======= " + fileName);
- String name = fileName.substring(1);
- if (isFolder) {
- name = name.substring(0, name.length() - 1);
- }
- if (name.contains("/") || fileName.contains("\\") || fileName.contains("<") ||
+ if (fileName.contains("/") || fileName.contains("\\") || fileName.contains("<") ||
fileName.contains(">") || fileName.contains(":") || fileName.contains("\"") ||
fileName.contains("|") || fileName.contains("?") || fileName.contains("*")) {
result = false;
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;
}
RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName,
- mNewRemotePath, mFile.isFolder());
+ mNewRemotePath);
result = operation.execute(client);
if (result.isSuccess()) {
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.create_dir_fail_msg_invalid_characters, Toast.LENGTH_LONG);
+ msg.show();
} else {
Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
msg.show();
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.create_dir_fail_msg_invalid_characters, Toast.LENGTH_LONG);
+ msg.show();
} else {
Toast msg = Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
msg.show();