1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.operations
;
21 import java
.util
.ArrayList
;
23 import com
.owncloud
.android
.lib
.common
.OwnCloudClient
;
24 import com
.owncloud
.android
.lib
.resources
.shares
.OCShare
;
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
.operations
.common
.SyncOperation
;
31 * 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
, mReshares
, mSubfiles
);
62 RemoteOperationResult result
= operation
.execute(client
);
64 if (result
.isSuccess()) {
66 // Update DB with the response
67 Log_OC
.d(TAG
, "File = " + mPath
+ " Share list size " + result
.getData().size());
68 ArrayList
<OCShare
> shares
= new ArrayList
<OCShare
>();
69 for(Object obj
: result
.getData()) {
70 shares
.add((OCShare
) obj
);
73 getStorageManager().saveSharesDB(shares
);