Search in sources :

Example 1 with UpdateShareRemoteOperation

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

the class UpdateShareViaLinkOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    OCShare publicShare = getStorageManager().getShareById(shareId);
    UpdateShareRemoteOperation updateOp = new UpdateShareRemoteOperation(publicShare.getRemoteId());
    updateOp.setPassword(password);
    updateOp.setExpirationDate(expirationDateInMillis);
    updateOp.setHideFileDownload(hideFileDownload);
    updateOp.setLabel(label);
    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 GetShareRemoteOperation(publicShare.getRemoteId());
        result = getShareOp.execute(client);
        if (result.isSuccess()) {
            OCShare share = (OCShare) result.getData().get(0);
            getStorageManager().saveShare(share);
        }
    }
    return result;
}
Also used : UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Example 2 with UpdateShareRemoteOperation

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

the class UpdateSharePermissionsOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    // ShareType.USER | ShareType.GROUP
    OCShare share = getStorageManager().getShareById(shareId);
    if (share == null) {
        // TODO try to get remote share before failing?
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    path = share.getPath();
    // Update remote share with password
    UpdateShareRemoteOperation updateOp = new UpdateShareRemoteOperation(share.getRemoteId());
    updateOp.setPassword(password);
    updateOp.setPermissions(permissions);
    updateOp.setExpirationDate(expirationDateInMillis);
    RemoteOperationResult result = updateOp.execute(client);
    if (result.isSuccess()) {
        RemoteOperation getShareOp = new GetShareRemoteOperation(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 : UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Example 3 with UpdateShareRemoteOperation

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

the class UpdateShareInfoOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    OCShare share;
    if (shareId > 0) {
        share = getStorageManager().getShareById(shareId);
    } else {
        share = this.share;
    }
    if (share == null) {
        // TODO try to get remote share before failing?
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    // Update remote share
    UpdateShareRemoteOperation updateOp = new UpdateShareRemoteOperation(share.getRemoteId());
    updateOp.setExpirationDate(expirationDateInMillis);
    updateOp.setHideFileDownload(hideFileDownload);
    if (!TextUtils.isEmpty(note)) {
        updateOp.setNote(note);
    }
    if (permissions > -1) {
        updateOp.setPermissions(permissions);
    }
    updateOp.setPassword(password);
    updateOp.setLabel(label);
    RemoteOperationResult result = updateOp.execute(client);
    if (result.isSuccess()) {
        RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
        result = getShareOp.execute(client);
        // this will be triggered by editing existing share
        if (result.isSuccess() && shareId > 0) {
            OCShare ocShare = (OCShare) result.getData().get(0);
            ocShare.setPasswordProtected(!TextUtils.isEmpty(password));
            getStorageManager().saveShare(ocShare);
        }
    }
    return result;
}
Also used : UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Example 4 with UpdateShareRemoteOperation

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

the class UpdateNoteForShareOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    OCShare share = getStorageManager().getShareById(shareId);
    if (share == null) {
        return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
    }
    UpdateShareRemoteOperation updateOperation = new UpdateShareRemoteOperation(share.getRemoteId());
    updateOperation.setNote(note);
    RemoteOperationResult result = updateOperation.execute(client);
    if (result.isSuccess()) {
        RemoteOperation getShareOp = new GetShareRemoteOperation(share.getRemoteId());
        result = getShareOp.execute(client);
        if (result.isSuccess()) {
            getStorageManager().saveShare((OCShare) result.getData().get(0));
        }
    }
    return result;
}
Also used : UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) UpdateShareRemoteOperation(com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation) RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetShareRemoteOperation(com.owncloud.android.lib.resources.shares.GetShareRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare)

Aggregations

RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)4 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)4 GetShareRemoteOperation (com.owncloud.android.lib.resources.shares.GetShareRemoteOperation)4 OCShare (com.owncloud.android.lib.resources.shares.OCShare)4 UpdateShareRemoteOperation (com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation)4