From cbd3050f4c5d0c98cc627cfab5d1ab8b85f1ae7c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 13 Jan 2016 13:02:23 +0100 Subject: [Share 2.0] Use full share id (providerId:shareId) Now that we support multiple managers we communicate shares to the outside as 'providerId:shareId'. This makes sures that id's are unique when references from the OCS API. However, since we do not want to break the OCS API v1 we need to somewhat hack around this. When we switch to OCS API v2 (which we should when we support more custom providers). We will change the id to always be the fullShareId. --- apps/files_sharing/api/share20ocs.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'apps/files_sharing/api') diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index f81eb071a37..c698dccefb8 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -142,10 +142,20 @@ class Share20OCS { * @return \OC_OCS_Result */ public function getShare($id) { + // Try both our default, and our federated provider.. + $share = null; + + // First check if it is an internal share. try { - $share = $this->shareManager->getShareById($id); + $share = $this->shareManager->getShareById('ocinternal:'.$id); } catch (\OC\Share20\Exception\ShareNotFound $e) { - return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + // Ignore for now + //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + } + + if ($share === null) { + //For now federated shares are handled by the old endpoint. + return \OCA\Files_Sharing\API\Local::getShare(['id' => $id]); } if ($this->canAccessShare($share)) { @@ -163,18 +173,19 @@ class Share20OCS { * @return \OC_OCS_Result */ public function deleteShare($id) { + // Try both our default and our federated provider + $share = null; + try { - $share = $this->shareManager->getShareById($id); + $share = $this->shareManager->getShareById('ocinternal:' . $id); } catch (\OC\Share20\Exception\ShareNotFound $e) { - return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); + //Ignore for now + //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } - /* - * FIXME - * User the old code path for remote shares until we have our remoteshareprovider - */ - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { - \OCA\Files_Sharing\API\Local::deleteShare(['id' => $id]); + // Could not find the share as internal share... maybe it is a federated share + if ($share === null) { + return \OCA\Files_Sharing\API\Local::deleteShare(['id' => $id]); } if (!$this->canAccessShare($share)) { -- cgit v1.2.3