2 * ownCloud Android client application
5 * @author David A. Velasco
6 * Copyright (C) 2015 ownCloud Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * 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
.lib
.common
.OwnCloudClient
;
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
.OCShare
;
30 import com
.owncloud
.android
.lib
.resources
.shares
.GetRemoteSharesOperation
;
31 import com
.owncloud
.android
.operations
.common
.SyncOperation
;
34 * Access to remote operation to get the share files/folders
35 * Save the data in Database
38 public class GetSharesOperation
extends SyncOperation
{
40 private static final String TAG
= GetSharesOperation
.class.getSimpleName();
43 protected RemoteOperationResult
run(OwnCloudClient client
) {
44 GetRemoteSharesOperation operation
= new GetRemoteSharesOperation();
45 RemoteOperationResult result
= operation
.execute(client
);
47 if (result
.isSuccess()) {
49 // Update DB with the response
50 Log_OC
.d(TAG
, "Share list size = " + result
.getData().size());
51 ArrayList
<OCShare
> shares
= new ArrayList
<OCShare
>();
52 for(Object obj
: result
.getData()) {
53 shares
.add((OCShare
) obj
);
56 getStorageManager().saveSharesDB(shares
);