From aeae73b364048ebf3baf8cf6d692ac4f62467e7e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 23 Nov 2015 14:06:25 +0100 Subject: [Sharing 2.0] Removed unused DI stuff The share manager etc should not care about filtering stuff. They should return what is asked for them. --- lib/private/share20/manager.php | 44 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'lib/private') diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 57d84967977..e58110b40d2 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -22,11 +22,7 @@ namespace OC\Share20; use OCP\IAppConfig; -use OCP\IUserManager; -use OCP\IGroupManager; -use OCP\IUser; use OCP\ILogger; -use OCP\Files\Folder; use OC\Share20\Exception\ShareNotFound; @@ -40,37 +36,19 @@ class Manager { */ private $defaultProvider; - /** @var IUser */ - private $currentUser; - - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - /** @var ILogger */ private $logger; /** @var IAppConfig */ private $appConfig; - /** @var IFolder */ - private $userFolder; - - public function __construct(IUser $user, - IUserManager $userManager, - IGroupManager $groupManager, - ILogger $logger, - IAppConfig $appConfig, - Folder $userFolder, - IShareProvider $defaultProvider) { - $this->currentUser = $user; - $this->userManager = $userManager; - $this->groupManager = $groupManager; + public function __construct( + ILogger $logger, + IAppConfig $appConfig, + IShareProvider $defaultProvider + ) { $this->logger = $logger; $this->appConfig = $appConfig; - $this->userFolder = $userFolder; // TEMP SOLUTION JUST TO GET STARTED $this->defaultProvider = $defaultProvider; @@ -118,7 +96,7 @@ class Manager { /** * Delete a share * - * @param Share $share + * @param IShare $share * @throws ShareNotFound * @throws \OC\Share20\Exception\BackendError */ @@ -126,7 +104,7 @@ class Manager { // Just to make sure we have all the info $share = $this->getShareById($share->getId()); - $formatHookParams = function($share) { + $formatHookParams = function(IShare $share) { // Prepare hook $shareType = $share->getShareType(); $sharedWith = ''; @@ -203,12 +181,6 @@ class Manager { $share = $this->defaultProvider->getShareById($id); - if ($share->getSharedWith() !== $this->currentUser && - $share->getSharedBy() !== $this->currentUser && - $share->getShareOwner() !== $this->currentUser) { - throw new ShareNotFound(); - } - return $share; } @@ -246,7 +218,7 @@ class Manager { * * @return Share * - * @throws ShareNotFoundException + * @throws ShareNotFound */ public function getShareByToken($token, $password=null) { throw new \Exception(); -- cgit v1.2.3 From a2b8483779b5cb868309ca3f98051bfcaafd6ff9 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 23 Nov 2015 17:10:58 +0100 Subject: [Sharing 2.0] Default share provider only generic DI No injection of userfolders etc. Only generic DI components (IRootFolder) etc should be used to make sure we can also run this from the cli --- apps/files_sharing/api/ocssharewrapper.php | 2 +- lib/private/share20/defaultshareprovider.php | 22 +-- tests/lib/share20/defaultshareprovidertest.php | 246 +++++++++++-------------- 3 files changed, 117 insertions(+), 153 deletions(-) (limited to 'lib/private') diff --git a/apps/files_sharing/api/ocssharewrapper.php b/apps/files_sharing/api/ocssharewrapper.php index b93a994f756..ab54e5e5e34 100644 --- a/apps/files_sharing/api/ocssharewrapper.php +++ b/apps/files_sharing/api/ocssharewrapper.php @@ -34,7 +34,7 @@ class OCSShareWrapper { \OC::$server->getDatabaseConnection(), \OC::$server->getUserManager(), \OC::$server->getGroupManager(), - \OC::$server->getUserFolder() + \OC::$server->getRootFolder() ) ), \OC::$server->getGroupManager(), diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index 5805e41d411..15add93ce64 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -35,17 +35,17 @@ class DefaultShareProvider implements IShareProvider { /** @var \OCP\IGroupManager */ private $groupManager; - /** @var \OCP\Files\Folder */ - private $userFolder; + /** @var \OCP\Files\IRootFolder */ + private $rootFolder; public function __construct(\OCP\IDBConnection $connection, \OCP\IUserManager $userManager, \OCP\IGroupManager $groupManager, - \OCP\Files\Folder $userFolder) { + \OCP\Files\IRootFolder $rootFolder) { $this->dbConn = $connection; $this->userManager = $userManager; $this->groupManager = $groupManager; - $this->userFolder = $userFolder; + $this->rootFolder = $rootFolder; } /** @@ -218,14 +218,14 @@ class DefaultShareProvider implements IShareProvider { $share->setSharedBy($this->userManager->get($data['uid_owner'])); // TODO: getById can return an array. How to handle this properly?? - $path = $this->userFolder->getById((int)$data['file_source']); - $path = $path[0]; - $share->setPath($path); + $folder = $this->rootFolder->getUserFolder($share->getSharedBy()->getUID()); + $path = $folder->getById((int)$data['file_source'])[0]; - $owner = $path->getStorage()->getOwner('.'); - if ($owner !== false) { - $share->setShareOwner($this->userManager->get($owner)); - } + $owner = $path->getOwner(); + $share->setShareOwner($owner); + + $path = $this->rootFolder->getUserFolder($owner->getUID())->getById((int)$data['file_source'])[0]; + $share->setPath($path); if ($data['expiration'] !== null) { $expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']); diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php index 4c0b5523947..dc45bc7c085 100644 --- a/tests/lib/share20/defaultshareprovidertest.php +++ b/tests/lib/share20/defaultshareprovidertest.php @@ -23,7 +23,7 @@ namespace Test\Share20; use OCP\IDBConnection; use OCP\IUserManager; use OCP\IGroupManager; -use OCP\Files\Folder; +use OCP\Files\IRootFolder; use OC\Share20\DefaultShareProvider; class DefaultShareProviderTest extends \Test\TestCase { @@ -37,8 +37,8 @@ class DefaultShareProviderTest extends \Test\TestCase { /** @var IGroupManager */ protected $groupManager; - /** @var Folder */ - protected $userFolder; + /** @var IRootFolder */ + protected $rootFolder; /** @var DefaultShareProvider */ protected $provider; @@ -47,7 +47,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->dbConn = \OC::$server->getDatabaseConnection(); $this->userManager = $this->getMock('OCP\IUserManager'); $this->groupManager = $this->getMock('OCP\IGroupManager'); - $this->userFolder = $this->getMock('OCP\Files\Folder'); + $this->rootFolder = $this->getMock('OCP\Files\IRootFolder'); //Empty share table $this->dbConn->getQueryBuilder()->delete('share')->execute(); @@ -56,7 +56,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->dbConn, $this->userManager, $this->groupManager, - $this->userFolder + $this->rootFolder ); } @@ -65,7 +65,7 @@ class DefaultShareProviderTest extends \Test\TestCase { } /** - * @expectedException OC\Share20\Exception\ShareNotFound + * @expectedException \OC\Share20\Exception\ShareNotFound */ public function testGetShareByIdNotExist() { $this->provider->getShareById(1); @@ -97,25 +97,30 @@ class DefaultShareProviderTest extends \Test\TestCase { $id = $id['id']; $cursor->closeCursor(); - $storage = $this->getMock('OC\Files\Storage\Storage'); - $storage - ->expects($this->once()) - ->method('getOwner') - ->willReturn('shareOwner'); - $path = $this->getMock('OCP\Files\File'); - $path - ->expects($this->once()) - ->method('getStorage') - ->wilLReturn($storage); - $this->userFolder - ->expects($this->once()) - ->method('getById') - ->with(42) - ->willReturn([$path]); - $sharedWith = $this->getMock('OCP\IUser'); $sharedBy = $this->getMock('OCP\IUser'); + $sharedBy->method('getUID')->willReturn('sharedBy'); $shareOwner = $this->getMock('OCP\IUser'); + $shareOwner->method('getUID')->willReturn('shareOwner'); + + $sharedByPath = $this->getMock('\OCP\Files\File'); + $ownerPath = $this->getMock('\OCP\Files\File'); + + $sharedByPath->method('getOwner')->willReturn($shareOwner); + + $sharedByFolder = $this->getMock('\OCP\Files\Folder'); + $sharedByFolder->method('getById')->with(42)->willReturn([$sharedByPath]); + + $shareOwnerFolder = $this->getMock('\OCP\Files\Folder'); + $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]); + + $this->rootFolder + ->method('getUserFolder') + ->will($this->returnValueMap([ + ['sharedBy', $sharedByFolder], + ['shareOwner', $shareOwnerFolder], + ])); + $this->userManager ->method('get') ->will($this->returnValueMap([ @@ -131,7 +136,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($sharedWith, $share->getSharedWith()); $this->assertEquals($sharedBy, $share->getSharedBy()); $this->assertEquals($shareOwner, $share->getShareOwner()); - $this->assertEquals($path, $share->getPath()); + $this->assertEquals($ownerPath, $share->getPath()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals(null, $share->getToken()); $this->assertEquals(null, $share->getExpirationDate()); @@ -164,25 +169,30 @@ class DefaultShareProviderTest extends \Test\TestCase { $id = $id['id']; $cursor->closeCursor(); - $storage = $this->getMock('OC\Files\Storage\Storage'); - $storage - ->expects($this->once()) - ->method('getOwner') - ->willReturn('shareOwner'); - $path = $this->getMock('OCP\Files\Folder'); - $path - ->expects($this->once()) - ->method('getStorage') - ->wilLReturn($storage); - $this->userFolder - ->expects($this->once()) - ->method('getById') - ->with(42) - ->willReturn([$path]); - $sharedWith = $this->getMock('OCP\IGroup'); $sharedBy = $this->getMock('OCP\IUser'); + $sharedBy->method('getUID')->willReturn('sharedBy'); $shareOwner = $this->getMock('OCP\IUser'); + $shareOwner->method('getUID')->willReturn('shareOwner'); + + $sharedByPath = $this->getMock('\OCP\Files\Folder'); + $ownerPath = $this->getMock('\OCP\Files\Folder'); + + $sharedByPath->method('getOwner')->willReturn($shareOwner); + + $sharedByFolder = $this->getMock('\OCP\Files\Folder'); + $sharedByFolder->method('getById')->with(42)->willReturn([$sharedByPath]); + + $shareOwnerFolder = $this->getMock('\OCP\Files\Folder'); + $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]); + + $this->rootFolder + ->method('getUserFolder') + ->will($this->returnValueMap([ + ['sharedBy', $sharedByFolder], + ['shareOwner', $shareOwnerFolder], + ])); + $this->userManager ->method('get') ->will($this->returnValueMap([ @@ -202,7 +212,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($sharedWith, $share->getSharedWith()); $this->assertEquals($sharedBy, $share->getSharedBy()); $this->assertEquals($shareOwner, $share->getShareOwner()); - $this->assertEquals($path, $share->getPath()); + $this->assertEquals($ownerPath, $share->getPath()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals(null, $share->getToken()); $this->assertEquals(null, $share->getExpirationDate()); @@ -237,90 +247,29 @@ class DefaultShareProviderTest extends \Test\TestCase { $id = $id['id']; $cursor->closeCursor(); - $storage = $this->getMock('OC\Files\Storage\Storage'); - $storage - ->expects($this->once()) - ->method('getOwner') - ->willReturn('shareOwner'); - $path = $this->getMock('OCP\Files\Node'); - $path - ->expects($this->once()) - ->method('getStorage') - ->wilLReturn($storage); - $this->userFolder - ->expects($this->once()) - ->method('getById') - ->with(42) - ->willReturn([$path]); - $sharedBy = $this->getMock('OCP\IUser'); + $sharedBy->method('getUID')->willReturn('sharedBy'); $shareOwner = $this->getMock('OCP\IUser'); - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); - - $share = $this->provider->getShareById($id); - - $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); - $this->assertEquals('sharedWith', $share->getPassword()); - $this->assertEquals($sharedBy, $share->getSharedBy()); - $this->assertEquals($shareOwner, $share->getShareOwner()); - $this->assertEquals($path, $share->getPath()); - $this->assertEquals(13, $share->getPermissions()); - $this->assertEquals('token', $share->getToken()); - $this->assertEquals(\DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-02 00:00:00'), $share->getExpirationDate()); - $this->assertEquals('myTarget', $share->getTarget()); - } + $shareOwner->method('getUID')->willReturn('shareOwner'); - public function testGetShareByIdRemoteShare() { - $qb = $this->dbConn->getQueryBuilder(); + $sharedByPath = $this->getMock('\OCP\Files\Folder'); + $ownerPath = $this->getMock('\OCP\Files\Folder'); - $qb->insert('share') - ->values([ - 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_REMOTE), - 'share_with' => $qb->expr()->literal('sharedWith'), - 'uid_owner' => $qb->expr()->literal('sharedBy'), - 'item_type' => $qb->expr()->literal('file'), - 'file_source' => $qb->expr()->literal(42), - 'file_target' => $qb->expr()->literal('myTarget'), - 'permissions' => $qb->expr()->literal(13), - ]); - $this->assertEquals(1, $qb->execute()); + $sharedByPath->method('getOwner')->willReturn($shareOwner); - // Get the id - $qb = $this->dbConn->getQueryBuilder(); - $cursor = $qb->select('id') - ->from('share') - ->setMaxResults(1) - ->orderBy('id', 'DESC') - ->execute(); - $id = $cursor->fetch(); - $id = $id['id']; - $cursor->closeCursor(); + $sharedByFolder = $this->getMock('\OCP\Files\Folder'); + $sharedByFolder->method('getById')->with(42)->willReturn([$sharedByPath]); + $shareOwnerFolder = $this->getMock('\OCP\Files\Folder'); + $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]); - $storage = $this->getMock('OC\Files\Storage\Storage'); - $storage - ->expects($this->once()) - ->method('getOwner') - ->willReturn('shareOwner'); - $path = $this->getMock('OCP\Files\Node'); - $path - ->expects($this->once()) - ->method('getStorage') - ->wilLReturn($storage); - $this->userFolder - ->expects($this->once()) - ->method('getById') - ->with(42) - ->willReturn([$path]); + $this->rootFolder + ->method('getUserFolder') + ->will($this->returnValueMap([ + ['sharedBy', $sharedByFolder], + ['shareOwner', $shareOwnerFolder], + ])); - $sharedBy = $this->getMock('OCP\IUser'); - $shareOwner = $this->getMock('OCP\IUser'); $this->userManager ->method('get') ->will($this->returnValueMap([ @@ -331,14 +280,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType()); - $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals('sharedWith', $share->getPassword()); $this->assertEquals($sharedBy, $share->getSharedBy()); $this->assertEquals($shareOwner, $share->getShareOwner()); - $this->assertEquals($path, $share->getPath()); + $this->assertEquals($ownerPath, $share->getPath()); $this->assertEquals(13, $share->getPermissions()); - $this->assertEquals(null, $share->getToken()); - $this->assertEquals(null, $share->getExpirationDate()); + $this->assertEquals('token', $share->getToken()); + $this->assertEquals(\DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-02 00:00:00'), $share->getExpirationDate()); $this->assertEquals('myTarget', $share->getTarget()); } @@ -376,7 +325,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->dbConn, $this->userManager, $this->groupManager, - $this->userFolder, + $this->rootFolder, ] ) ->setMethods(['getShareById']) @@ -437,7 +386,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $db, $this->userManager, $this->groupManager, - $this->userFolder, + $this->rootFolder, ] ) ->setMethods(['getShareById']) @@ -504,30 +453,45 @@ class DefaultShareProviderTest extends \Test\TestCase { ]); $qb->execute(); + $shareOwner = $this->getMock('OCP\IUser'); + $shareOwner->method('getUID')->willReturn('shareOwner'); + $user1 = $this->getMock('OCP\IUser'); + $user2 = $this->getMock('OCP\IUser'); + $user2->method('getUID')->willReturn('user2'); + $user3 = $this->getMock('OCP\IUser'); + $user3->method('getUID')->willReturn('user3'); + + $user2Path = $this->getMock('\OCP\Files\File'); + $user2Path->expects($this->once())->method('getOwner')->willReturn($shareOwner); + $user2Folder = $this->getMock('\OCP\Files\Folder'); + $user2Folder->expects($this->once()) + ->method('getById') + ->with(1) + ->willReturn([$user2Path]); - $storage = $this->getMock('OC\Files\Storage\Storage'); - $storage - ->method('getOwner') - ->willReturn('shareOwner'); - $path1 = $this->getMock('OCP\Files\File'); - $path1->expects($this->once())->method('getStorage')->willReturn($storage); - $path2 = $this->getMock('OCP\Files\Folder'); - $path2->expects($this->once())->method('getStorage')->willReturn($storage); - $this->userFolder + $user3Path = $this->getMock('\OCP\Files\Folder'); + $user3Path->expects($this->once())->method('getOwner')->willReturn($shareOwner); + $user3Folder = $this->getMock('\OCP\Files\Folder'); + $user3Folder->expects($this->once()) ->method('getById') + ->with(3) + ->willReturn([$user3Path]); + + $ownerPath = $this->getMock('\OCP\Files\Folder'); + $ownerFolder = $this->getMock('\OCP\Files\Folder'); + $ownerFolder->method('getById')->willReturn([$ownerPath]); + + $this->rootFolder + ->method('getUserFolder') ->will($this->returnValueMap([ - [1, [$path1]], - [3, [$path2]], + ['shareOwner', $ownerFolder], + ['user2', $user2Folder], + ['user3', $user3Folder], ])); - $shareOwner = $this->getMock('OCP\IUser'); - $user1 = $this->getMock('OCP\IUser'); - $user2 = $this->getMock('OCP\IUser'); - $user3 = $this->getMock('OCP\IUser'); $this->userManager ->method('get') ->will($this->returnValueMap([ - ['shareOwner', $shareOwner], ['user1', $user1], ['user2', $user2], ['user3', $user3], @@ -552,7 +516,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($user1, $children[0]->getSharedWith()); $this->assertEquals($user2, $children[0]->getSharedBy()); $this->assertEquals($shareOwner, $children[0]->getShareOwner()); - $this->assertEquals($path1, $children[0]->getPath()); + $this->assertEquals($ownerPath, $children[0]->getPath()); $this->assertEquals(2, $children[0]->getPermissions()); $this->assertEquals(null, $children[0]->getToken()); $this->assertEquals(null, $children[0]->getExpirationDate()); @@ -563,7 +527,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($group1, $children[1]->getSharedWith()); $this->assertEquals($user3, $children[1]->getSharedBy()); $this->assertEquals($shareOwner, $children[1]->getShareOwner()); - $this->assertEquals($path2, $children[1]->getPath()); + $this->assertEquals($ownerPath, $children[1]->getPath()); $this->assertEquals(4, $children[1]->getPermissions()); $this->assertEquals(null, $children[1]->getToken()); $this->assertEquals(null, $children[1]->getExpirationDate()); -- cgit v1.2.3 From 85976b72937eae0e99d974551baf3aa96fa8d041 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 24 Nov 2015 09:58:37 +0100 Subject: [Sharing 2.0] Fix phpdoc etc --- apps/files_sharing/api/share20ocs.php | 12 +++---- lib/private/share20/defaultshareprovider.php | 53 ++++++++++++++++------------ lib/private/share20/ishare.php | 2 +- lib/private/share20/ishareprovider.php | 12 +++---- lib/private/share20/manager.php | 16 ++++----- lib/private/share20/share.php | 4 +-- 6 files changed, 53 insertions(+), 46 deletions(-) (limited to 'lib/private') diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 788cbe85866..1f27168c705 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -54,12 +54,12 @@ class Share20OCS { public function __construct( \OC\Share20\Manager $shareManager, - \OCP\IGroupManager $groupManager, - \OCP\IUserManager $userManager, - \OCP\IRequest $request, - \OCP\Files\Folder $userFolder, - \OCP\IURLGenerator $urlGenerator, - \OCP\IUser $currentUser + IGroupManager $groupManager, + IUserManager $userManager, + IRequest $request, + Folder $userFolder, + IURLGenerator $urlGenerator, + IUser $currentUser ) { $this->shareManager = $shareManager; $this->userManager = $userManager; diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index 15add93ce64..bc3bc0ce9ed 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -23,25 +23,39 @@ namespace OC\Share20; use OC\Share20\Exception\ShareNotFound; use OC\Share20\Exception\BackendError; use OCP\IUser; +use OCP\IGroupManager; +use OCP\IUserManager; +use OCP\Files\IRootFolder; +use OCP\IDBConnection; +use OCP\Files\Node; class DefaultShareProvider implements IShareProvider { - /** @var \OCP\IDBConnection */ + /** @var IDBConnection */ private $dbConn; - /** @var \OCP\IUserManager */ + /** @var IUserManager */ private $userManager; - /** @var \OCP\IGroupManager */ + /** @var IGroupManager */ private $groupManager; - /** @var \OCP\Files\IRootFolder */ + /** @var IRootFolder */ private $rootFolder; - public function __construct(\OCP\IDBConnection $connection, - \OCP\IUserManager $userManager, - \OCP\IGroupManager $groupManager, - \OCP\Files\IRootFolder $rootFolder) { + /** + * DefaultShareProvider constructor. + * + * @param IDBConnection $connection + * @param IUserManager $userManager + * @param IGroupManager $groupManager + * @param IRootFolder $rootFolder + */ + public function __construct( + IDBConnection $connection, + IUserManager $userManager, + IGroupManager $groupManager, + IRootFolder $rootFolder) { $this->dbConn = $connection; $this->userManager = $userManager; $this->groupManager = $groupManager; @@ -51,21 +65,19 @@ class DefaultShareProvider implements IShareProvider { /** * Share a path * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function create(Share $share) { - throw new \Exception(); + public function create(IShare $share) { } /** * Update a share * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function update(Share $share) { - throw new \Exception(); + public function update(IShare $share) { } /** @@ -125,7 +137,6 @@ class DefaultShareProvider implements IShareProvider { * @return Share[] */ public function getShares(IUser $user, $shareType, $offset, $limit) { - throw new \Exception(); } /** @@ -163,8 +174,7 @@ class DefaultShareProvider implements IShareProvider { * @param \OCP\Files\Node $path * @return IShare[] */ - public function getSharesByPath(\OCP\IUser $user, \OCP\Files\Node $path) { - throw new \Exception(); + public function getSharesByPath(IUser $user, Node $path) { } /** @@ -175,7 +185,6 @@ class DefaultShareProvider implements IShareProvider { * @param Share */ public function getSharedWithMe(IUser $user, $shareType = null) { - throw new \Exception(); } /** @@ -186,7 +195,6 @@ class DefaultShareProvider implements IShareProvider { * @param Share */ public function getShareByToken($token, $password = null) { - throw new \Exception(); } /** @@ -235,5 +243,4 @@ class DefaultShareProvider implements IShareProvider { return $share; } - -} +} \ No newline at end of file diff --git a/lib/private/share20/ishare.php b/lib/private/share20/ishare.php index a80abebd71c..2e54da7a029 100644 --- a/lib/private/share20/ishare.php +++ b/lib/private/share20/ishare.php @@ -38,7 +38,7 @@ interface IShare { /** * Set the path of this share * - * @param File|Folder $path + * @param Node $path * @return Share The modified object */ public function setPath(Node $path); diff --git a/lib/private/share20/ishareprovider.php b/lib/private/share20/ishareprovider.php index 833de1b58f6..56a550acf71 100644 --- a/lib/private/share20/ishareprovider.php +++ b/lib/private/share20/ishareprovider.php @@ -29,18 +29,18 @@ interface IShareProvider { /** * Share a path * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function create(Share $share); + public function create(IShare $share); /** * Update a share * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function update(Share $share); + public function update(IShare $share); /** * Delete a share diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index e58110b40d2..882b281c490 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -42,6 +42,13 @@ class Manager { /** @var IAppConfig */ private $appConfig; + /** + * Manager constructor. + * + * @param ILogger $logger + * @param IAppConfig $appConfig + * @param IShareProvider $defaultProvider + */ public function __construct( ILogger $logger, IAppConfig $appConfig, @@ -56,12 +63,11 @@ class Manager { /** * Share a path - * + * * @param Share $share * @return Share The share object */ public function createShare(Share $share) { - throw new \Exception(); } /** @@ -71,7 +77,6 @@ class Manager { * @return Share The share object */ public function updateShare(Share $share) { - throw new \Exception(); } /** @@ -163,7 +168,6 @@ class Manager { * @return Share[] */ public function getShares($page=0, $perPage=50) { - throw new \Exception(); } /** @@ -194,7 +198,6 @@ class Manager { * @return Share[] */ public function getSharesByPath(\OCP\Files\Node $path, $page=0, $perPage=50) { - throw new \Exception(); } /** @@ -207,7 +210,6 @@ class Manager { * @return Share[] */ public function getSharedWithMe($shareType = null, $page=0, $perPage=50) { - throw new \Exception(); } /** @@ -221,7 +223,6 @@ class Manager { * @throws ShareNotFound */ public function getShareByToken($token, $password=null) { - throw new \Exception(); } /** @@ -249,6 +250,5 @@ class Manager { * @param \OCP\Files\Node $path */ public function getAccessList(\OCP\Files\Node $path) { - throw new \Exception(); } } diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php index 4200816799e..b7ce38ac61d 100644 --- a/lib/private/share20/share.php +++ b/lib/private/share20/share.php @@ -58,7 +58,7 @@ class Share implements IShare { /** * Set the id of the share * - * @param int id + * @param string $id * @return Share The modified object */ public function setId($id) { @@ -292,7 +292,7 @@ class Share implements IShare { /** * Set the target of this share * - * @param string target + * @param string $target * @return Share The modified object */ public function setTarget($target) { -- cgit v1.2.3