diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-02 14:18:59 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-02 14:23:45 +0100 |
commit | dc32f49c6ee25770b461f11287fd9695f2429c91 (patch) | |
tree | 37b4a2b3dcb98be57bc4fdef38ccdea6b729be18 /apps/files_sharing | |
parent | 4d7130ad315637b7b7b925efce4032472f4530f8 (diff) | |
download | nextcloud-server-dc32f49c6ee25770b461f11287fd9695f2429c91.tar.gz nextcloud-server-dc32f49c6ee25770b461f11287fd9695f2429c91.zip |
[Share 2.0] Use GenericShareException
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/api/share20ocs.php | 17 | ||||
-rw-r--r-- | apps/files_sharing/tests/api/share20ocstest.php | 19 |
2 files changed, 8 insertions, 28 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index a9f32143776..63c49b926bf 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -27,6 +27,9 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\Files\IRootFolder; +use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\Exceptions\GenericShareException; + class Share20OCS { /** @var \OC\Share20\Manager */ @@ -148,7 +151,7 @@ class Share20OCS { // First check if it is an internal share. try { $share = $this->shareManager->getShareById('ocinternal:'.$id); - } catch (\OCP\Share\Exceptions\ShareNotFound $e) { + } catch (ShareNotFound $e) { // Ignore for now //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } @@ -178,7 +181,7 @@ class Share20OCS { try { $share = $this->shareManager->getShareById('ocinternal:' . $id); - } catch (\OCP\Share\Exceptions\ShareNotFound $e) { + } catch (ShareNotFound $e) { //Ignore for now //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } @@ -192,11 +195,7 @@ class Share20OCS { return new \OC_OCS_Result(null, 404, 'could not delete share'); } - try { - $this->shareManager->deleteShare($share); - } catch (\OC\Share20\Exception\BackendError $e) { - return new \OC_OCS_Result(null, 404, 'could not delete share'); - } + $this->shareManager->deleteShare($share); return new \OC_OCS_Result(); } @@ -318,7 +317,7 @@ class Share20OCS { try { $share = $this->shareManager->createShare($share); - } catch (\OC\HintException $e) { + } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); return new \OC_OCS_Result(null, $code, $e->getHint()); }catch (\Exception $e) { @@ -443,7 +442,7 @@ class Share20OCS { try { $share = $this->shareManager->getShareById('ocinternal:' . $id); - } catch (\OCP\Share\Exceptions\ShareNotFound $e) { + } catch (ShareNotFound $e) { //Ignore for now //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php index 77331fada50..1405f8f441a 100644 --- a/apps/files_sharing/tests/api/share20ocstest.php +++ b/apps/files_sharing/tests/api/share20ocstest.php @@ -102,25 +102,6 @@ class Share20OCSTest extends \Test\TestCase { $this->assertEquals($expected, $this->ocs->deleteShare(42)); } - public function testDeleteShareCouldNotDelete() { - $share = $this->getMock('OCP\Share\IShare'); - $share->method('getShareOwner')->willReturn($this->currentUser); - $this->shareManager - ->expects($this->once()) - ->method('getShareById') - ->with('ocinternal:42') - ->willReturn($share); - $this->shareManager - ->expects($this->once()) - ->method('deleteShare') - ->with($share) - ->will($this->throwException(new \OC\Share20\Exception\BackendError())); - - - $expected = new \OC_OCS_Result(null, 404, 'could not delete share'); - $this->assertEquals($expected, $this->ocs->deleteShare(42)); - } - public function testDeleteShare() { $share = $this->getMock('OCP\Share\IShare'); $share->method('getSharedBy')->willReturn($this->currentUser); |