2 * ownCloud Android client application
5 * Copyright (C) 2015 ownCloud Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2,
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 package com
.owncloud
.android
.operations
;
24 import com
.owncloud
.android
.lib
.common
.OwnCloudClient
;
25 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperationResult
;
26 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
27 import com
.owncloud
.android
.lib
.resources
.shares
.GetRemoteSharesForFileOperation
;
28 import com
.owncloud
.android
.lib
.resources
.shares
.OCShare
;
29 import com
.owncloud
.android
.operations
.common
.SyncOperation
;
31 import java
.util
.ArrayList
;
34 * Provide a list shares for a specific file.
36 public class GetSharesForFileOperation
extends SyncOperation
{
38 private static final String TAG
= GetSharesForFileOperation
.class.getSimpleName();
41 private boolean mReshares
;
42 private boolean mSubfiles
;
47 * @param path Path to file or folder
48 * @param reshares If set to false (default), only shares from the current user are returned
49 * If set to true, all shares from the given file are returned
50 * @param subfiles If set to false (default), lists only the folder being shared
51 * If set to true, all shared files within the folder are returned.
53 public GetSharesForFileOperation(String path
, boolean reshares
, boolean subfiles
) {
60 protected RemoteOperationResult
run(OwnCloudClient client
) {
61 GetRemoteSharesForFileOperation operation
= new GetRemoteSharesForFileOperation(mPath
,
62 mReshares
, mSubfiles
);
63 RemoteOperationResult result
= operation
.execute(client
);
65 if (result
.isSuccess()) {
67 // Update DB with the response
68 Log_OC
.d(TAG
, "File = " + mPath
+ " Share list size " + result
.getData().size());
69 ArrayList
<OCShare
> shares
= new ArrayList
<OCShare
>();
70 for(Object obj
: result
.getData()) {
71 shares
.add((OCShare
) obj
);
74 getStorageManager().saveSharesDB(shares
);