Skip to content

Commit

Permalink
Move files_external storage services to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Aug 19, 2016
1 parent 4b0a008 commit aee765f
Show file tree
Hide file tree
Showing 29 changed files with 191 additions and 142 deletions.
5 changes: 3 additions & 2 deletions apps/files_external/appinfo/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

$app = \OC_Mount_Config::$app;

$globalStorageService = $app->getContainer()->query('\OCA\Files_External\Service\GlobalStoragesService');
$userStorageService = $app->getContainer()->query('\OCA\Files_External\Service\UserStoragesService');
$globalStorageService = OC::$server->getGlobalStoragesService();
$userStorageService = OC::$server->getUserStoragesService();
// TODO
$importLegacyStorageService = $app->getContainer()->query('\OCA\Files_External\Service\ImportLegacyStoragesService');
$backendService = OC::$server->getStoragesBackendService();

Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Command/Applicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

use OC\Core\Command\Base;
use OCP\Files\External\IStorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Files\External\NotFoundException;
use OC\Files\External\Service\GlobalStoragesService;
use OCP\IGroupManager;
use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Command/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

use OC\Core\Command\Base;
use OCP\Files\External\IStorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Files\External\NotFoundException;
use OC\Files\External\Service\GlobalStoragesService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableHelper;
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
use OCP\Files\External\DefinitionParameter;
use OCP\Files\External\IStorageConfig;
use OCP\Files\External\IStoragesBackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down
6 changes: 3 additions & 3 deletions apps/files_external/lib/Command/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
namespace OCA\Files_External\Command;

use OC\Core\Command\Base;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Files\External\NotFoundException;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down
8 changes: 4 additions & 4 deletions apps/files_external/lib/Command/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCA\Files_External\Lib\StorageConfig;
use OC\Files\External\Lib\StorageConfig;
use OCP\Files\External\IStorageConfig;
use OCP\Files\External\IStoragesBackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\ImportLegacyStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\ImportLegacyStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCP\Files\External\IStorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Helper\Table;
Expand Down
10 changes: 5 additions & 5 deletions apps/files_external/lib/Command/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
namespace OCA\Files_External\Command;

use OC\Core\Command\Base;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCP\Files\External\Auth\AuthMechanism;
use OCP\Files\External\Backend\Backend;
use OCP\Files\External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCP\Files\External\IStorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Files\External\NotFoundException;
use OC\Files\External\Service\GlobalStoragesService;
use OCP\Files\StorageNotAvailableException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down
4 changes: 2 additions & 2 deletions apps/files_external/lib/Config/ConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
use OCA\Files_External\Lib\PersonalMount;
use OCP\Files\Config\IMountProvider;
use OCP\IUser;
use OCA\Files_External\Service\UserStoragesService;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OC\Files\External\Service\UserGlobalStoragesService;
use OCP\Files\External\IStorageConfig;
use OC\Files\Storage\FailedStorage;
use OCP\Files\StorageNotAvailableException;
Expand Down
14 changes: 7 additions & 7 deletions apps/files_external/lib/Migration/StorageMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
namespace OCA\Files_External\Migration;

use OCP\Files\External\IStoragesBackendService;
use OCA\Files_External\Service\DBConfigService;
use OCA\Files_External\Service\GlobalLegacyStoragesService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\LegacyStoragesService;
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserLegacyStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OC\Files\External\Service\DBConfigService;
use OC\Files\External\Service\GlobalLegacyStoragesService;
use OC\Files\External\Service\GlobalStoragesService;
use OC\Files\External\Service\LegacyStoragesService;
use OC\Files\External\Service\StoragesService;
use OC\Files\External\Service\UserLegacyStoragesService;
use OC\Files\External\Service\UserStoragesService;
use OCP\Files\Config\IUserMountCache;
use OCP\IConfig;
use OCP\IDBConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;


use \OC\Files\Filesystem;
use OC\Files\Filesystem;

use OCP\Files\External\IStorageConfig;
use OCP\Files\External\IStoragesBackendService;

Expand All @@ -51,7 +52,7 @@ protected function triggerHooks(IStorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
['all']
);
return;
Expand All @@ -60,13 +61,13 @@ protected function triggerHooks(IStorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
$applicableUsers
);
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_GROUP,
IStorageConfig::MOUNT_TYPE_GROUP,
$applicableGroups
);
}
Expand Down Expand Up @@ -100,7 +101,7 @@ protected function triggerChangeHooks(IStorageConfig $oldStorage, IStorageConfig
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
['all']
);
}
Expand All @@ -109,31 +110,31 @@ protected function triggerChangeHooks(IStorageConfig $oldStorage, IStorageConfig
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
$userDeletions
);

// trigger delete for removed groups
$this->triggerApplicableHooks(
Filesystem::signal_delete_mount,
$oldStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_GROUP,
IStorageConfig::MOUNT_TYPE_GROUP,
$groupDeletions
);

// and now add the new users
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
$userAdditions
);

// and now add the new groups
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_GROUP,
IStorageConfig::MOUNT_TYPE_GROUP,
$groupAdditions
);

Expand All @@ -145,7 +146,7 @@ protected function triggerChangeHooks(IStorageConfig $oldStorage, IStorageConfig
$this->triggerApplicableHooks(
Filesystem::signal_create_mount,
$newStorage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
['all']
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OCP\Files\External\IStoragesBackendService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OCP\Files\External\IStorageConfig;
use OCP\Files\External\IStoragesBackendService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OC\Files\Filesystem;
use OC\Files\External\StorageConfig;

use OCP\Files\External\IStorageConfig;
use OCP\Files\External\Backend\Backend;
use OCP\Files\External\Auth\AuthMechanism;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\StorageNotAvailableException;
use OCP\Files\External\IStoragesBackendService;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCP\Files\External\NotFoundException;

/**
* Service class to manage external storages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OCP\Files\Config\IUserMountCache;
use OCP\IUserSession;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OCP\IUserSession;
use OCP\Files\External\IStoragesBackendService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use OC\Files\Filesystem;
use OC\Files\External\Service\UserTrait;

use OCP\Files\Config\IUserMountCache;
use OCP\IUserSession;
use OC\Files\Filesystem;

use OCP\Files\External\IStorageConfig;
use OCA\Files_External\NotFoundException;
use OCP\Files\External\NotFoundException;
use OCP\Files\External\IStoragesBackendService;
use OCA\Files_External\Service\UserTrait;

/**
* Service class to manage user external storages
Expand Down Expand Up @@ -77,7 +78,7 @@ protected function triggerHooks(IStorageConfig $storage, $signal) {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
\OC_Mount_Config::MOUNT_TYPE_USER,
IStorageConfig::MOUNT_TYPE_USER,
[$user]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

namespace OCA\Files_External\Service;
namespace OC\Files\External\Service;

use \OCP\IUserSession;
use \OCP\IUser;
Expand Down
18 changes: 15 additions & 3 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use OC\Files\External\StoragesBackendService;
use OC\Files\External\Service\UserStoragesService;
use OC\Files\External\Service\UserGlobalStoragesService;
use OC\Files\External\Service\GlobalStoragesService;

/**
* Class Server
Expand Down Expand Up @@ -662,6 +665,15 @@ public function __construct($webRoot, \OC\Config $config) {
$this->registerService('StoragesBackendService', function (Server $c) {
return new StoragesBackendService($c->query('AllConfig'));
});
$this->registerService('GlobalStoragesService', function (Server $c) {
return new GlobalStoragesService($c->query('AllConfig'));
});
$this->registerService('UserGlobalStoragesService', function (Server $c) {
return new UserGlobalStoragesService($c->query('AllConfig'));
});
$this->registerService('UserStoragesService', function (Server $c) {
return new UserStoragesService($c->query('AllConfig'));
});
$this->registerService('ShareManager', function(Server $c) {
$config = $c->getConfig();
$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
Expand Down Expand Up @@ -1335,7 +1347,7 @@ public function getStoragesBackendService() {
* @return \OCA\Files_External\Service\GlobalStoragesService
*/
public function getGlobalStoragesService() {
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\GlobalStoragesService');
return $this->query('GlobalStoragesService');
}

/**
Expand All @@ -1344,7 +1356,7 @@ public function getGlobalStoragesService() {
* @return \OCA\Files_External\Service\UserGlobalStoragesService
*/
public function getUserGlobalStoragesService() {
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
return $this->query('UserGlobalStoragesService');
}

/**
Expand All @@ -1353,7 +1365,7 @@ public function getUserGlobalStoragesService() {
* @return \OCA\Files_External\Service\UserStoragesService
*/
public function getUserStoragesService() {
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService');
return $this->query('UserStoragesService');
}

/**
Expand Down
Loading

0 comments on commit aee765f

Please sign in to comment.