diff options
Diffstat (limited to 'lib/private/share20/share.php')
-rw-r--r-- | lib/private/share20/share.php | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php index db91ad4a91d..5b7945b1da8 100644 --- a/lib/private/share20/share.php +++ b/lib/private/share20/share.php @@ -20,7 +20,9 @@ */ namespace OC\Share20; +use OCP\Files\IRootFolder; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\IUser; use OCP\IGroup; @@ -31,14 +33,16 @@ class Share implements \OCP\Share\IShare { /** @var string */ private $providerId; /** @var Node */ - private $path; + private $node; + /** @var int */ + private $fileId; /** @var int */ private $shareType; - /** @var IUser|IGroup */ + /** @var string */ private $sharedWith; - /** @var IUser */ + /** @var string */ private $sharedBy; - /** @var IUser */ + /** @var string */ private $shareOwner; /** @var int */ private $permissions; @@ -57,6 +61,13 @@ class Share implements \OCP\Share\IShare { /** @var bool */ private $mailSend; + /** @var IRootFolder */ + private $rootFolder; + + public function __construct(IRootFolder $rootFolder) { + $this->rootFolder = $rootFolder; + } + /** * @inheritdoc */ @@ -90,8 +101,8 @@ class Share implements \OCP\Share\IShare { /** * @inheritdoc */ - public function setNode(Node $path) { - $this->path = $path; + public function setNode(Node $node) { + $this->node = $node; return $this; } @@ -99,7 +110,32 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function getNode() { - return $this->path; + if ($this->node === null) { + + if ($this->shareOwner === null || $this->fileId === null) { + throw new NotFoundException(); + } + + $userFolder = $this->rootFolder->getUserFolder($this->shareOwner); + + $nodes = $userFolder->getById($this->fileId); + if (empty($nodes)) { + throw new NotFoundException(); + } + + $this->node = $nodes[0]; + } + + return $this->node; + } + + /** + * @inheritdoc + */ + public function setNodeId($fileId) { + $this->node = null; + $this->fileId = $fileId; + return $this; } /** |