|
|
@@ -42,11 +42,11 @@ use OCP\Federation\ICloudFederationFactory; |
|
|
|
use OCP\Federation\ICloudFederationProviderManager; |
|
|
|
use OCP\Federation\ICloudIdManager; |
|
|
|
use OCP\IDBConnection; |
|
|
|
use OCP\ILogger; |
|
|
|
use OCP\IRequest; |
|
|
|
use OCP\IUserManager; |
|
|
|
use OCP\Share; |
|
|
|
use OCP\Share\Exceptions\ShareNotFound; |
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
|
|
|
class RequestHandlerController extends OCSController { |
|
|
|
|
|
|
@@ -74,7 +74,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
/** @var ICloudIdManager */ |
|
|
|
private $cloudIdManager; |
|
|
|
|
|
|
|
/** @var ILogger */ |
|
|
|
/** @var LoggerInterface */ |
|
|
|
private $logger; |
|
|
|
|
|
|
|
/** @var ICloudFederationFactory */ |
|
|
@@ -83,23 +83,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
/** @var ICloudFederationProviderManager */ |
|
|
|
private $cloudFederationProviderManager; |
|
|
|
|
|
|
|
/** |
|
|
|
* Server2Server constructor. |
|
|
|
* |
|
|
|
* @param string $appName |
|
|
|
* @param IRequest $request |
|
|
|
* @param FederatedShareProvider $federatedShareProvider |
|
|
|
* @param IDBConnection $connection |
|
|
|
* @param Share\IManager $shareManager |
|
|
|
* @param Notifications $notifications |
|
|
|
* @param AddressHandler $addressHandler |
|
|
|
* @param IUserManager $userManager |
|
|
|
* @param ICloudIdManager $cloudIdManager |
|
|
|
* @param ILogger $logger |
|
|
|
* @param ICloudFederationFactory $cloudFederationFactory |
|
|
|
* @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
|
|
*/ |
|
|
|
public function __construct($appName, |
|
|
|
public function __construct(string $appName, |
|
|
|
IRequest $request, |
|
|
|
FederatedShareProvider $federatedShareProvider, |
|
|
|
IDBConnection $connection, |
|
|
@@ -108,7 +92,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
AddressHandler $addressHandler, |
|
|
|
IUserManager $userManager, |
|
|
|
ICloudIdManager $cloudIdManager, |
|
|
|
ILogger $logger, |
|
|
|
LoggerInterface $logger, |
|
|
|
ICloudFederationFactory $cloudFederationFactory, |
|
|
|
ICloudFederationProviderManager $cloudFederationProviderManager |
|
|
|
) { |
|
|
@@ -227,9 +211,9 @@ class RequestHandlerController extends OCSController { |
|
|
|
} catch (ProviderDoesNotExistsException $e) { |
|
|
|
throw new OCSException('Server does not support federated cloud sharing', 503); |
|
|
|
} catch (ShareNotFound $e) { |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} |
|
|
|
|
|
|
|
throw new OCSBadRequestException(); |
|
|
@@ -262,9 +246,9 @@ class RequestHandlerController extends OCSController { |
|
|
|
} catch (ProviderDoesNotExistsException $e) { |
|
|
|
throw new OCSException('Server does not support federated cloud sharing', 503); |
|
|
|
} catch (ShareNotFound $e) { |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} |
|
|
|
|
|
|
|
return new Http\DataResponse(); |
|
|
@@ -294,9 +278,9 @@ class RequestHandlerController extends OCSController { |
|
|
|
} catch (ProviderDoesNotExistsException $e) { |
|
|
|
throw new OCSException('Server does not support federated cloud sharing', 503); |
|
|
|
} catch (ShareNotFound $e) { |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('Share not found: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} |
|
|
|
|
|
|
|
return new Http\DataResponse(); |
|
|
@@ -324,7 +308,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
$notification = ['sharedSecret' => $token]; |
|
|
|
$provider->notificationReceived('SHARE_UNSHARED', $id, $notification); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->logger->debug('processing unshare notification failed: ' . $e->getMessage()); |
|
|
|
$this->logger->debug('processing unshare notification failed: ' . $e->getMessage(), ['exception' => $e]); |
|
|
|
} |
|
|
|
|
|
|
|
return new Http\DataResponse(); |
|
|
@@ -398,7 +382,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
$notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions]; |
|
|
|
$provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->logger->debug($e->getMessage()); |
|
|
|
$this->logger->debug($e->getMessage(), ['exception' => $e]); |
|
|
|
throw new OCSBadRequestException(); |
|
|
|
} |
|
|
|
|
|
|
@@ -458,7 +442,7 @@ class RequestHandlerController extends OCSController { |
|
|
|
->set('remote_id', $qb->createNamedParameter($newRemoteId)) |
|
|
|
->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id))) |
|
|
|
->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token))); |
|
|
|
$affected = $query->execute(); |
|
|
|
$affected = $query->executeUpdate(); |
|
|
|
|
|
|
|
if ($affected > 0) { |
|
|
|
return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]); |