diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 11 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 11 | ||||
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 1 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Collection.php | 43 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 31 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Resource.php | 7 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/ICollection.php | 6 | ||||
-rw-r--r-- | lib/public/Collaboration/Resources/IManager.php | 4 |
8 files changed, 93 insertions, 21 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index e1f5e2b8c9c..af347b1ea92 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -112,6 +112,12 @@ return array( 'OCP\\Collaboration\\Collaborators\\ISearchPlugin' => $baseDir . '/lib/public/Collaboration/Collaborators/ISearchPlugin.php', 'OCP\\Collaboration\\Collaborators\\ISearchResult' => $baseDir . '/lib/public/Collaboration/Collaborators/ISearchResult.php', 'OCP\\Collaboration\\Collaborators\\SearchResultType' => $baseDir . '/lib/public/Collaboration/Collaborators/SearchResultType.php', + 'OCP\\Collaboration\\Resources\\CollectionException' => $baseDir . '/lib/public/Collaboration/Resources/CollectionException.php', + 'OCP\\Collaboration\\Resources\\ICollection' => $baseDir . '/lib/public/Collaboration/Resources/ICollection.php', + 'OCP\\Collaboration\\Resources\\IManager' => $baseDir . '/lib/public/Collaboration/Resources/IManager.php', + 'OCP\\Collaboration\\Resources\\IProvider' => $baseDir . '/lib/public/Collaboration/Resources/IProvider.php', + 'OCP\\Collaboration\\Resources\\IResource' => $baseDir . '/lib/public/Collaboration/Resources/IResource.php', + 'OCP\\Collaboration\\Resources\\ResourceException' => $baseDir . '/lib/public/Collaboration/Resources/ResourceException.php', 'OCP\\Command\\IBus' => $baseDir . '/lib/public/Command/IBus.php', 'OCP\\Command\\ICommand' => $baseDir . '/lib/public/Command/ICommand.php', 'OCP\\Comments\\CommentsEntityEvent' => $baseDir . '/lib/public/Comments/CommentsEntityEvent.php', @@ -544,6 +550,9 @@ return array( 'OC\\Collaboration\\Collaborators\\Search' => $baseDir . '/lib/private/Collaboration/Collaborators/Search.php', 'OC\\Collaboration\\Collaborators\\SearchResult' => $baseDir . '/lib/private/Collaboration/Collaborators/SearchResult.php', 'OC\\Collaboration\\Collaborators\\UserPlugin' => $baseDir . '/lib/private/Collaboration/Collaborators/UserPlugin.php', + 'OC\\Collaboration\\Resources\\Collection' => $baseDir . '/lib/private/Collaboration/Resources/Collection.php', + 'OC\\Collaboration\\Resources\\Manager' => $baseDir . '/lib/private/Collaboration/Resources/Manager.php', + 'OC\\Collaboration\\Resources\\Resource' => $baseDir . '/lib/private/Collaboration/Resources/Resource.php', 'OC\\Color' => $baseDir . '/lib/private/Color.php', 'OC\\Command\\AsyncBus' => $baseDir . '/lib/private/Command/AsyncBus.php', 'OC\\Command\\CallableJob' => $baseDir . '/lib/private/Command/CallableJob.php', @@ -659,6 +668,7 @@ return array( 'OC\\Core\\Controller\\CSRFTokenController' => $baseDir . '/core/Controller/CSRFTokenController.php', 'OC\\Core\\Controller\\ClientFlowLoginController' => $baseDir . '/core/Controller/ClientFlowLoginController.php', 'OC\\Core\\Controller\\ClientFlowLoginV2Controller' => $baseDir . '/core/Controller/ClientFlowLoginV2Controller.php', + 'OC\\Core\\Controller\\CollaborationResourcesController' => $baseDir . '/core/Controller/CollaborationResourcesController.php', 'OC\\Core\\Controller\\ContactsMenuController' => $baseDir . '/core/Controller/ContactsMenuController.php', 'OC\\Core\\Controller\\CssController' => $baseDir . '/core/Controller/CssController.php', 'OC\\Core\\Controller\\GuestAvatarController' => $baseDir . '/core/Controller/GuestAvatarController.php', @@ -695,6 +705,7 @@ return array( 'OC\\Core\\Migrations\\Version14000Date20180626223656' => $baseDir . '/core/Migrations/Version14000Date20180626223656.php', 'OC\\Core\\Migrations\\Version14000Date20180710092004' => $baseDir . '/core/Migrations/Version14000Date20180710092004.php', 'OC\\Core\\Migrations\\Version14000Date20180712153140' => $baseDir . '/core/Migrations/Version14000Date20180712153140.php', + 'OC\\Core\\Migrations\\Version15000Date20180917092725' => $baseDir . '/core/Migrations/Version15000Date20180917092725.php', 'OC\\Core\\Migrations\\Version15000Date20180926101451' => $baseDir . '/core/Migrations/Version15000Date20180926101451.php', 'OC\\Core\\Migrations\\Version15000Date20181015062942' => $baseDir . '/core/Migrations/Version15000Date20181015062942.php', 'OC\\Core\\Migrations\\Version15000Date20181029084625' => $baseDir . '/core/Migrations/Version15000Date20181029084625.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 3f7132316ad..9238ad7875f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -142,6 +142,12 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Collaboration\\Collaborators\\ISearchPlugin' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Collaborators/ISearchPlugin.php', 'OCP\\Collaboration\\Collaborators\\ISearchResult' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Collaborators/ISearchResult.php', 'OCP\\Collaboration\\Collaborators\\SearchResultType' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Collaborators/SearchResultType.php', + 'OCP\\Collaboration\\Resources\\CollectionException' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/CollectionException.php', + 'OCP\\Collaboration\\Resources\\ICollection' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/ICollection.php', + 'OCP\\Collaboration\\Resources\\IManager' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IManager.php', + 'OCP\\Collaboration\\Resources\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IProvider.php', + 'OCP\\Collaboration\\Resources\\IResource' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/IResource.php', + 'OCP\\Collaboration\\Resources\\ResourceException' => __DIR__ . '/../../..' . '/lib/public/Collaboration/Resources/ResourceException.php', 'OCP\\Command\\IBus' => __DIR__ . '/../../..' . '/lib/public/Command/IBus.php', 'OCP\\Command\\ICommand' => __DIR__ . '/../../..' . '/lib/public/Command/ICommand.php', 'OCP\\Comments\\CommentsEntityEvent' => __DIR__ . '/../../..' . '/lib/public/Comments/CommentsEntityEvent.php', @@ -574,6 +580,9 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Collaboration\\Collaborators\\Search' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Collaborators/Search.php', 'OC\\Collaboration\\Collaborators\\SearchResult' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Collaborators/SearchResult.php', 'OC\\Collaboration\\Collaborators\\UserPlugin' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Collaborators/UserPlugin.php', + 'OC\\Collaboration\\Resources\\Collection' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Collection.php', + 'OC\\Collaboration\\Resources\\Manager' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Manager.php', + 'OC\\Collaboration\\Resources\\Resource' => __DIR__ . '/../../..' . '/lib/private/Collaboration/Resources/Resource.php', 'OC\\Color' => __DIR__ . '/../../..' . '/lib/private/Color.php', 'OC\\Command\\AsyncBus' => __DIR__ . '/../../..' . '/lib/private/Command/AsyncBus.php', 'OC\\Command\\CallableJob' => __DIR__ . '/../../..' . '/lib/private/Command/CallableJob.php', @@ -689,6 +698,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Controller\\CSRFTokenController' => __DIR__ . '/../../..' . '/core/Controller/CSRFTokenController.php', 'OC\\Core\\Controller\\ClientFlowLoginController' => __DIR__ . '/../../..' . '/core/Controller/ClientFlowLoginController.php', 'OC\\Core\\Controller\\ClientFlowLoginV2Controller' => __DIR__ . '/../../..' . '/core/Controller/ClientFlowLoginV2Controller.php', + 'OC\\Core\\Controller\\CollaborationResourcesController' => __DIR__ . '/../../..' . '/core/Controller/CollaborationResourcesController.php', 'OC\\Core\\Controller\\ContactsMenuController' => __DIR__ . '/../../..' . '/core/Controller/ContactsMenuController.php', 'OC\\Core\\Controller\\CssController' => __DIR__ . '/../../..' . '/core/Controller/CssController.php', 'OC\\Core\\Controller\\GuestAvatarController' => __DIR__ . '/../../..' . '/core/Controller/GuestAvatarController.php', @@ -725,6 +735,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Migrations\\Version14000Date20180626223656' => __DIR__ . '/../../..' . '/core/Migrations/Version14000Date20180626223656.php', 'OC\\Core\\Migrations\\Version14000Date20180710092004' => __DIR__ . '/../../..' . '/core/Migrations/Version14000Date20180710092004.php', 'OC\\Core\\Migrations\\Version14000Date20180712153140' => __DIR__ . '/../../..' . '/core/Migrations/Version14000Date20180712153140.php', + 'OC\\Core\\Migrations\\Version15000Date20180917092725' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20180917092725.php', 'OC\\Core\\Migrations\\Version15000Date20180926101451' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20180926101451.php', 'OC\\Core\\Migrations\\Version15000Date20181015062942' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20181015062942.php', 'OC\\Core\\Migrations\\Version15000Date20181029084625' => __DIR__ . '/../../..' . '/core/Migrations/Version15000Date20181029084625.php', diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index bb63adf3983..fc16521cf32 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -283,6 +283,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { return $dispatcher; }); + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, OC\Collaboration\Resources\Manager::class); } /** diff --git a/lib/private/Collaboration/Resources/Collection.php b/lib/private/Collaboration/Resources/Collection.php index e89f62c0518..54c009b917c 100644 --- a/lib/private/Collaboration/Resources/Collection.php +++ b/lib/private/Collaboration/Resources/Collection.php @@ -43,17 +43,42 @@ class Collection implements ICollection { /** @var int */ protected $id; + /** @var string */ + protected $name; + /** @var IResource[] */ protected $resources; - public function __construct(IManager $manager, IDBConnection $connection, int $id) { + public function __construct( + IManager $manager, + IDBConnection $connection, + int $id, + string $name + ) { $this->manager = $manager; $this->connection = $connection; $this->id = $id; + $this->name = $name; $this->resources = []; } /** + * @return int + * @since 15.0.0 + */ + public function getId(): int { + return $this->id; + } + + /** + * @return string + * @since 15.0.0 + */ + public function getName(): string { + return $this->name; + } + + /** * @return IResource[] * @since 15.0.0 */ @@ -90,10 +115,6 @@ class Collection implements ICollection { $this->resources[] = $resource; - if ($this->id === 0) { - $this->makeCollectionPersistent(); - } - $query = $this->connection->getQueryBuilder(); $query->insert('collres_resources') ->values([ @@ -128,7 +149,7 @@ class Collection implements ICollection { $query->execute(); if (empty($this->resources)) { - $this->makeCollectionUnsteady(); + $this->removeCollection(); } } @@ -154,15 +175,7 @@ class Collection implements ICollection { $resource1->getId() === $resource2->getId(); } - protected function makeCollectionPersistent() { - $query = $this->connection->getQueryBuilder(); - $query->insert('collres_collections'); - $query->execute(); - - $this->id = $query->getLastInsertId(); - } - - protected function makeCollectionUnsteady() { + protected function removeCollection() { $query = $this->connection->getQueryBuilder(); $query->delete('collres_collections') ->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT))); diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index c091f5c5805..18301e0f2f5 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -23,11 +23,14 @@ declare(strict_types=1); namespace OC\Collaboration\Resources; +use OCA\Files\Collaboration\Resources\ResourceProvider; +use OCP\Collaboration\Resources\CollectionException; use OCP\Collaboration\Resources\ICollection; use OCP\Collaboration\Resources\IManager; use OCP\Collaboration\Resources\IProvider; use OCP\Collaboration\Resources\IResource; use OCP\Collaboration\Resources\ResourceException; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IUser; @@ -43,18 +46,36 @@ class Manager implements IManager { /** * @param int $id * @return ICollection + * @throws CollectionException when the collection could not be found * @since 15.0.0 */ public function getCollection(int $id): ICollection { - return new Collection($this, $this->connection, $id); + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('collres_collections') + ->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if (!$row) { + throw new CollectionException('Collection not found'); + } + + return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name']); } /** + * @param string $name * @return ICollection * @since 15.0.0 */ - public function newCollection(): ICollection { - return new Collection($this, $this->connection, 0); + public function newCollection(string $name): ICollection { + $query = $this->connection->getQueryBuilder(); + $query->insert('collres_collections'); + $query->execute(); + + return new Collection($this, $this->connection, $query->getLastInsertId(), $name); } /** @@ -72,7 +93,9 @@ class Manager implements IManager { * @since 15.0.0 */ public function getProviders(): array { - return []; + return [ + \OC::$server->query(ResourceProvider::class) // FIXME + ]; } /** diff --git a/lib/private/Collaboration/Resources/Resource.php b/lib/private/Collaboration/Resources/Resource.php index 144af6d358e..3013f1f5c48 100644 --- a/lib/private/Collaboration/Resources/Resource.php +++ b/lib/private/Collaboration/Resources/Resource.php @@ -47,7 +47,12 @@ class Resource implements IResource { /** @var string|null */ protected $name; - public function __construct(IManager $manager, IDBConnection $connection, string $type, string $id) { + public function __construct( + IManager $manager, + IDBConnection $connection, + string $type, + string $id + ) { $this->manager = $manager; $this->connection = $connection; $this->type = $type; diff --git a/lib/public/Collaboration/Resources/ICollection.php b/lib/public/Collaboration/Resources/ICollection.php index 1f503d8083a..d5864466491 100644 --- a/lib/public/Collaboration/Resources/ICollection.php +++ b/lib/public/Collaboration/Resources/ICollection.php @@ -36,6 +36,12 @@ interface ICollection { public function getId(): int; /** + * @return string + * @since 15.0.0 + */ + public function getName(): string; + + /** * @return IResource[] * @since 15.0.0 */ diff --git a/lib/public/Collaboration/Resources/IManager.php b/lib/public/Collaboration/Resources/IManager.php index abccfd2eed1..dd1c970af79 100644 --- a/lib/public/Collaboration/Resources/IManager.php +++ b/lib/public/Collaboration/Resources/IManager.php @@ -30,15 +30,17 @@ interface IManager extends IProvider { /** * @param int $id * @return ICollection + * @throws CollectionException when the collection could not be found * @since 15.0.0 */ public function getCollection(int $id): ICollection; /** + * @param string $name * @return ICollection * @since 15.0.0 */ - public function newCollection(): ICollection; + public function newCollection(string $name): ICollection; /** * @param string $type |