Search in sources :

Example 31 with RemoteOperationResult

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;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Example 32 with RemoteOperationResult

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");
    }
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Example 33 with RemoteOperationResult

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");
    }
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Example 34 with RemoteOperationResult

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;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) RemoveRemoteFileOperation(com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation)

Example 35 with RemoteOperationResult

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;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) RenameRemoteFileOperation(com.owncloud.android.lib.resources.files.RenameRemoteFileOperation) IOException(java.io.IOException) OCFile(com.owncloud.android.datamodel.OCFile) File(java.io.File)

Aggregations

RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)46 OCFile (com.owncloud.android.datamodel.OCFile)11 ArrayList (java.util.ArrayList)9 RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)7 OCShare (com.owncloud.android.lib.resources.shares.OCShare)7 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)6 ExistenceCheckRemoteOperation (com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation)6 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)5 OperationCancelledException (com.owncloud.android.lib.common.operations.OperationCancelledException)5 File (java.io.File)5 IOException (java.io.IOException)5 Account (android.accounts.Account)4 Uri (android.net.Uri)4 Intent (android.content.Intent)3 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)3 GetRemoteSharesForFileOperation (com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation)3 UserInfo (com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation.UserInfo)3 AccountManager (android.accounts.AccountManager)2 Pair (android.util.Pair)2 OwnCloudClient (com.owncloud.android.lib.common.OwnCloudClient)2