use of com.owncloud.android.lib.resources.shares.GetSharesForFileRemoteOperation in project android by nextcloud.
the class RefreshFolderOperation method refreshSharesForFolder.
/**
* Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants).
*
* @param client Handler of a session with an OC server.
* @return The result of the remote operation retrieving the Share resources in the folder refreshed by
* the operation.
*/
private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
RemoteOperationResult result;
// remote request
GetSharesForFileRemoteOperation operation = new GetSharesForFileRemoteOperation(mLocalFolder.getRemotePath(), true, true);
result = operation.execute(client);
if (result.isSuccess()) {
// update local database
ArrayList<OCShare> shares = new ArrayList<>();
OCShare share;
for (Object obj : result.getData()) {
share = (OCShare) obj;
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
shares.add(share);
}
}
mStorageManager.saveSharesInFolder(shares, mLocalFolder);
}
return result;
}
use of com.owncloud.android.lib.resources.shares.GetSharesForFileRemoteOperation in project android by nextcloud.
the class GetSharesForFileOperation method run.
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
GetSharesForFileRemoteOperation operation = new GetSharesForFileRemoteOperation(path, reshares, subfiles);
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {
// Update DB with the response
Log_OC.d(TAG, "File = " + path + " Share list size " + result.getData().size());
ArrayList<OCShare> shares = new ArrayList<OCShare>();
for (Object obj : result.getData()) {
shares.add((OCShare) obj);
}
getStorageManager().saveSharesDB(shares);
} else if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND) {
// no share on the file - remove local shares
getStorageManager().removeSharesForFile(path);
}
return result;
}
Aggregations