Quellcode durchsuchen

replace \OCP\Federation\Exception\ShareNotFoundException with the generic \OCP\Share\Exception\ShareNotFound exception

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
tags/v14.0.0beta1
Bjoern Schiessle vor 6 Jahren
Ursprung
Commit
957b27f282
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 2
- 2
apps/cloud_federation_api/lib/Controller/RequestHandlerController.php Datei anzeigen

@@ -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

+ 6
- 15
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php Datei anzeigen

@@ -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());

+ 2
- 3
apps/federatedfilesharing/lib/FederatedShareProvider.php Datei anzeigen

@@ -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;

+ 14
- 14
apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php Datei anzeigen

@@ -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) {


+ 3
- 1
lib/composer/composer/autoload_classmap.php Datei anzeigen

@@ -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',

+ 3
- 1
lib/composer/composer/autoload_static.php Datei anzeigen

@@ -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',

+ 0
- 29
lib/public/Federation/Exceptions/ShareNotFoundException.php Datei anzeigen

@@ -1,29 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

namespace OCP\Federation\Exceptions;


use OC\HintException;

class ShareNotFoundException extends HintException {

}

+ 2
- 2
lib/public/Federation/ICloudFederationProvider.php Datei anzeigen

@@ -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

+ 1
- 2
lib/public/Share/IShareProvider.php Datei anzeigen

@@ -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);

Laden…
Abbrechen
Speichern