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;
}
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;
}
Aggregations