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