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 java
.util
.ArrayList
;
26 import com
.owncloud
.android
.MainApp
;
27 import com
.owncloud
.android
.lib
.common
.OwnCloudClient
;
28 import com
.owncloud
.android
.lib
.resources
.shares
.OCShare
;
29 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperationResult
;
30 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
31 import com
.owncloud
.android
.lib
.resources
.shares
.GetRemoteSharesForFileOperation
;
32 import com
.owncloud
.android
.operations
.common
.SyncOperation
;
35 * Provide a list shares for a specific file.
37 public class GetSharesForFileOperation
extends SyncOperation
{
39 private static final String TAG
= GetSharesForFileOperation
.class.getSimpleName();
42 private boolean mReshares
;
43 private boolean mSubfiles
;
48 * @param path Path to file or folder
49 * @param reshares If set to false (default), only shares from the current user are returned
50 * If set to true, all shares from the given file are returned
51 * @param subfiles If set to false (default), lists only the folder being shared
52 * If set to true, all shared files within the folder are returned.
54 public GetSharesForFileOperation(String path
, boolean reshares
, boolean subfiles
) {
61 protected RemoteOperationResult
run(OwnCloudClient client
) {
62 GetRemoteSharesForFileOperation operation
= new GetRemoteSharesForFileOperation(mPath
,
63 mReshares
, mSubfiles
);
64 RemoteOperationResult result
= operation
.execute(client
);
66 if (result
.isSuccess()) {
68 // Update DB with the response
69 Log_OC
.d(TAG
, "File = " + mPath
+ " Share list size " + result
.getData().size());
70 ArrayList
<OCShare
> shares
= new ArrayList
<OCShare
>();
71 for(Object obj
: result
.getData()) {
72 shares
.add((OCShare
) obj
);
75 getStorageManager().saveSharesDB(shares
);