From d9219441b145bc48302934430b05dfb001501d57 Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 20 Mar 2014 14:01:35 +0100 Subject: [PATCH] Revert "Changes from comments in PR#442, in oc-project" This reverts commit 0aa9a0bc6cca948ac5a0d693cf9791fad2d99d6f. --- owncloud-android-library | 2 +- .../operations/CreateShareOperation.java | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/owncloud-android-library b/owncloud-android-library index 3bf858e2a7..ff4dd08dd5 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 3bf858e2a7ea154e4a00e98fe95d98153b416bbf +Subproject commit ff4dd08dd5ac79ef2ce200d033182773f9dc36b1 diff --git a/src/com/owncloud/android/operations/CreateShareOperation.java b/src/com/owncloud/android/operations/CreateShareOperation.java index 4b2f6ad51e..17151abf06 100644 --- a/src/com/owncloud/android/operations/CreateShareOperation.java +++ b/src/com/owncloud/android/operations/CreateShareOperation.java @@ -42,6 +42,9 @@ import com.owncloud.android.utils.Log_OC; public class CreateShareOperation extends SyncOperation { private static final String TAG = CreateShareOperation.class.getSimpleName(); + + // String to build the link with the token of a share: server address + "/public.php?service=files&t=" + token + private final String SHARING_LINK_TOKEN = "/public.php?service=files&t="; protected FileDataStorageManager mStorageManager; @@ -92,13 +95,21 @@ public class CreateShareOperation extends SyncOperation { RemoteOperationResult result = ((GetRemoteSharesForFileOperation)operation).execute(client); if (result.isSuccess()) { - operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions); - result = ((CreateRemoteShareOperation)operation).execute(client); + if (result.getData().size() > 0) { + OCShare share = (OCShare) result.getData().get(0); + // Update the link, build it with the token: server address + "/public.php?service=files&t=" + token + share.setShareLink(client.getBaseUri() + SHARING_LINK_TOKEN + share.getToken()); + Log_OC.d(TAG, "Build Share link= " + share.getShareLink()); + updateData(share); + } else { + operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions); + result = ((CreateRemoteShareOperation)operation).execute(client); - if (result.isSuccess()) { - if (result.getData().size() > 0) { - OCShare share = (OCShare) result.getData().get(0); - updateData(share); + if (result.isSuccess()) { + if (result.getData().size() > 0) { + OCShare share = (OCShare) result.getData().get(0); + updateData(share); + } } } }