use of com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation in project android by owncloud.
the class CheckCurrentCredentialsOperation method run.
@Override
protected RemoteOperationResult<Account> run(OwnCloudClient client) {
if (!getStorageManager().getAccount().name.equals(mAccount.name)) {
return new RemoteOperationResult<>(new IllegalStateException("Account to validate is not the account connected to!"));
} else {
RemoteOperation checkPathExistenceOperation = new CheckPathExistenceRemoteOperation(OCFile.ROOT_PATH, false);
final RemoteOperationResult existenceCheckResult = checkPathExistenceOperation.execute(client);
final RemoteOperationResult<Account> result = new RemoteOperationResult<>(existenceCheckResult.getCode());
result.setData(mAccount);
return result;
}
}
use of com.owncloud.android.lib.resources.files.CheckPathExistenceRemoteOperation in project android by owncloud.
the class UploadFileOperation method grantFolderExistence.
/**
* Checks the existence of the folder where the current file will be uploaded both
* in the remote server and in the local database.
* <p>
* If the upload is set to enforce the creation of the folder, the method tries to
* create it both remote and locally.
*
* @param pathToGrant Full remote path whose existence will be granted.
* @return An {@link OCFile} instance corresponding to the folder where the file
* will be uploaded.
*/
private RemoteOperationResult grantFolderExistence(String pathToGrant, OwnCloudClient client) {
RemoteOperation checkPathExistenceOperation = new CheckPathExistenceRemoteOperation(pathToGrant, false);
RemoteOperationResult result = checkPathExistenceOperation.execute(client);
if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND && mRemoteFolderToBeCreated) {
SyncOperation syncOp = new CreateFolderOperation(pathToGrant, true);
result = syncOp.execute(client, getStorageManager());
}
if (result.isSuccess()) {
OCFile parentDir = getStorageManager().getFileByPath(pathToGrant);
if (parentDir == null) {
parentDir = createLocalFolder(pathToGrant);
}
if (parentDir != null) {
result = new RemoteOperationResult(ResultCode.OK);
} else {
result = new RemoteOperationResult(ResultCode.UNKNOWN_ERROR);
}
}
return result;
}
Aggregations