diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-03-10 15:37:21 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-11 15:04:01 +0200 |
commit | 449011dae7ea0ec7eb8d6c78e89709982020e709 (patch) | |
tree | e102862917001ace40e23d7126973612cf7f2ac6 /apps/files_sharing/lib | |
parent | 0dea31d48bbd0361cca4d67b9de05a9f9ad3a198 (diff) | |
download | nextcloud-server-449011dae7ea0ec7eb8d6c78e89709982020e709.tar.gz nextcloud-server-449011dae7ea0ec7eb8d6c78e89709982020e709.zip |
remove discovery manager in favour of the OCSDiscoveryService
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 35 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Storage.php | 16 | ||||
-rw-r--r-- | apps/files_sharing/lib/Hooks.php | 6 |
4 files changed, 31 insertions, 32 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index f9540df3ff2..d4e83ce5d6b 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -92,17 +92,13 @@ class Application extends App { $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { $user = $server->getUserSession()->getUser(); $uid = $user ? $user->getUID() : null; - $discoveryManager = new DiscoveryManager( - \OC::$server->getMemCacheFactory(), - \OC::$server->getHTTPClientService() - ); return new \OCA\Files_Sharing\External\Manager( $server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPClientService(), $server->getNotificationManager(), - $discoveryManager, + $server->getOCSDiscoveryService(), $uid ); }); diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 0a57324c32f..2c348907384 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -32,8 +32,11 @@ namespace OCA\Files_Sharing\External; use OC\Files\Filesystem; use OCA\FederatedFileSharing\DiscoveryManager; use OCP\Files; +use OCP\Files\Storage\IStorageFactory; use OCP\Http\Client\IClientService; +use OCP\IDBConnection; use OCP\Notification\IManager; +use OCP\OCS\IDiscoveryService; class Manager { const STORAGE = '\OCA\Files_Sharing\External\Storage'; @@ -44,7 +47,7 @@ class Manager { private $uid; /** - * @var \OCP\IDBConnection + * @var IDBConnection */ private $connection; @@ -54,7 +57,7 @@ class Manager { private $mountManager; /** - * @var \OCP\Files\Storage\IStorageFactory + * @var IStorageFactory */ private $storageLoader; @@ -67,24 +70,27 @@ class Manager { * @var IManager */ private $notificationManager; - /** @var DiscoveryManager */ - private $discoveryManager; /** - * @param \OCP\IDBConnection $connection + * @var IDiscoveryService + */ + private $discoveryService; + + /** + * @param IDBConnection $connection * @param \OC\Files\Mount\Manager $mountManager - * @param \OCP\Files\Storage\IStorageFactory $storageLoader + * @param IStorageFactory $storageLoader * @param IClientService $clientService * @param IManager $notificationManager - * @param DiscoveryManager $discoveryManager + * @param IDiscoveryService $discoveryService * @param string $uid */ - public function __construct(\OCP\IDBConnection $connection, + public function __construct(IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, - \OCP\Files\Storage\IStorageFactory $storageLoader, + IStorageFactory $storageLoader, IClientService $clientService, IManager $notificationManager, - DiscoveryManager $discoveryManager, + IDiscoveryService $discoveryService, $uid) { $this->connection = $connection; $this->mountManager = $mountManager; @@ -92,7 +98,7 @@ class Manager { $this->clientService = $clientService; $this->uid = $uid; $this->notificationManager = $notificationManager; - $this->discoveryManager = $discoveryManager; + $this->discoveryService = $discoveryService; } /** @@ -260,7 +266,10 @@ class Manager { */ private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) { - $url = rtrim($remote, '/') . $this->discoveryManager->getShareEndpoint($remote) . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT; + $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING'); + $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; + + $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT; $fields = array('token' => $token); $client = $this->clientService->newClient(); @@ -376,7 +385,7 @@ class Manager { /** * remove re-shares from share table and mapping in the federated_reshares table - * + * * @param $mountPointId */ protected function removeReShares($mountPointId) { diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 51d97388db7..7e0f1fd0b75 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -51,8 +51,6 @@ class Storage extends DAV implements ISharedStorage { private $memcacheFactory; /** @var \OCP\Http\Client\IClientService */ private $httpClient; - /** @var \OCP\ICertificateManager */ - private $certificateManager; /** @var bool */ private $updateChecked = false; @@ -64,14 +62,11 @@ class Storage extends DAV implements ISharedStorage { public function __construct($options) { $this->memcacheFactory = \OC::$server->getMemCacheFactory(); $this->httpClient = $options['HttpClientService']; - $discoveryManager = new DiscoveryManager( - $this->memcacheFactory, - $this->httpClient - ); $this->manager = $options['manager']; - $this->certificateManager = $options['certificateManager']; $this->cloudId = $options['cloudId']; + $discoveryService = \OC::$server->getOCSDiscoveryService(); + list($protocol, $remote) = explode('://', $this->cloudId->getRemote()); if (strpos($remote, '/')) { list($host, $root) = explode('/', $remote, 2); @@ -80,9 +75,12 @@ class Storage extends DAV implements ISharedStorage { $root = ''; } $secure = $protocol === 'https'; - $root = rtrim($root, '/') . $discoveryManager->getWebDavEndpoint($this->cloudId->getRemote()); + $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING'); + $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav'; + $root = rtrim($root, '/') . $webDavEndpoint; $this->mountPoint = $options['mountpoint']; $this->token = $options['token']; + parent::__construct(array( 'secure' => $secure, 'host' => $host, @@ -350,7 +348,7 @@ class Storage extends DAV implements ISharedStorage { } return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } - + public function getPermissions($path) { $response = $this->propfind($path); if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index 2029e97d08b..8c5fc6a8d6a 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -32,17 +32,13 @@ use OCA\FederatedFileSharing\DiscoveryManager; class Hooks { public static function deleteUser($params) { - $discoveryManager = new DiscoveryManager( - \OC::$server->getMemCacheFactory(), - \OC::$server->getHTTPClientService() - ); $manager = new External\Manager( \OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPClientService(), \OC::$server->getNotificationManager(), - $discoveryManager, + \OC::$server->getOCSDiscoveryService(), $params['uid']); $manager->removeUserShares($params['uid']); |