use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.
the class RefreshFolderOperation method run.
/**
* Performs the synchronization.
*
* {@inheritDoc}
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result;
// get 'fresh data' from the database
mLocalFolder = getStorageManager().getFileByPath(mLocalFolder.getRemotePath());
// only in root folder: sync server version and user profile
if (OCFile.ROOT_PATH.equals(mLocalFolder.getRemotePath())) {
updateOCVersion(client);
updateUserProfile();
}
// sync list of files, and contents of available offline files & folders
SynchronizeFolderOperation syncOp = new SynchronizeFolderOperation(mContext, mLocalFolder.getRemotePath(), mAccount, System.currentTimeMillis(), false, false, false);
result = syncOp.execute(client, getStorageManager());
sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result);
// sync list of shares
if (result.isSuccess() && mIsShareSupported) {
// share result is ignored
refreshSharesForFolder(client);
}
sendLocalBroadcast(EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result);
return result;
}
use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.
the class RefreshFolderOperation method updateUserProfile.
private void updateUserProfile() {
GetUserProfileOperation update = new GetUserProfileOperation();
RemoteOperationResult result = update.execute(getStorageManager(), mContext);
if (!result.isSuccess()) {
Log_OC.w(TAG, "Couldn't update user profile from server");
} else {
Log_OC.i(TAG, "Got user profile");
}
}
use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.
the class RefreshFolderOperation method updateCapabilities.
private void updateCapabilities() {
GetCapabilitiesOperarion getCapabilities = new GetCapabilitiesOperarion();
RemoteOperationResult result = getCapabilities.execute(getStorageManager(), mContext);
if (!result.isSuccess()) {
Log_OC.w(TAG, "Update Capabilities unsuccessfully");
}
}
use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.
the class RemoveFileOperation method run.
/**
* Performs the remove operation
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
mFileToRemove = getStorageManager().getFileByPath(mRemotePath);
boolean localRemovalFailed = false;
if (!mOnlyLocalCopy) {
RemoveRemoteFileOperation operation = new RemoveRemoteFileOperation(mRemotePath);
result = operation.execute(client);
if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
localRemovalFailed = !(getStorageManager().removeFile(mFileToRemove, true, true));
}
} else {
localRemovalFailed = !(getStorageManager().removeFile(mFileToRemove, false, true));
if (!localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.OK);
}
}
if (localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_REMOVED);
}
return result;
}
use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.
the class RenameFileOperation method run.
/**
* Performs the rename operation.
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
mFile = getStorageManager().getFileByPath(mRemotePath);
// check if the new name is valid in the local file system
try {
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 local overwrite
if (getStorageManager().getFileByPath(mNewRemotePath) != null) {
return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
}
RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName, mFile.isFolder());
result = operation.execute(client);
if (result.isSuccess()) {
if (mFile.isFolder()) {
saveLocalDirectory(parent);
} else {
saveLocalFile();
}
}
} catch (IOException e) {
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath == null) ? mNewName : mNewRemotePath) + ": " + ((result != null) ? result.getLogMessage() : ""), e);
}
return result;
}
Aggregations