mFileActivity.showLoadingDialog();
}
+
+ public void createFolder(String remotePath, boolean createFullPath) {
+ // Create Folder
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_CREATE_FOLDER);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
+ service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
+ mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+ }
}
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.operations.UploadFileOperation;
+import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
RemoteOperation operation = new ExistenceCheckRemoteOperation(pathToGrant, this, false);
RemoteOperationResult result = operation.execute(mUploadClient);
if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND && mCurrentUpload.isRemoteFolderToBeCreated()) {
- operation = new CreateFolderOperation( pathToGrant,
- true,
- mStorageManager );
- result = operation.execute(mUploadClient);
+ SyncOperation syncOp = new CreateFolderOperation( pathToGrant, true);
+ result = syncOp.execute(mUploadClient, mStorageManager);
}
if (result.isSuccess()) {
OCFile parentDir = mStorageManager.getFileByPath(pathToGrant);
/* ownCloud Android client application
- * Copyright (C) 2012 ownCloud Inc.
+ * Copyright (C) 2014 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
package com.owncloud.android.operations;
-import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.Log_OC;
* @author David A. Velasco
* @author masensio
*/
-public class CreateFolderOperation extends RemoteOperation implements OnRemoteOperationListener{
+public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener{
private static final String TAG = CreateFolderOperation.class.getSimpleName();
protected String mRemotePath;
protected boolean mCreateFullPath;
- protected FileDataStorageManager mStorageManager;
/**
* Constructor
*
* @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
- * @param storageManager Reference to the local database corresponding to the account where the file is contained.
*/
- public CreateFolderOperation(String remotePath, boolean createFullPath, FileDataStorageManager storageManager) {
+ public CreateFolderOperation(String remotePath, boolean createFullPath) {
mRemotePath = remotePath;
mCreateFullPath = createFullPath;
- mStorageManager = storageManager;
}
public void saveFolderInDB() {
OCFile newDir = new OCFile(mRemotePath);
newDir.setMimetype("DIR");
- long parentId = mStorageManager.getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId();
+ long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId();
newDir.setParentId(parentId);
newDir.setModificationTimestamp(System.currentTimeMillis());
- mStorageManager.saveFile(newDir);
+ getStorageManager().saveFile(newDir);
Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database");
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
import com.owncloud.android.operations.common.SyncOperation;
+import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.CreateShareOperation;
import com.owncloud.android.operations.GetServerInfoOperation;
import com.owncloud.android.operations.OAuth2GetAccessToken;
public static final String EXTRA_SEND_INTENT = "SEND_INTENT";
public static final String EXTRA_NEWNAME = "NEWNAME";
public static final String EXTRA_REMOVE_LOCAL_COPY = "REMOVE_LOCAL_COPY";
+ public static final String EXTRA_CREATE_FULL_PATH = "CREATE_FULL_PATH";
public static final String EXTRA_RESULT = "RESULT";
// TODO review if ALL OF THEM are necessary
public static final String ACTION_GET_USER_NAME = "GET_USER_NAME";
public static final String ACTION_RENAME = "RENAME";
public static final String ACTION_REMOVE = "REMOVE";
+ public static final String ACTION_CREATE_FOLDER = "CREATE_FOLDER";
public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED";
public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() + ".OPERATION_FINISHED";
private ConcurrentLinkedQueue<Pair<Target, RemoteOperation>> mPendingOperations =
new ConcurrentLinkedQueue<Pair<Target, RemoteOperation>>();
-
- /*
- private ConcurrentMap<Integer, RemoteOperationResult> mOperationResults =
- new ConcurrentHashMap<Integer, RemoteOperationResult>();
- */
private ConcurrentMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>
mUndispatchedFinishedOperations =
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
boolean removeLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_LOCAL_COPY, true);
operation = new RemoveFileOperation(remotePath, removeLocalCopy);
+
+ } else if (action.equals(ACTION_CREATE_FOLDER)) {
+ // Create Folder
+ String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
+ boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true);
+ operation = new CreateFolderOperation(remotePath, createFullPath);
}
+
}
} catch (IllegalArgumentException e) {
// Create directory
path += newDirectoryName + OCFile.PATH_SEPARATOR;
- RemoteOperation operation = new CreateFolderOperation(path, false, getStorageManager());
- operation.execute( getAccount(),
- FileDisplayActivity.this,
- FileDisplayActivity.this,
- getHandler(),
- FileDisplayActivity.this);
-
- showLoadingDialog();
+ getFileOperationsHelper().createFolder(path, false);
}
}
}