Search in sources :

Example 1 with UpdateRemoteShareOperation

use of com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation in project android by owncloud.

the class UpdateSharePermissionsOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    // ShareType.USER | ShareType.GROUP
    OCShare share = getStorageManager().getShareById(mShareId);
    if (share == null) {
        // TODO try to get remote share before failing?
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    mPath = share.getPath();
    // Update remote share with password
    UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(share.getRemoteId());
    updateOp.setPermissions(mPermissions);
    RemoteOperationResult result = updateOp.execute(client);
    if (result.isSuccess()) {
        RemoteOperation getShareOp = new GetRemoteShareOperation(share.getRemoteId());
        result = getShareOp.execute(client);
        if (result.isSuccess()) {
            share = (OCShare) result.getData().get(0);
            // TODO check permissions are being saved
            updateData(share);
        }
    }
    return result;
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetRemoteShareOperation(com.owncloud.android.lib.resources.shares.GetRemoteShareOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) UpdateRemoteShareOperation(com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Example 2 with UpdateRemoteShareOperation

use of com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation in project android by owncloud.

the class UpdateShareViaLinkOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    OCShare publicShare = getStorageManager().getFirstShareByPathAndType(mPath, ShareType.PUBLIC_LINK, "");
    if (publicShare == null) {
        // TODO try to get remote share before failing?
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    // Update remote share with password
    UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(publicShare.getRemoteId());
    updateOp.setPassword(mPassword);
    updateOp.setExpirationDate(mExpirationDateInMillis);
    updateOp.setPublicUpload(mPublicUpload);
    RemoteOperationResult result = updateOp.execute(client);
    if (result.isSuccess()) {
        // Retrieve updated share / save directly with password? -> no; the password is not to be saved
        RemoteOperation getShareOp = new GetRemoteShareOperation(publicShare.getRemoteId());
        result = getShareOp.execute(client);
        if (result.isSuccess()) {
            OCShare share = (OCShare) result.getData().get(0);
            updateData(share);
        }
    }
    return result;
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetRemoteShareOperation(com.owncloud.android.lib.resources.shares.GetRemoteShareOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) UpdateRemoteShareOperation(com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Aggregations

RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)2 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)2 GetRemoteShareOperation (com.owncloud.android.lib.resources.shares.GetRemoteShareOperation)2 OCShare (com.owncloud.android.lib.resources.shares.OCShare)2 UpdateRemoteShareOperation (com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation)2