Search in sources :

Example 1 with GetSharesForFileOperation

use of com.owncloud.android.operations.GetSharesForFileOperation in project android by owncloud.

the class GetShareWithUsersAsyncTask method doInBackground.

@Override
protected Pair<RemoteOperation, RemoteOperationResult> doInBackground(Object... params) {
    GetSharesForFileOperation operation = null;
    RemoteOperationResult result = null;
    if (params != null && params.length == 3) {
        OCFile file = (OCFile) params[0];
        Account account = (Account) params[1];
        FileDataStorageManager fileDataStorageManager = (FileDataStorageManager) params[2];
        try {
            // Get shares request
            operation = new GetSharesForFileOperation(file.getRemotePath(), false, false);
            OwnCloudAccount ocAccount = new OwnCloudAccount(account, MainApp.getAppContext());
            OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, MainApp.getAppContext());
            result = operation.execute(client, fileDataStorageManager);
        } catch (Exception e) {
            result = new RemoteOperationResult(e);
            Log_OC.e(TAG, "Exception while getting shares", e);
        }
    } else {
        result = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR);
    }
    return new Pair(operation, result);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) GetSharesForFileOperation(com.owncloud.android.operations.GetSharesForFileOperation) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) OwnCloudClient(com.owncloud.android.lib.common.OwnCloudClient) Pair(android.util.Pair)

Aggregations

Account (android.accounts.Account)1 Pair (android.util.Pair)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1 OCFile (com.owncloud.android.datamodel.OCFile)1 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)1 OwnCloudClient (com.owncloud.android.lib.common.OwnCloudClient)1 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)1 GetSharesForFileOperation (com.owncloud.android.operations.GetSharesForFileOperation)1