diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-11 12:57:38 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:19 +0100 |
commit | 59c92a75139b9db1cc1171f41bac971c2c528873 (patch) | |
tree | c897e2fcec33a4c3509539f67198a90c17efc307 /core/Controller | |
parent | ece471de360ebbebee6b098a20d65042dd69928c (diff) | |
download | nextcloud-server-59c92a75139b9db1cc1171f41bac971c2c528873.tar.gz nextcloud-server-59c92a75139b9db1cc1171f41bac971c2c528873.zip |
Further work on the access cache
Searching for all is still a problem
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/CollaborationResourcesController.php | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/core/Controller/CollaborationResourcesController.php b/core/Controller/CollaborationResourcesController.php index ae306d8aea8..77f47a9f0a1 100644 --- a/core/Controller/CollaborationResourcesController.php +++ b/core/Controller/CollaborationResourcesController.php @@ -59,7 +59,7 @@ class CollaborationResourcesController extends OCSController { * @throws CollectionException when the collection was not found for the user */ protected function getCollection(int $collectionId): ICollection { - $collection = $this->manager->getCollection($collectionId); + $collection = $this->manager->getCollectionForUser($collectionId, $this->userSession->getUser()); if (!$collection->canAccess($this->userSession->getUser())) { throw new CollectionException('Not found'); @@ -115,9 +115,9 @@ class CollaborationResourcesController extends OCSController { return new DataResponse([], Http::STATUS_NOT_FOUND); } - try { - $resource = $this->manager->getResource($resourceType, $resourceId); - } catch (ResourceException $e) { + $resource = $this->manager->createResource($resourceType, $resourceId); + + if (!$resource->canAccess($this->userSession->getUser())) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -145,7 +145,7 @@ class CollaborationResourcesController extends OCSController { } try { - $resource = $this->manager->getResource($resourceType, $resourceId); + $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); } catch (CollectionException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -164,8 +164,8 @@ class CollaborationResourcesController extends OCSController { */ public function getCollectionsByResource(string $resourceType, string $resourceId): DataResponse { try { - $resource = $this->manager->getResource($resourceType, $resourceId); - } catch (CollectionException $e) { + $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); + } catch (ResourceException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -190,7 +190,7 @@ class CollaborationResourcesController extends OCSController { } try { - $resource = $this->manager->getResource($baseResourceType, $baseResourceId); + $resource = $this->manager->createResource($baseResourceType, $baseResourceId); } catch (CollectionException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } @@ -214,19 +214,13 @@ class CollaborationResourcesController extends OCSController { */ public function renameCollection(int $collectionId, string $collectionName): DataResponse { try { - $collection = $this->manager->getCollection($collectionId); - if (!$collection->canAccess($this->userSession->getUser())) { - throw new CollectionException('Not found'); - } + $collection = $this->getCollection($collectionId); } catch (CollectionException $exception) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - try { - $collection = $this->manager->renameCollection($collectionId, $collectionName); - } catch (CollectionException $e) { - return new DataResponse([], Http::STATUS_NOT_FOUND); - } + $collection->setName($collectionName); + return new DataResponse($this->prepareCollection($collection)); } |