diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-06-07 14:40:12 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-02 11:29:29 +0200 |
commit | 957b27f28267fd95bec9c8a041ca1e7be9d32aa6 (patch) | |
tree | 3b246af7f382572f53624e7afe32bd237da01a09 /apps/federatedfilesharing | |
parent | 61485e3e600d5a9359ac215602c4778f00d38823 (diff) | |
download | nextcloud-server-957b27f28267fd95bec9c8a041ca1e7be9d32aa6.tar.gz nextcloud-server-957b27f28267fd95bec9c8a041ca1e7be9d32aa6.zip |
replace \OCP\Federation\Exception\ShareNotFoundException with the generic \OCP\Share\Exception\ShareNotFound exception
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federatedfilesharing')
3 files changed, 22 insertions, 32 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index 653c41c3ba0..eb434c30c91 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -29,7 +29,6 @@ namespace OCA\FederatedFileSharing\Controller; -use OCA\Files_Sharing\Activity\Providers\RemoteShares; use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Notifications; @@ -37,24 +36,19 @@ use OCP\AppFramework\Http; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; -use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; use OCP\Constants; -use OCP\Federation\Exceptions\AuthenticationFailedException; -use OCP\Federation\Exceptions\BadRequestException; use OCP\Federation\Exceptions\ProviderCouldNotAddShareException; use OCP\Federation\Exceptions\ProviderDoesNotExistsException; -use OCP\Federation\Exceptions\ShareNotFoundException; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudIdManager; -use OCP\Files\NotFoundException; use OCP\IDBConnection; use OCP\ILogger; use OCP\IRequest; use OCP\IUserManager; use OCP\Share; -use OCP\Share\IShare; +use OCP\Share\Exceptions\ShareNotFound; class RequestHandlerController extends OCSController { @@ -201,8 +195,8 @@ class RequestHandlerController extends OCSController { * @param int $id * @return Http\DataResponse * @throws OCSBadRequestException + * @throws OCSException * @throws OCSForbiddenException - * @throws OCSNotFoundException */ public function reShare($id) { @@ -236,11 +230,8 @@ class RequestHandlerController extends OCSController { ]); } catch (ProviderDoesNotExistsException $e) { throw new OCSException('Server does not support federated cloud sharing', 503); - } catch (ShareNotFoundException $e) { + } catch (ShareNotFound $e) { $this->logger->debug('Share not found: ' . $e->getMessage()); - } catch (ProviderCouldNotAddShareException $e) { - $this->logger->debug('Could not add reshare: ' . $e->getMessage()); - throw new OCSForbiddenException(); } catch (\Exception $e) { $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); } @@ -258,7 +249,7 @@ class RequestHandlerController extends OCSController { * @param int $id * @return Http\DataResponse * @throws OCSException - * @throws Share\Exceptions\ShareNotFound + * @throws ShareNotFound * @throws \OC\HintException */ public function acceptShare($id) { @@ -275,7 +266,7 @@ class RequestHandlerController extends OCSController { $provider->notificationReceived('SHARE_ACCEPTED', $id, $notification); } catch (ProviderDoesNotExistsException $e) { throw new OCSException('Server does not support federated cloud sharing', 503); - } catch (ShareNotFoundException $e) { + } catch (ShareNotFound $e) { $this->logger->debug('Share not found: ' . $e->getMessage()); } catch (\Exception $e) { $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); @@ -308,7 +299,7 @@ class RequestHandlerController extends OCSController { $provider->notificationReceived('SHARE_DECLINED', $id, $notification); } catch (ProviderDoesNotExistsException $e) { throw new OCSException('Server does not support federated cloud sharing', 503); - } catch (ShareNotFoundException $e) { + } catch (ShareNotFound $e) { $this->logger->debug('Share not found: ' . $e->getMessage()); } catch (\Exception $e) { $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 370ba44a0bd..27fbfeef619 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -30,7 +30,6 @@ namespace OCA\FederatedFileSharing; use OC\Share20\Share; -use OCP\Federation\Exceptions\ShareNotFoundException; use OCP\Federation\ICloudIdManager; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Folder; @@ -700,13 +699,13 @@ class FederatedShareProvider implements IShareProvider { $cursor->closeCursor(); if ($data === false) { - throw new ShareNotFoundException('Can not find share with ID: ' . $id); + throw new ShareNotFound('Can not find share with ID: ' . $id); } try { $share = $this->createShareObject($data); } catch (InvalidShare $e) { - throw new ShareNotFoundException(); + throw new ShareNotFound(); } return $share; diff --git a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php index ae2e12bb894..422d008ffd6 100644 --- a/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php @@ -21,21 +21,18 @@ namespace OCA\FederatedFileSharing\OCM; -use function GuzzleHttp\default_ca_bundle; use OC\AppFramework\Http; use OC\Files\Filesystem; use OCA\Files_Sharing\Activity\Providers\RemoteShares; use OCA\FederatedFileSharing\AddressHandler; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\Activity\IManager as IActivityManager; -use OCP\Activity\IManager; use OCP\App\IAppManager; use OCP\Constants; use OCP\Federation\Exceptions\ActionNotSupportedException; use OCP\Federation\Exceptions\AuthenticationFailedException; use OCP\Federation\Exceptions\BadRequestException; use OCP\Federation\Exceptions\ProviderCouldNotAddShareException; -use OCP\Federation\Exceptions\ShareNotFoundException; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProvider; use OCP\Federation\ICloudFederationProviderManager; @@ -272,7 +269,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws ActionNotSupportedException * @throws AuthenticationFailedException * @throws BadRequestException - * @throws ShareNotFoundException * @throws \OC\HintException * @since 14.0.0 */ @@ -306,7 +302,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws ActionNotSupportedException * @throws AuthenticationFailedException * @throws BadRequestException - * @throws ShareNotFoundException * @throws \OC\HintException */ private function shareAccepted($id, $notification) { @@ -348,14 +343,14 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { /** * @param IShare $share - * @throws ShareNotFoundException + * @throws ShareNotFound */ protected function executeAcceptShare(IShare $share) { try { $fileId = (int)$share->getNode()->getId(); list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); } catch (\Exception $e) { - throw new ShareNotFoundException(); + throw new ShareNotFound(); } $event = $this->activityManager->generateEvent(); @@ -378,7 +373,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws AuthenticationFailedException * @throws BadRequestException * @throws ShareNotFound - * @throws ShareNotFoundException * @throws \OC\HintException * */ @@ -425,7 +419,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * delete declined share and create a activity * * @param IShare $share - * @throws ShareNotFoundException + * @throws ShareNotFound */ protected function executeDeclineShare(IShare $share) { $this->federatedShareProvider->removeShareFromTable($share); @@ -434,7 +428,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $fileId = (int)$share->getNode()->getId(); list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); } catch (\Exception $e) { - throw new ShareNotFoundException(); + throw new ShareNotFound(); } $event = $this->activityManager->generateEvent(); @@ -456,7 +450,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return array * @throws AuthenticationFailedException * @throws BadRequestException - * @throws ShareNotFoundException */ private function undoReshare($id, $notification) { if (!isset($notification['sharedSecret'])) { @@ -471,7 +464,16 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { return []; } - private function unshare($id, $notification) { + /** + * unshare file from self + * + * @param string $id + * @param array $notification + * @return array + * @throws ActionNotSupportedException + * @throws BadRequestException + */ + private function unshare($id, array $notification) { if (!$this->isS2SEnabled(true)) { throw new ActionNotSupportedException("incoming shares disabled!"); @@ -554,7 +556,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @throws AuthenticationFailedException * @throws BadRequestException * @throws ProviderCouldNotAddShareException - * @throws ShareNotFoundException * @throws ShareNotFound */ protected function reshareRequested($id, $notification) { @@ -613,7 +614,6 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return array * @throws AuthenticationFailedException * @throws BadRequestException - * @throws ShareNotFoundException */ protected function updateResharePermissions($id, $notification) { |