diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php index a7601d1ce1..f79b774770 100644 --- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php +++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php @@ -31,7 +31,6 @@ 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\ICloudFederationProviderManager; use OCP\Federation\Exceptions\ProviderDoesNotExistsException; @@ -40,6 +39,7 @@ use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserManager; +use OCP\Share\Exceptions\ShareNotFound; /** @@ -234,7 +234,7 @@ class RequestHandlerController extends Controller { ['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST ); - } catch (ShareNotFoundException $e) { + } catch (ShareNotFound $e) { return new JSONResponse( ['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index 653c41c3ba..eb434c30c9 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 370ba44a0b..27fbfeef61 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 ae2e12bb89..422d008ffd 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) { diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 8b5410919c..d2648c2db6 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -132,10 +132,12 @@ return array( 'OCP\\Encryption\\IFile' => $baseDir . '/lib/public/Encryption/IFile.php', 'OCP\\Encryption\\IManager' => $baseDir . '/lib/public/Encryption/IManager.php', 'OCP\\Encryption\\Keys\\IStorage' => $baseDir . '/lib/public/Encryption/Keys/IStorage.php', + 'OCP\\Federation\\Exceptions\\ActionNotSupportedException' => $baseDir . '/lib/public/Federation/Exceptions/ActionNotSupportedException.php', + 'OCP\\Federation\\Exceptions\\AuthenticationFailedException' => $baseDir . '/lib/public/Federation/Exceptions/AuthenticationFailedException.php', + 'OCP\\Federation\\Exceptions\\BadRequestException' => $baseDir . '/lib/public/Federation/Exceptions/BadRequestException.php', 'OCP\\Federation\\Exceptions\\ProviderAlreadyExistsException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php', 'OCP\\Federation\\Exceptions\\ProviderCouldNotAddShareException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php', 'OCP\\Federation\\Exceptions\\ProviderDoesNotExistsException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php', - 'OCP\\Federation\\Exceptions\\ShareNotFoundException' => $baseDir . '/lib/public/Federation/Exceptions/ShareNotFoundException.php', 'OCP\\Federation\\ICloudFederationFactory' => $baseDir . '/lib/public/Federation/ICloudFederationFactory.php', 'OCP\\Federation\\ICloudFederationNotification' => $baseDir . '/lib/public/Federation/ICloudFederationNotification.php', 'OCP\\Federation\\ICloudFederationProvider' => $baseDir . '/lib/public/Federation/ICloudFederationProvider.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 36c582ccdb..4a2580fe75 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -162,10 +162,12 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Encryption\\IFile' => __DIR__ . '/../../..' . '/lib/public/Encryption/IFile.php', 'OCP\\Encryption\\IManager' => __DIR__ . '/../../..' . '/lib/public/Encryption/IManager.php', 'OCP\\Encryption\\Keys\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Encryption/Keys/IStorage.php', + 'OCP\\Federation\\Exceptions\\ActionNotSupportedException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ActionNotSupportedException.php', + 'OCP\\Federation\\Exceptions\\AuthenticationFailedException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/AuthenticationFailedException.php', + 'OCP\\Federation\\Exceptions\\BadRequestException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/BadRequestException.php', 'OCP\\Federation\\Exceptions\\ProviderAlreadyExistsException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php', 'OCP\\Federation\\Exceptions\\ProviderCouldNotAddShareException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php', 'OCP\\Federation\\Exceptions\\ProviderDoesNotExistsException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php', - 'OCP\\Federation\\Exceptions\\ShareNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ShareNotFoundException.php', 'OCP\\Federation\\ICloudFederationFactory' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationFactory.php', 'OCP\\Federation\\ICloudFederationNotification' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationNotification.php', 'OCP\\Federation\\ICloudFederationProvider' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationProvider.php', diff --git a/lib/public/Federation/Exceptions/ShareNotFoundException.php b/lib/public/Federation/Exceptions/ShareNotFoundException.php deleted file mode 100644 index 6655d5b443..0000000000 --- a/lib/public/Federation/Exceptions/ShareNotFoundException.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see . - * - */ - -namespace OCP\Federation\Exceptions; - - -use OC\HintException; - -class ShareNotFoundException extends HintException { - -} diff --git a/lib/public/Federation/ICloudFederationProvider.php b/lib/public/Federation/ICloudFederationProvider.php index 5260cbf9aa..49a2b4bc77 100644 --- a/lib/public/Federation/ICloudFederationProvider.php +++ b/lib/public/Federation/ICloudFederationProvider.php @@ -25,7 +25,7 @@ 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\Share\Exceptions\ShareNotFound; /** * Interface ICloudFederationProvider @@ -68,7 +68,7 @@ interface ICloudFederationProvider { * @param array $notification provider specific notification * @return array $data send back to sender * - * @throws ShareNotFoundException + * @throws ShareNotFound * @throws ActionNotSupportedException * @throws BadRequestException * @throws AuthenticationFailedException diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php index bcb12de8b8..4a1ac9b8b8 100644 --- a/lib/public/Share/IShareProvider.php +++ b/lib/public/Share/IShareProvider.php @@ -24,7 +24,6 @@ namespace OCP\Share; -use OCP\Federation\Exceptions\ShareNotFoundException; use OCP\Files\Folder; use OCP\Files\Node; @@ -125,7 +124,7 @@ interface IShareProvider { * @param int $id * @param string|null $recipientId * @return \OCP\Share\IShare - * @throws ShareNotFoundException + * @throws ShareNotFound * @since 9.0.0 */ public function getShareById($id, $recipientId = null);