use of com.owncloud.android.lib.resources.shares.GetShareRemoteOperation 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;
}
use of com.owncloud.android.lib.resources.shares.GetShareRemoteOperation 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;
}
use of com.owncloud.android.lib.resources.shares.GetShareRemoteOperation 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;
}
use of com.owncloud.android.lib.resources.shares.GetShareRemoteOperation 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;
}
Aggregations