summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/composer/composer/autoload_classmap.php1
-rw-r--r--apps/files/composer/composer/autoload_static.php1
-rw-r--r--apps/files/lib/Collaboration/Resources/ResourceProvider.php83
-rw-r--r--core/Controller/CollaborationResourcesController.php17
-rw-r--r--core/Migrations/Version15000Date20180917092725.php4
-rw-r--r--lib/composer/composer/autoload_classmap.php11
-rw-r--r--lib/composer/composer/autoload_static.php11
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php1
-rw-r--r--lib/private/Collaboration/Resources/Collection.php43
-rw-r--r--lib/private/Collaboration/Resources/Manager.php31
-rw-r--r--lib/private/Collaboration/Resources/Resource.php7
-rw-r--r--lib/public/Collaboration/Resources/ICollection.php6
-rw-r--r--lib/public/Collaboration/Resources/IManager.php4
13 files changed, 191 insertions, 29 deletions
diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php
index 3fe29a5dd59..fe4477635c1 100644
--- a/apps/files/composer/composer/autoload_classmap.php
+++ b/apps/files/composer/composer/autoload_classmap.php
@@ -23,6 +23,7 @@ return array(
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
+ 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php',
diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php
index 7dd15083831..9da1be7be0d 100644
--- a/apps/files/composer/composer/autoload_static.php
+++ b/apps/files/composer/composer/autoload_static.php
@@ -38,6 +38,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__ . '/..' . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
+ 'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php',
diff --git a/apps/files/lib/Collaboration/Resources/ResourceProvider.php b/apps/files/lib/Collaboration/Resources/ResourceProvider.php
new file mode 100644
index 00000000000..6d9b1b59784
--- /dev/null
+++ b/apps/files/lib/Collaboration/Resources/ResourceProvider.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files\Collaboration\Resources;
+
+
+use OCP\Collaboration\Resources\IProvider;
+use OCP\Collaboration\Resources\IResource;
+use OCP\Files\IRootFolder;
+use OCP\IUser;
+
+class ResourceProvider implements IProvider {
+
+ /** @var IRootFolder */
+ protected $rootFolder;
+
+ /** @var array */
+ protected $nodes = [];
+
+ public function __construct(IRootFolder $rootFolder) {
+ $this->rootFolder = $rootFolder;
+ }
+
+ /**
+ * Get the display name of a resource
+ *
+ * @param IResource $resource
+ * @return string
+ * @since 15.0.0
+ */
+ public function getName(IResource $resource): string {
+ if (isset($this->nodes[(int) $resource->getId()])) {
+ return $this->nodes[(int) $resource->getId()]->getPath();
+ }
+ return '';
+ }
+
+ /**
+ * Can a user/guest access the collection
+ *
+ * @param IResource $resource
+ * @param IUser $user
+ * @return bool
+ * @since 15.0.0
+ */
+ public function canAccess(IResource $resource, IUser $user = null): bool {
+ if ($resource->getType() !== 'files') {
+ return false;
+ }
+
+ if (!$user instanceof IUser) {
+ return false;
+ }
+
+ $userFolder = $this->rootFolder->getUserFolder($user->getUID());
+ $nodes = $userFolder->getById((int) $resource->getId());
+
+ if (!empty($nodes)) {
+ $this->nodes[(int) $resource->getId()] = array_shift($nodes);
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/core/Controller/CollaborationResourcesController.php b/core/Controller/CollaborationResourcesController.php
index 453a6405e56..e9fc7b1ac70 100644
--- a/core/Controller/CollaborationResourcesController.php
+++ b/core/Controller/CollaborationResourcesController.php
@@ -163,27 +163,27 @@ class CollaborationResourcesController extends OCSController {
/**
* @NoAdminRequired
*
- * @param string $baseResourceType
- * @param string $baseResourceId
* @param string $resourceType
* @param string $resourceId
+ * @param string $name
* @return DataResponse
*/
- public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $resourceType, string $resourceId): DataResponse {
+ public function createCollectionOnResource(string $resourceType, string $resourceId, string $name): DataResponse {
+ if (!isset($name[0]) || isset($name[64])) {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+
try {
- $baseResource = $this->manager->getResource($baseResourceType, $baseResourceId);
$resource = $this->manager->getResource($resourceType, $resourceId);
} catch (CollectionException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
- if (!$baseResource->canAccess($this->userSession->getUser()) ||
- !$resource->canAccess($this->userSession->getUser())) {
+ if (!$resource->canAccess($this->userSession->getUser())) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
- $collection = $this->manager->newCollection();
- $collection->addResource($baseResource);
+ $collection = $this->manager->newCollection($name);
$collection->addResource($resource);
return new DataResponse($this->prepareCollection($collection));
@@ -192,6 +192,7 @@ class CollaborationResourcesController extends OCSController {
protected function prepareCollection(ICollection $collection): array {
return [
'id' => $collection->getId(),
+ 'name' => $collection->getName(),
'resources' => array_map([$this, 'prepareResources'], $collection->getResources()),
];
}
diff --git a/core/Migrations/Version15000Date20180917092725.php b/core/Migrations/Version15000Date20180917092725.php
index 9dbc5efceda..1bcc6382745 100644
--- a/core/Migrations/Version15000Date20180917092725.php
+++ b/core/Migrations/Version15000Date20180917092725.php
@@ -48,6 +48,10 @@ class Version15000Date20180917092725 extends SimpleMigrationStep {
'autoincrement' => true,
'notnull' => true,
]);
+ $table->addColumn('name', Type::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
$table->setPrimaryKey(['id']);
}
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