Search in sources :

Example 81 with RemoteOperationResult

use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.

the class RefreshFolderOperation method updateOCVersion.

private void updateOCVersion(OwnCloudClient client) {
    UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
    RemoteOperationResult result = update.execute(client);
    if (result.isSuccess()) {
        mIsShareSupported = update.getOCVersion().isSharedSupported();
        // Update Capabilities for this account
        if (update.getOCVersion().isVersionWithCapabilitiesAPI()) {
            updateCapabilities();
        } else {
            Log_OC.d(TAG, "Capabilities API disabled");
        }
    }
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult)

Example 82 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 83 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 84 with RemoteOperationResult

use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.

the class FileSyncAdapter method updateOCVersion.

/**
     * Updates the locally stored version value of the ownCloud server
     */
private void updateOCVersion() {
    UpdateOCVersionOperation update = new UpdateOCVersionOperation(getAccount(), getContext());
    RemoteOperationResult result = update.execute(getClient());
    if (!result.isSuccess()) {
        mLastFailedResult = result;
    }
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) UpdateOCVersionOperation(com.owncloud.android.operations.UpdateOCVersionOperation)

Example 85 with RemoteOperationResult

use of com.owncloud.android.lib.common.operations.RemoteOperationResult in project android by owncloud.

the class SynchronizeFolderOperation method run.

/**
     * Performs the synchronization.
     *
     * {@inheritDoc}
     */
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    RemoteOperationResult result;
    mFailsInFileSyncsFound = 0;
    mConflictsFound = 0;
    mForgottenLocalFiles.clear();
    try {
        // get locally cached information about folder
        mLocalFolder = getStorageManager().getFileByPath(mRemotePath);
        if (mPushOnly) {
            // assuming there is no update in the server side, still need to handle local changes
            Log_OC.i(TAG, "Push only sync of " + mAccount.name + mRemotePath);
            preparePushOfLocalChanges();
            syncContents();
            //pushOnlySync();
            result = new RemoteOperationResult(ResultCode.OK);
        } else {
            // get list of files in folder from remote server
            result = fetchRemoteFolder(client);
            if (result.isSuccess()) {
                // success - merge updates in server with local state
                mergeRemoteFolder(result.getData());
                syncContents();
            } else {
                // fail fetching the server
                if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                    removeLocalFolder();
                }
                if (result.isException()) {
                    Log_OC.e(TAG, "Checked " + mAccount.name + mRemotePath + " : " + result.getLogMessage(), result.getException());
                } else {
                    Log_OC.e(TAG, "Checked " + mAccount.name + mRemotePath + " : " + result.getLogMessage());
                }
            }
        }
    } catch (OperationCancelledException e) {
        result = new RemoteOperationResult(e);
    }
    return result;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OperationCancelledException(com.owncloud.android.lib.common.operations.OperationCancelledException)

Aggregations

RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)172 OCFile (com.owncloud.android.datamodel.OCFile)48 RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)24 ArrayList (java.util.ArrayList)24 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)22 IOException (java.io.IOException)22 Account (android.accounts.Account)19 User (com.nextcloud.client.account.User)18 OCShare (com.owncloud.android.lib.resources.shares.OCShare)18 File (java.io.File)18 OperationCancelledException (com.owncloud.android.lib.common.operations.OperationCancelledException)17 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)16 Context (android.content.Context)15 OwnCloudClient (com.owncloud.android.lib.common.OwnCloudClient)12 RemoteFile (com.owncloud.android.lib.resources.files.model.RemoteFile)12 FileNotFoundException (java.io.FileNotFoundException)12 Intent (android.content.Intent)11 JSONObject (org.json.JSONObject)11 Test (org.junit.Test)11 Uri (android.net.Uri)10