]> source.dussan.org Git - nextcloud-server.git/commitdiff
[Share 2.0] Add exceptions to OCP
authorRoeland Jago Douma <rullzer@owncloud.com>
Tue, 2 Feb 2016 13:07:11 +0000 (14:07 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Tue, 2 Feb 2016 13:07:11 +0000 (14:07 +0100)
apps/files_sharing/api/share20ocs.php
apps/files_sharing/lib/controllers/sharecontroller.php
apps/files_sharing/tests/api/share20ocstest.php
apps/files_sharing/tests/controller/sharecontroller.php
lib/private/share20/defaultshareprovider.php
lib/private/share20/exception/sharenotfound.php [deleted file]
lib/private/share20/manager.php
lib/public/share/exceptions/genericshareexception.php [new file with mode: 0644]
lib/public/share/exceptions/sharenotfound.php [new file with mode: 0644]
tests/lib/share20/defaultshareprovidertest.php
tests/lib/share20/managertest.php

index 8fe8991f9c9e6e80e564610efcf0d2c025da204c..a9f32143776c871503b0323267e7b0df07225ebb 100644 (file)
@@ -148,7 +148,7 @@ class Share20OCS {
                // First check if it is an internal share.
                try {
                        $share = $this->shareManager->getShareById('ocinternal:'.$id);
-               } catch (\OC\Share20\Exception\ShareNotFound $e) {
+               } catch (\OCP\Share\Exceptions\ShareNotFound $e) {
                        // Ignore for now
                        //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
                }
@@ -178,7 +178,7 @@ class Share20OCS {
 
                try {
                        $share = $this->shareManager->getShareById('ocinternal:' . $id);
-               } catch (\OC\Share20\Exception\ShareNotFound $e) {
+               } catch (\OCP\Share\Exceptions\ShareNotFound $e) {
                        //Ignore for now
                        //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
                }
@@ -443,7 +443,7 @@ class Share20OCS {
 
                try {
                        $share = $this->shareManager->getShareById('ocinternal:' . $id);
-               } catch (\OC\Share20\Exception\ShareNotFound $e) {
+               } catch (\OCP\Share\Exceptions\ShareNotFound $e) {
                        //Ignore for now
                        //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
                }
index 9fec57edbdd2813979e8da94bfd5b4d1a41212b6..6ac585e275c640d7a523a86debc9d9d0413c3dbc 100644 (file)
@@ -52,6 +52,7 @@ use OCP\Util;
 use OCA\Files_Sharing\Activity;
 use \OCP\Files\NotFoundException;
 use OCP\Files\IRootFolder;
+use OCP\Share\Exceptions\ShareNotFound;
 
 /**
  * Class ShareController
@@ -147,7 +148,7 @@ class ShareController extends Controller {
                // Check whether share exists
                try {
                        $share = $this->shareManager->getShareByToken($token);
-               } catch (\OC\Share20\Exception\ShareNotFound $e) {
+               } catch (ShareNotFound $e) {
                        return new NotFoundResponse();
                }
 
@@ -203,7 +204,7 @@ class ShareController extends Controller {
                // Check whether share exists
                try {
                        $share = $this->shareManager->getShareByToken($token);
-               } catch (\OC\Share20\Exception\ShareNotFound $e) {
+               } catch (ShareNotFound $e) {
                        return new NotFoundResponse();
                }
 
index 111fad0236fba4c36612e6d468bb8951f292d0d9..77331fada509977c89b13fb6f0525e8bec8ddf8f 100644 (file)
@@ -96,7 +96,7 @@ class Share20OCSTest extends \Test\TestCase {
                        ->expects($this->once())
                        ->method('getShareById')
                        ->with('ocinternal:42')
-                       ->will($this->throwException(new \OC\Share20\Exception\ShareNotFound()));
+                       ->will($this->throwException(new \OCP\Share\Exceptions\ShareNotFound()));
 
                $expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
                $this->assertEquals($expected, $this->ocs->deleteShare(42));
index 9f1d38f9f2312b647779a5946bfa7e22f50a4411..e36ee9e4914806d272cae4c0c3d8a7df105105ea 100644 (file)
@@ -30,7 +30,7 @@
 namespace OCA\Files_Sharing\Controllers;
 
 use OC\Files\Filesystem;
-use OC\Share20\Exception\ShareNotFound;
+use OCP\Share\Exceptions\ShareNotFound;
 use OCP\AppFramework\Http\NotFoundResponse;
 use OCP\AppFramework\Http\RedirectResponse;
 use OCP\AppFramework\Http\TemplateResponse;
@@ -175,7 +175,7 @@ class ShareControllerTest extends \Test\TestCase {
                        ->expects($this->once())
                        ->method('getShareByToken')
                        ->with('token')
-                       ->will($this->throwException(new \OC\Share20\Exception\ShareNotFound()));
+                       ->will($this->throwException(new \OCP\Share\Exceptions\ShareNotFound()));
 
                $response = $this->shareController->authenticate('token');
                $expectedResponse =  new NotFoundResponse();
index 224dddf401914071de0a7f6bffceab8624e2b1b1..7b78be2b61d61a0461b3922d98bc2c2619ce47f7 100644 (file)
@@ -24,7 +24,7 @@ use OCP\Files\File;
 use OCP\Share\IShareProvider;
 use OC\Share20\Exception\InvalidShare;
 use OC\Share20\Exception\ProviderException;
-use OC\Share20\Exception\ShareNotFound;
+use OCP\Share\Exceptions\ShareNotFound;
 use OC\Share20\Exception\BackendError;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\Files\NotFoundException;
diff --git a/lib/private/share20/exception/sharenotfound.php b/lib/private/share20/exception/sharenotfound.php
deleted file mode 100644 (file)
index b59f185..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Share20\Exception;
-
-class ShareNotFound extends \Exception {
-
-}
index b22b81bb404067e0137f3f53304ff89fc3941f98..8ea9d10c1cba1a384c989739919645acff2f8a04 100644 (file)
@@ -36,7 +36,7 @@ use OCP\Files\File;
 use OCP\Files\Folder;
 use OCP\IUser;
 
-use OC\Share20\Exception\ShareNotFound;
+use OCP\Share\Exceptions\ShareNotFound;
 use OC\HintException;
 
 /**
diff --git a/lib/public/share/exceptions/genericshareexception.php b/lib/public/share/exceptions/genericshareexception.php
new file mode 100644 (file)
index 0000000..83dfa12
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace OCP\Share\Exceptions;
+use OC\HintException;
+
+/**
+ * Class GenericEncryptionException
+ *
+ * @package OCP\Share\Exceptions
+ * @since 9.0.0
+ */
+class GenericShareException extends HintException {
+
+       /**
+        * @param string $message
+        * @param string $hint
+        * @param int $code
+        * @param \Exception $previous
+        * @since 9.0.0
+        */
+       public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) {
+               if (empty($message)) {
+                       $message = 'Unspecified share exception';
+               }
+               parent::__construct($message, $hint, $code, $previous);
+       }
+
+}
diff --git a/lib/public/share/exceptions/sharenotfound.php b/lib/public/share/exceptions/sharenotfound.php
new file mode 100644 (file)
index 0000000..96e7c09
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share\Exceptions;
+
+/**
+ * Class ShareNotFound
+ *
+ * @package OCP\Share\Exceptions
+ * @since 9.0.0
+ */
+class ShareNotFound extends GenericShareException {
+
+}
index 504bd77603653d26bd8f16dee166860c1d062f7e..32c0b342c41fd256ddd640833933b4c77af8b045 100644 (file)
@@ -110,7 +110,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
 
 
        /**
-        * @expectedException \OC\Share20\Exception\ShareNotFound
+        * @expectedException \OCP\Share\Exceptions\ShareNotFound
         */
        public function testGetShareByIdNotExist() {
                $this->provider->getShareById(1);
@@ -809,7 +809,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
        }
 
        /**
-        * @expectedException \OC\Share20\Exception\ShareNotFound
+        * @expectedException \OCP\Share\Exceptions\ShareNotFound
         */
        public function testGetShareByTokenNotFound() {
                $this->provider->getShareByToken('invalidtoken');
index 6043d30a0bb89d8db13531488e89db0687bf8f15..5dcf8f0760ef339e87788571ce750be903e3ee6f 100644 (file)
@@ -129,7 +129,7 @@ class ManagerTest extends \Test\TestCase {
        }
 
        /**
-        * @expectedException \OC\Share20\Exception\ShareNotFound
+        * @expectedException \OCP\Share\Exceptions\ShareNotFound
         */
        public function testDeleteNoShareId() {
                $share = $this->getMock('\OCP\Share\IShare');