]> source.dussan.org Git - nextcloud-server.git/commitdiff
Migrate federated file sharing to PSR LoggerInterface 39160/head
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Wed, 5 Jul 2023 09:42:41 +0000 (11:42 +0200)
committerBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Fri, 7 Jul 2023 07:00:35 +0000 (09:00 +0200)
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
apps/federatedfilesharing/lib/FederatedShareProvider.php
apps/federatedfilesharing/lib/Notifications.php
apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
apps/federatedfilesharing/tests/FederatedShareProviderTest.php
apps/federatedfilesharing/tests/NotificationsTest.php
lib/private/Share20/ProviderFactory.php

index f785f4fc52861e3d4565ea1b70edfae4e4572de3..98fe20bf46e1b2ef2a7fc4d0031f9fdcd10330d3 100644 (file)
@@ -30,7 +30,6 @@ use OCA\FederatedFileSharing\Notifications;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\BackgroundJob\IJobList;
 use OCP\BackgroundJob\Job;
-use OCP\ILogger;
 
 /**
  * Class RetryJob
index 404077e46affe510de938cd9f4c14d8a0553a9cd..7042715b70c475452aa4e69702c9934e68f93472 100644 (file)
@@ -41,12 +41,12 @@ use OCP\Federation\ICloudIdManager;
 use OCP\HintException;
 use OCP\Http\Client\IClientService;
 use OCP\IL10N;
-use OCP\ILogger;
 use OCP\IRequest;
 use OCP\ISession;
 use OCP\IUserSession;
 use OCP\Share\IManager;
 use OCP\Share\IShare;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class MountPublicLinkController
@@ -56,66 +56,23 @@ use OCP\Share\IShare;
  * @package OCA\FederatedFileSharing\Controller
  */
 class MountPublicLinkController extends Controller {
-
-       /** @var FederatedShareProvider */
-       private $federatedShareProvider;
-
-       /** @var AddressHandler */
-       private $addressHandler;
-
-       /** @var IManager  */
-       private $shareManager;
-
-       /** @var  ISession */
-       private $session;
-
-       /** @var IL10N */
-       private $l;
-
-       /** @var IUserSession */
-       private $userSession;
-
-       /** @var IClientService */
-       private $clientService;
-
-       /** @var ICloudIdManager  */
-       private $cloudIdManager;
-
        /**
         * MountPublicLinkController constructor.
-        *
-        * @param string $appName
-        * @param IRequest $request
-        * @param FederatedShareProvider $federatedShareProvider
-        * @param IManager $shareManager
-        * @param AddressHandler $addressHandler
-        * @param ISession $session
-        * @param IL10N $l
-        * @param IUserSession $userSession
-        * @param IClientService $clientService
-        * @param ICloudIdManager $cloudIdManager
         */
-       public function __construct($appName,
-                                                               IRequest $request,
-                                                               FederatedShareProvider $federatedShareProvider,
-                                                               IManager $shareManager,
-                                                               AddressHandler $addressHandler,
-                                                               ISession $session,
-                                                               IL10N $l,
-                                                               IUserSession $userSession,
-                                                               IClientService $clientService,
-                                                               ICloudIdManager $cloudIdManager
+       public function __construct(
+               string $appName,
+               IRequest $request,
+               private FederatedShareProvider $federatedShareProvider,
+               private IManager $shareManager,
+               private AddressHandler $addressHandler,
+               private ISession $session,
+               private IL10N $l,
+               private IUserSession $userSession,
+               private IClientService $clientService,
+               private ICloudIdManager $cloudIdManager,
+               private LoggerInterface $logger,
        ) {
                parent::__construct($appName, $request);
-
-               $this->federatedShareProvider = $federatedShareProvider;
-               $this->shareManager = $shareManager;
-               $this->addressHandler = $addressHandler;
-               $this->session = $session;
-               $this->l = $l;
-               $this->userSession = $userSession;
-               $this->clientService = $clientService;
-               $this->cloudIdManager = $cloudIdManager;
        }
 
        /**
@@ -175,9 +132,9 @@ class MountPublicLinkController extends Controller {
                try {
                        $this->federatedShareProvider->create($share);
                } catch (\Exception $e) {
-                       \OC::$server->getLogger()->logException($e, [
-                               'level' => ILogger::WARN,
+                       $this->logger->warning($e->getMessage(), [
                                'app' => 'federatedfilesharing',
+                               'exception' => $e,
                        ]);
                        return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
                }
index b4fedecfd4214013610987b1f4eae6f0f3ff6694..6157bad0335521dec64352c7039e8cc07ac7b7f5 100644 (file)
@@ -50,12 +50,12 @@ use OCP\Files\NotFoundException;
 use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IL10N;
-use OCP\ILogger;
 use OCP\IUserManager;
 use OCP\Share\Exceptions\GenericShareException;
 use OCP\Share\Exceptions\ShareNotFound;
 use OCP\Share\IShare;
 use OCP\Share\IShareProvider;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class FederatedShareProvider
@@ -65,90 +65,29 @@ use OCP\Share\IShareProvider;
 class FederatedShareProvider implements IShareProvider {
        public const SHARE_TYPE_REMOTE = 6;
 
-       /** @var IDBConnection */
-       private $dbConnection;
-
-       /** @var AddressHandler */
-       private $addressHandler;
-
-       /** @var Notifications */
-       private $notifications;
-
-       /** @var TokenHandler */
-       private $tokenHandler;
-
-       /** @var IL10N */
-       private $l;
-
-       /** @var ILogger */
-       private $logger;
-
-       /** @var IRootFolder */
-       private $rootFolder;
-
-       /** @var IConfig */
-       private $config;
-
        /** @var string */
        private $externalShareTable = 'share_external';
 
-       /** @var IUserManager */
-       private $userManager;
-
-       /** @var ICloudIdManager */
-       private $cloudIdManager;
-
-       /** @var \OCP\GlobalScale\IConfig */
-       private $gsConfig;
-
-       /** @var ICloudFederationProviderManager */
-       private $cloudFederationProviderManager;
-
        /** @var array list of supported share types */
        private $supportedShareType = [IShare::TYPE_REMOTE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_CIRCLE];
 
        /**
         * DefaultShareProvider constructor.
-        *
-        * @param IDBConnection $connection
-        * @param AddressHandler $addressHandler
-        * @param Notifications $notifications
-        * @param TokenHandler $tokenHandler
-        * @param IL10N $l10n
-        * @param ILogger $logger
-        * @param IRootFolder $rootFolder
-        * @param IConfig $config
-        * @param IUserManager $userManager
-        * @param ICloudIdManager $cloudIdManager
-        * @param \OCP\GlobalScale\IConfig $globalScaleConfig
-        * @param ICloudFederationProviderManager $cloudFederationProviderManager
         */
        public function __construct(
-                       IDBConnection $connection,
-                       AddressHandler $addressHandler,
-                       Notifications $notifications,
-                       TokenHandler $tokenHandler,
-                       IL10N $l10n,
-                       ILogger $logger,
-                       IRootFolder $rootFolder,
-                       IConfig $config,
-                       IUserManager $userManager,
-                       ICloudIdManager $cloudIdManager,
-                       \OCP\GlobalScale\IConfig $globalScaleConfig,
-                       ICloudFederationProviderManager $cloudFederationProviderManager
+                       private IDBConnection $dbConnection,
+                       private AddressHandler $addressHandler,
+                       private Notifications $notifications,
+                       private TokenHandler $tokenHandler,
+                       private IL10N $l,
+                       private IRootFolder $rootFolder,
+                       private IConfig $config,
+                       private IUserManager $userManager,
+                       private ICloudIdManager $cloudIdManager,
+                       private \OCP\GlobalScale\IConfig $gsConfig,
+                       private ICloudFederationProviderManager $cloudFederationProviderManager,
+                       private LoggerInterface $logger,
        ) {
-               $this->dbConnection = $connection;
-               $this->addressHandler = $addressHandler;
-               $this->notifications = $notifications;
-               $this->tokenHandler = $tokenHandler;
-               $this->l = $l10n;
-               $this->logger = $logger;
-               $this->rootFolder = $rootFolder;
-               $this->config = $config;
-               $this->userManager = $userManager;
-               $this->cloudIdManager = $cloudIdManager;
-               $this->gsConfig = $globalScaleConfig;
-               $this->cloudFederationProviderManager = $cloudFederationProviderManager;
        }
 
        /**
@@ -303,10 +242,9 @@ class FederatedShareProvider implements IShareProvider {
                                $failure = true;
                        }
                } catch (\Exception $e) {
-                       $this->logger->logException($e, [
-                               'message' => 'Failed to notify remote server of federated share, removing share.',
-                               'level' => ILogger::ERROR,
+                       $this->logger->error('Failed to notify remote server of federated share, removing share.', [
                                'app' => 'federatedfilesharing',
+                               'exception' => $e,
                        ]);
                        $failure = true;
                }
@@ -873,7 +811,6 @@ class FederatedShareProvider implements IShareProvider {
         * @throws ShareNotFound
         */
        private function getRawShare($id) {
-
                // Now fetch the inserted share and create a complete share object
                $qb = $this->dbConnection->getQueryBuilder();
                $qb->select('*')
index 2a162abcd76ba9865e05435bfe86a832beedcbca..f0d50a25abeff422a1afef0954df161a4ef11dd2 100644 (file)
@@ -34,54 +34,22 @@ use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Federation\ICloudFederationFactory;
 use OCP\Federation\ICloudFederationProviderManager;
 use OCP\Http\Client\IClientService;
-use OCP\ILogger;
 use OCP\OCS\IDiscoveryService;
+use Psr\Log\LoggerInterface;
 
 class Notifications {
        public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls
 
-       /** @var AddressHandler */
-       private $addressHandler;
-
-       /** @var IClientService */
-       private $httpClientService;
-
-       /** @var IDiscoveryService */
-       private $discoveryService;
-
-       /** @var IJobList  */
-       private $jobList;
-
-       /** @var ICloudFederationProviderManager */
-       private $federationProviderManager;
-
-       /** @var ICloudFederationFactory */
-       private $cloudFederationFactory;
-
-       /** @var IEventDispatcher */
-       private $eventDispatcher;
-
-       /** @var ILogger */
-       private $logger;
-
        public function __construct(
-               AddressHandler $addressHandler,
-               IClientService $httpClientService,
-               IDiscoveryService $discoveryService,
-               ILogger $logger,
-               IJobList $jobList,
-               ICloudFederationProviderManager $federationProviderManager,
-               ICloudFederationFactory $cloudFederationFactory,
-               IEventDispatcher $eventDispatcher
+               private AddressHandler $addressHandler,
+               private IClientService $httpClientService,
+               private IDiscoveryService $discoveryService,
+               private IJobList $jobList,
+               private ICloudFederationProviderManager $federationProviderManager,
+               private ICloudFederationFactory $cloudFederationFactory,
+               private IEventDispatcher $eventDispatcher,
+               private LoggerInterface $logger,
        ) {
-               $this->addressHandler = $addressHandler;
-               $this->httpClientService = $httpClientService;
-               $this->discoveryService = $discoveryService;
-               $this->jobList = $jobList;
-               $this->logger = $logger;
-               $this->federationProviderManager = $federationProviderManager;
-               $this->cloudFederationFactory = $cloudFederationFactory;
-               $this->eventDispatcher = $eventDispatcher;
        }
 
        /**
index 5e2cafe0ce047826c65faac53e294fdf0c645e0c..6ae334f1991d195802a337b918b5c626b832c87c 100644 (file)
@@ -51,7 +51,6 @@ use OCP\HintException;
 use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IGroupManager;
-use OCP\ILogger;
 use OCP\IURLGenerator;
 use OCP\IUserManager;
 use OCP\Notification\IManager as INotificationManager;
@@ -60,117 +59,32 @@ use OCP\Share\Exceptions\ShareNotFound;
 use OCP\Share\IManager;
 use OCP\Share\IShare;
 use OCP\Util;
-use Psr\Container\ContainerExceptionInterface;
 use Psr\Log\LoggerInterface;
 
 class CloudFederationProviderFiles implements ICloudFederationProvider {
-
-       /** @var IAppManager */
-       private $appManager;
-
-       /** @var FederatedShareProvider */
-       private $federatedShareProvider;
-
-       /** @var AddressHandler */
-       private $addressHandler;
-
-       /** @var ILogger */
-       private $logger;
-
-       /** @var IUserManager */
-       private $userManager;
-
-       /** @var IManager */
-       private $shareManager;
-
-       /** @var ICloudIdManager */
-       private $cloudIdManager;
-
-       /** @var IActivityManager */
-       private $activityManager;
-
-       /** @var INotificationManager */
-       private $notificationManager;
-
-       /** @var IURLGenerator */
-       private $urlGenerator;
-
-       /** @var ICloudFederationFactory */
-       private $cloudFederationFactory;
-
-       /** @var ICloudFederationProviderManager */
-       private $cloudFederationProviderManager;
-
-       /** @var IDBConnection */
-       private $connection;
-
-       /** @var IGroupManager */
-       private $groupManager;
-
-       /** @var IConfig */
-       private $config;
-
-       /** @var Manager */
-       private $externalShareManager;
-
        /**
         * CloudFederationProvider constructor.
-        *
-        * @param IAppManager $appManager
-        * @param FederatedShareProvider $federatedShareProvider
-        * @param AddressHandler $addressHandler
-        * @param ILogger $logger
-        * @param IUserManager $userManager
-        * @param IManager $shareManager
-        * @param ICloudIdManager $cloudIdManager
-        * @param IActivityManager $activityManager
-        * @param INotificationManager $notificationManager
-        * @param IURLGenerator $urlGenerator
-        * @param ICloudFederationFactory $cloudFederationFactory
-        * @param ICloudFederationProviderManager $cloudFederationProviderManager
-        * @param IDBConnection $connection
-        * @param IGroupManager $groupManager
-        * @param IConfig $config
-        * @param Manager $externalShareManager
         */
        public function __construct(
-               IAppManager $appManager,
-               FederatedShareProvider $federatedShareProvider,
-               AddressHandler $addressHandler,
-               ILogger $logger,
-               IUserManager $userManager,
-               IManager $shareManager,
-               ICloudIdManager $cloudIdManager,
-               IActivityManager $activityManager,
-               INotificationManager $notificationManager,
-               IURLGenerator $urlGenerator,
-               ICloudFederationFactory $cloudFederationFactory,
-               ICloudFederationProviderManager $cloudFederationProviderManager,
-               IDBConnection $connection,
-               IGroupManager $groupManager,
-               IConfig $config,
-               Manager $externalShareManager
+               private IAppManager $appManager,
+               private FederatedShareProvider $federatedShareProvider,
+               private AddressHandler $addressHandler,
+               private IUserManager $userManager,
+               private IManager $shareManager,
+               private ICloudIdManager $cloudIdManager,
+               private IActivityManager $activityManager,
+               private INotificationManager $notificationManager,
+               private IURLGenerator $urlGenerator,
+               private ICloudFederationFactory $cloudFederationFactory,
+               private ICloudFederationProviderManager $cloudFederationProviderManager,
+               private IDBConnection $connection,
+               private IGroupManager $groupManager,
+               private IConfig $config,
+               private Manager $externalShareManager,
+               private LoggerInterface $logger,
        ) {
-               $this->appManager = $appManager;
-               $this->federatedShareProvider = $federatedShareProvider;
-               $this->addressHandler = $addressHandler;
-               $this->logger = $logger;
-               $this->userManager = $userManager;
-               $this->shareManager = $shareManager;
-               $this->cloudIdManager = $cloudIdManager;
-               $this->activityManager = $activityManager;
-               $this->notificationManager = $notificationManager;
-               $this->urlGenerator = $urlGenerator;
-               $this->cloudFederationFactory = $cloudFederationFactory;
-               $this->cloudFederationProviderManager = $cloudFederationProviderManager;
-               $this->connection = $connection;
-               $this->groupManager = $groupManager;
-               $this->config = $config;
-               $this->externalShareManager = $externalShareManager;
        }
 
-
-
        /**
         * @return string
         */
@@ -239,18 +153,18 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
                                $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
 
                                if (!$this->userManager->userExists($shareWith)) {
-                                       throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
+                                       throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST);
                                }
 
                                \OC_Util::setupFS($shareWith);
                        }
 
                        if ($shareType === IShare::TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) {
-                               throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST);
+                               throw new ProviderCouldNotAddShareException('Group does not exists', '', Http::STATUS_BAD_REQUEST);
                        }
 
                        try {
-                               $this->externalShareManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId);
+                               $this->externalShareManager->addShare($remote, $token, '', $name, $owner, $shareType, false, $shareWith, $remoteId);
                                $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
 
                                // get DisplayName about the owner of the share
@@ -280,10 +194,9 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
                                }
                                return $shareId;
                        } catch (\Exception $e) {
-                               $this->logger->logException($e, [
-                                       'message' => 'Server can not add remote share.',
-                                       'level' => ILogger::ERROR,
-                                       'app' => 'files_sharing'
+                               $this->logger->error('Server can not add remote share.', [
+                                       'app' => 'files_sharing',
+                                       'exception' => $e,
                                ]);
                                throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
                        }
index b04b7810910693f624801fc745f839227636add6..7cc788d3a6cefde93c830f0552ab768ad244617d 100644 (file)
@@ -48,48 +48,50 @@ use OCP\IUserManager;
 use OCP\IUserSession;
 use OCP\Share\IManager;
 use OCP\Share\IShare;
+use Psr\Log\LoggerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
 
 class MountPublicLinkControllerTest extends \Test\TestCase {
-       /** @var IContactsManager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var IContactsManager|MockObject */
        protected $contactsManager;
 
-       /** @var  MountPublicLinkController */
+       /** @var MountPublicLinkController */
        private $controller;
 
-       /** @var  \OCP\IRequest | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IRequest|MockObject */
        private $request;
 
-       /** @var  FederatedShareProvider | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var FederatedShareProvider|MockObject */
        private $federatedShareProvider;
 
-       /** @var  IManager | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IManager|MockObject */
        private $shareManager;
 
-       /** @var  AddressHandler | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var AddressHandler|MockObject */
        private $addressHandler;
 
-       /** @var  IRootFolder | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IRootFolder|MockObject */
        private $rootFolder;
 
-       /** @var  IUserManager | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IUserManager|MockObject */
        private $userManager;
 
-       /** @var  ISession | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var ISession|MockObject */
        private $session;
 
-       /** @var  IL10N | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IL10N|MockObject */
        private $l10n;
 
-       /** @var  IUserSession | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IUserSession|MockObject */
        private $userSession;
 
-       /** @var  IClientService | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IClientService|MockObject */
        private $clientService;
 
-       /** @var  IShare */
+       /** @var IShare */
        private $share;
 
-       /** @var  ICloudIdManager */
+       /** @var ICloudIdManager */
        private $cloudIdManager;
 
        protected function setUp(): void {
@@ -126,7 +128,8 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
                        $this->l10n,
                        $this->userSession,
                        $this->clientService,
-                       $this->cloudIdManager
+                       $this->cloudIdManager,
+                       $this->createMock(LoggerInterface::class),
                );
        }
 
index 797d029d6b1520453e8eb1f52559c2d755e15c1a..744cb769c549f6aed86acd78152e4f120fd22b1b 100644 (file)
@@ -47,12 +47,12 @@ use OCP\ICacheFactory;
 use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IL10N;
-use OCP\ILogger;
 use OCP\IURLGenerator;
 use OCP\IUserManager;
 use OCP\Share\IManager;
 use OCP\Share\IShare;
 use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class FederatedShareProviderTest
@@ -61,39 +61,38 @@ use PHPUnit\Framework\MockObject\MockObject;
  * @group DB
  */
 class FederatedShareProviderTest extends \Test\TestCase {
-
        /** @var IDBConnection */
        protected $connection;
-       /** @var AddressHandler | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var AddressHandler|MockObject */
        protected $addressHandler;
-       /** @var Notifications | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var Notifications|MockObject */
        protected $notifications;
-       /** @var TokenHandler|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var TokenHandler|MockObject */
        protected $tokenHandler;
        /** @var IL10N */
        protected $l;
-       /** @var ILogger */
+       /** @var LoggerInterface */
        protected $logger;
-       /** @var IRootFolder | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IRootFolder|MockObject */
        protected $rootFolder;
-       /** @var  IConfig | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var  IConfig|MockObject */
        protected $config;
-       /** @var  IUserManager | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var  IUserManager|MockObject */
        protected $userManager;
-       /** @var  \OCP\GlobalScale\IConfig|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var  \OCP\GlobalScale\IConfig|MockObject */
        protected $gsConfig;
 
        /** @var IManager */
        protected $shareManager;
        /** @var FederatedShareProvider */
        protected $provider;
-       /** @var IContactsManager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var IContactsManager|MockObject */
        protected $contactsManager;
 
        /** @var  ICloudIdManager */
        private $cloudIdManager;
 
-       /** @var \PHPUnit\Framework\MockObject\MockObject|ICloudFederationProviderManager */
+       /** @var MockObject|ICloudFederationProviderManager */
        private $cloudFederationProviderManager;
 
        protected function setUp(): void {
@@ -111,7 +110,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
                        ->willReturnCallback(function ($text, $parameters = []) {
                                return vsprintf($text, $parameters);
                        });
-               $this->logger = $this->getMockBuilder(ILogger::class)->getMock();
+               $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
                $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
                $this->config = $this->getMockBuilder(IConfig::class)->getMock();
                $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
@@ -137,13 +136,13 @@ class FederatedShareProviderTest extends \Test\TestCase {
                        $this->notifications,
                        $this->tokenHandler,
                        $this->l,
-                       $this->logger,
                        $this->rootFolder,
                        $this->config,
                        $this->userManager,
                        $this->cloudIdManager,
                        $this->gsConfig,
-                       $this->cloudFederationProviderManager
+                       $this->cloudFederationProviderManager,
+                       $this->logger,
                );
 
                $this->shareManager = \OC::$server->getShareManager();
@@ -476,13 +475,13 @@ class FederatedShareProviderTest extends \Test\TestCase {
                                        $this->notifications,
                                        $this->tokenHandler,
                                        $this->l,
-                                       $this->logger,
                                        $this->rootFolder,
                                        $this->config,
                                        $this->userManager,
                                        $this->cloudIdManager,
                                        $this->gsConfig,
-                                       $this->cloudFederationProviderManager
+                                       $this->cloudFederationProviderManager,
+                                       $this->logger,
                                ]
                        )->setMethods(['sendPermissionUpdate'])->getMock();
 
index c77d9affb17a5650ff3c8b149cec2a4e4809e95d..e9027564d87be2cd167a4366aac45bea12c38ccd 100644 (file)
@@ -32,33 +32,33 @@ use OCP\EventDispatcher\IEventDispatcher;
 use OCP\Federation\ICloudFederationFactory;
 use OCP\Federation\ICloudFederationProviderManager;
 use OCP\Http\Client\IClientService;
-use OCP\ILogger;
 use OCP\OCS\IDiscoveryService;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
 
 class NotificationsTest extends \Test\TestCase {
-
-       /** @var  AddressHandler | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var AddressHandler|MockObject */
        private $addressHandler;
 
-       /** @var  IClientService | \PHPUnit\Framework\MockObject\MockObject*/
+       /** @var IClientService|MockObject*/
        private $httpClientService;
 
-       /** @var  IDiscoveryService | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IDiscoveryService|MockObject */
        private $discoveryService;
 
-       /** @var  IJobList | \PHPUnit\Framework\MockObject\MockObject */
+       /** @var IJobList|MockObject */
        private $jobList;
 
-       /** @var ICloudFederationProviderManager|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var ICloudFederationProviderManager|MockObject */
        private $cloudFederationProviderManager;
 
-       /** @var ICloudFederationFactory|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var ICloudFederationFactory|MockObject */
        private $cloudFederationFactory;
 
-       /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var IEventDispatcher|MockObject */
        private $eventDispatcher;
 
-       /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+       /** @var LoggerInterface|MockObject */
        private $logger;
 
        protected function setUp(): void {
@@ -69,7 +69,7 @@ class NotificationsTest extends \Test\TestCase {
                $this->httpClientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->getMock();
                $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')
                        ->disableOriginalConstructor()->getMock();
-               $this->logger = $this->createMock(ILogger::class);
+               $this->logger = $this->createMock(LoggerInterface::class);
                $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
                $this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
                $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
@@ -87,11 +87,11 @@ class NotificationsTest extends \Test\TestCase {
                                $this->addressHandler,
                                $this->httpClientService,
                                $this->discoveryService,
-                               $this->logger,
                                $this->jobList,
                                $this->cloudFederationProviderManager,
                                $this->cloudFederationFactory,
-                               $this->eventDispatcher
+                               $this->eventDispatcher,
+                               $this->logger,
                        );
                } else {
                        $instance = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications')
@@ -100,11 +100,11 @@ class NotificationsTest extends \Test\TestCase {
                                                $this->addressHandler,
                                                $this->httpClientService,
                                                $this->discoveryService,
-                                               $this->logger,
                                                $this->jobList,
                                                $this->cloudFederationProviderManager,
                                                $this->cloudFederationFactory,
-                                               $this->eventDispatcher
+                                               $this->eventDispatcher,
+                                               $this->logger,
                                        ]
                                )->setMethods($mockedMethods)->getMock();
                }
index 6abfb372a4d1ebdb173a8408b8c5529bd63f130f..8c01d6609155cb918d0361ba71f34c71b7473295 100644 (file)
@@ -139,11 +139,11 @@ class ProviderFactory implements IProviderFactory {
                                $addressHandler,
                                $this->serverContainer->getHTTPClientService(),
                                $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
-                               $this->serverContainer->getLogger(),
                                $this->serverContainer->getJobList(),
                                \OC::$server->getCloudFederationProviderManager(),
                                \OC::$server->getCloudFederationFactory(),
-                               $this->serverContainer->query(IEventDispatcher::class)
+                               $this->serverContainer->query(IEventDispatcher::class),
+                               $this->serverContainer->get(LoggerInterface::class),
                        );
                        $tokenHandler = new TokenHandler(
                                $this->serverContainer->getSecureRandom()
@@ -155,13 +155,13 @@ class ProviderFactory implements IProviderFactory {
                                $notifications,
                                $tokenHandler,
                                $l,
-                               $this->serverContainer->getLogger(),
                                $this->serverContainer->getLazyRootFolder(),
                                $this->serverContainer->getConfig(),
                                $this->serverContainer->getUserManager(),
                                $this->serverContainer->getCloudIdManager(),
                                $this->serverContainer->getGlobalScaleConfig(),
-                               $this->serverContainer->getCloudFederationProviderManager()
+                               $this->serverContainer->getCloudFederationProviderManager(),
+                               $this->serverContainer->get(LoggerInterface::class),
                        );
                }