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
.MainApp
;
27 import com
.owncloud
.android
.lib
.common
.OwnCloudClient
;
28 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperationResult
;
29 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
30 import com
.owncloud
.android
.lib
.resources
.shares
.OCShare
;
31 import com
.owncloud
.android
.lib
.resources
.shares
.GetRemoteSharesOperation
;
32 import com
.owncloud
.android
.operations
.common
.SyncOperation
;
35 * Access to remote operation to get the share files/folders
36 * Save the data in Database
39 public class GetSharesOperation
extends SyncOperation
{
41 private static final String TAG
= GetSharesOperation
.class.getSimpleName();
44 protected RemoteOperationResult
run(OwnCloudClient client
) {
45 GetRemoteSharesOperation operation
= new GetRemoteSharesOperation();
46 RemoteOperationResult result
= operation
.execute(client
);
48 if (result
.isSuccess()) {
50 // Update DB with the response
51 Log_OC
.d(TAG
, "Share list size = " + result
.getData().size());
52 ArrayList
<OCShare
> shares
= new ArrayList
<OCShare
>();
53 for(Object obj
: result
.getData()) {
54 shares
.add((OCShare
) obj
);
57 getStorageManager().saveSharesDB(shares
);