X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/ab3044dc821afd86a99a49ce30b9160e5f25e347..cea1a76f48ceb400136e64b4fb921a3f92aee6e4:/src/com/owncloud/android/operations/GetSharesOperation.java diff --git a/src/com/owncloud/android/operations/GetSharesOperation.java b/src/com/owncloud/android/operations/GetSharesOperation.java index 3b879c06..4cbee02a 100644 --- a/src/com/owncloud/android/operations/GetSharesOperation.java +++ b/src/com/owncloud/android/operations/GetSharesOperation.java @@ -19,15 +19,14 @@ package com.owncloud.android.operations; import java.util.ArrayList; -import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.network.OwnCloudClient; -import com.owncloud.android.lib.operations.common.RemoteOperation; import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.lib.operations.common.OCShare; import com.owncloud.android.lib.operations.common.ShareType; import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation; import com.owncloud.android.lib.utils.FileUtils; +import com.owncloud.android.operations.common.SyncOperation; import com.owncloud.android.utils.Log_OC; /** @@ -35,19 +34,13 @@ import com.owncloud.android.utils.Log_OC; * Save the data in Database * * @author masensio + * @author David A. Velasco */ -public class GetSharesOperation extends RemoteOperation { +public class GetSharesOperation extends SyncOperation { private static final String TAG = GetSharesOperation.class.getSimpleName(); - protected FileDataStorageManager mStorageManager; - - - public GetSharesOperation(FileDataStorageManager storageManager) { - mStorageManager = storageManager; - } - @Override protected RemoteOperationResult run(OwnCloudClient client) { GetRemoteSharesOperation operation = new GetRemoteSharesOperation(); @@ -69,34 +62,29 @@ public class GetSharesOperation extends RemoteOperation { } private void saveSharesDB(ArrayList shares) { - - if (shares.size() > 0) { - // Save share file - mStorageManager.saveShares(shares); - - ArrayList sharedFiles = new ArrayList(); - - for (OCShare share : shares) { - // Get the path - String path = share.getPath(); - if (share.isDirectory()) { - path = path + FileUtils.PATH_SEPARATOR; - } - - // Update OCFile with data from share: ShareByLink ¿and publicLink? - OCFile file = mStorageManager.getFileByPath(path); - if (file != null) { - if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { - file.setShareByLink(true); - sharedFiles.add(file); - } - } - } - - if (sharedFiles.size() > 0) { - mStorageManager.updateSharedFiles(sharedFiles); - } + // Save share file + getStorageManager().saveShares(shares); + + ArrayList sharedFiles = new ArrayList(); + + for (OCShare share : shares) { + // Get the path + String path = share.getPath(); + if (share.isDirectory()) { + path = path + FileUtils.PATH_SEPARATOR; + } + + // Update OCFile with data from share: ShareByLink ¿and publicLink? + OCFile file = getStorageManager().getFileByPath(path); + if (file != null) { + if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { + file.setShareByLink(true); + sharedFiles.add(file); + } + } } + + getStorageManager().updateSharedFiles(sharedFiles); } }