]> source.dussan.org Git - nextcloud-server.git/commitdiff
[Share 2.0] Move IShare to OCP
authorRoeland Jago Douma <rullzer@owncloud.com>
Wed, 27 Jan 2016 11:13:53 +0000 (12:13 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Wed, 27 Jan 2016 21:04:37 +0000 (22:04 +0100)
16 files changed:
apps/files_sharing/api/share20ocs.php
apps/files_sharing/lib/controllers/sharecontroller.php
apps/files_sharing/tests/api/share20ocstest.php
apps/files_sharing/tests/controller/sharecontroller.php
lib/private/share20/defaultshareprovider.php
lib/private/share20/iproviderfactory.php [deleted file]
lib/private/share20/ishare.php [deleted file]
lib/private/share20/ishareprovider.php [deleted file]
lib/private/share20/manager.php
lib/private/share20/providerfactory.php
lib/private/share20/share.php
lib/public/share/iproviderfactory.php [new file with mode: 0644]
lib/public/share/ishare.php [new file with mode: 0644]
lib/public/share/ishareprovider.php [new file with mode: 0644]
tests/lib/share20/defaultshareprovidertest.php
tests/lib/share20/managertest.php

index 3048eb7cd1a2f7b43fb7283603e047786a409457..8e216c8c3c88bfe73065a820f8452a857aa922e9 100644 (file)
@@ -20,8 +20,6 @@
  */
 namespace OCA\Files_Sharing\API;
 
-use OC\Share20\IShare;
-
 use OCP\IGroupManager;
 use OCP\IUserManager;
 use OCP\IRequest;
@@ -73,10 +71,10 @@ class Share20OCS {
        /**
         * Convert an IShare to an array for OCS output
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @return array
         */
-       protected function formatShare($share) {
+       protected function formatShare(\OCP\Share\IShare $share) {
                $result = [
                        'id' => $share->getId(),
                        'share_type' => $share->getShareType(),
@@ -353,7 +351,7 @@ class Share20OCS {
                }
 
                $nodes = $folder->getDirectoryListing();
-               /** @var IShare[] $shares */
+               /** @var \OCP\Share\IShare[] $shares */
                $shares = [];
                foreach ($nodes as $node) {
                        $shares  = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
@@ -494,10 +492,10 @@ class Share20OCS {
        }
 
        /**
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @return bool
         */
-       protected function canAccessShare(IShare $share) {
+       protected function canAccessShare(\OCP\Share\IShare $share) {
                // A file with permissions 0 can't be accessed by us. So Don't show it
                if ($share->getPermissions() === 0) {
                        return false;
index 6f9a8d742cc67f32c86e164987c00258ba96bb40..407207c0efc295961d3dbd1e9dd1c5347379c69a 100644 (file)
@@ -51,7 +51,6 @@ use OCA\Files_Sharing\Helper;
 use OCP\Util;
 use OCA\Files_Sharing\Activity;
 use \OCP\Files\NotFoundException;
-use \OC\Share20\IShare;
 use OCP\Files\IRootFolder;
 
 /**
@@ -168,11 +167,11 @@ class ShareController extends Controller {
         * This is a modified version of Helper::authenticate
         * TODO: Try to merge back eventually with Helper::authenticate
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @param string|null $password
         * @return bool
         */
-       private function linkShareAuth(IShare $share, $password = null) {
+       private function linkShareAuth(\OCP\Share\IShare $share, $password = null) {
                if ($password !== null) {
                        if ($this->shareManager->checkPassword($share, $password)) {
                                $this->session->set('public_link_authenticated', (string)$share->getId());
index f38af9881558e0ddff1026049528695ed81cab66..ebacf6c20fec92dd319607cbe1b4f56fb0f5dbde 100644 (file)
@@ -20,7 +20,6 @@
  */
 namespace OCA\Files_Sharing\Tests\API;
 
-use OC\Share20\IShare;
 use OCA\Files_Sharing\API\Share20OCS;
 use OCP\IGroupManager;
 use OCP\IUserManager;
@@ -90,7 +89,7 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testDeleteShareCouldNotDelete() {
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareOwner')->willReturn($this->currentUser);
                $this->shareManager
                        ->expects($this->once())
@@ -109,7 +108,7 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testDeleteShare() {
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getSharedBy')->willReturn($this->currentUser);
                $this->shareManager
                        ->expects($this->once())
@@ -143,7 +142,7 @@ class Share20OCSTest extends \Test\TestCase {
        public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
                                                                $shareTime, $expiration, $parent, $target, $mail_send, $token=null,
                                                                $password=null) {
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getId')->willReturn($id);
                $share->method('getShareType')->willReturn($shareType);
                $share->method('getSharedWith')->willReturn($sharedWith);
@@ -345,7 +344,7 @@ class Share20OCSTest extends \Test\TestCase {
        /**
         * @dataProvider dataGetShare
         */
-       public function testGetShare(\OC\Share20\IShare $share, array $result) {
+       public function testGetShare(\OCP\Share\IShare $share, array $result) {
                $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
                                ->setConstructorArgs([
                                        $this->shareManager,
@@ -384,39 +383,39 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCanAccessShare() {
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareOwner')->willReturn($this->currentUser);
                $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getSharedBy')->willReturn($this->currentUser);
                $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
                $share->method('getSharedWith')->willReturn($this->currentUser);
                $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
                $share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser'));
                $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
                $group = $this->getMock('OCP\IGroup');
                $group->method('inGroup')->with($this->currentUser)->willReturn(true);
                $share->method('getSharedWith')->willReturn($group);
                $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
                $group = $this->getMock('OCP\IGroup');
                $group->method('inGroup')->with($this->currentUser)->willReturn(false);
                $share->method('getSharedWith')->willReturn($group);
                $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
                $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
        }
@@ -457,7 +456,7 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareInvalidPermissions() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
 
                $this->request
@@ -488,7 +487,7 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareUserNoShareWith() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
 
                $this->request
@@ -520,7 +519,7 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareUserNoValidShareWith() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
 
                $this->request
@@ -553,8 +552,9 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareUser() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
+               $this->shareManager->method('createShare')->will($this->returnArgument(0));
 
                $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
                        ->setConstructorArgs([
@@ -611,8 +611,9 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareGroupNoValidShareWith() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
+               $this->shareManager->method('createShare')->will($this->returnArgument(0));
 
                $this->request
                                ->method('getParam')
@@ -644,8 +645,9 @@ class Share20OCSTest extends \Test\TestCase {
        }
 
        public function testCreateShareGroup() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $this->shareManager->method('newShare')->willReturn($share);
+               $this->shareManager->method('createShare')->will($this->returnArgument(0));
 
                $ocs = $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
                        ->setConstructorArgs([
index 43db17f5abc0919670fa848fd8d539fde5d90669..7d13753d3221d31953b1b2d802221598032f918d 100644 (file)
@@ -116,7 +116,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testShowAuthenticateNotAuthenticated() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
 
                $this->shareManager
                        ->expects($this->once())
@@ -130,7 +130,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testShowAuthenticateAuthenticatedForDifferentShare() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn(1);
 
                $this->shareManager
@@ -148,7 +148,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testShowAuthenticateCorrectShare() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn(1);
 
                $this->shareManager
@@ -183,7 +183,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testAuthenticateValidPassword() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn(42);
 
                $this->shareManager
@@ -214,7 +214,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testAuthenticateInvalidPassword() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn(42);
 
                $this->shareManager
@@ -252,7 +252,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testShowShareNotAuthenticated() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getPassword')->willReturn('password');
 
                $this->shareManager
@@ -283,7 +283,7 @@ class ShareControllerTest extends \Test\TestCase {
                $file->method('getMimetype')->willReturn('text/plain');
                $file->method('getSize')->willReturn(33);
 
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn('42');
                $share->method('getPassword')->willReturn('password');
                $share->method('getShareOwner')->willReturn($owner);
@@ -340,7 +340,7 @@ class ShareControllerTest extends \Test\TestCase {
        }
 
        public function testDownloadShare() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getPassword')->willReturn('password');
 
                $this->shareManager
index 36ba56d63a25a2145e6b7eae84013bfee6330a8e..74dd408ad210eef8b440b89ebd2c524fdc8e419e 100644 (file)
@@ -20,6 +20,7 @@
  */
 namespace OC\Share20;
 
+use OCP\Share\IShareProvider;
 use OC\Share20\Exception\InvalidShare;
 use OC\Share20\Exception\ProviderException;
 use OC\Share20\Exception\ShareNotFound;
@@ -87,12 +88,12 @@ class DefaultShareProvider implements IShareProvider {
        /**
         * Share a path
         *
-        * @param IShare $share
-        * @return IShare The share object
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare The share object
         * @throws ShareNotFound
         * @throws \Exception
         */
-       public function create(IShare $share) {
+       public function create(\OCP\Share\IShare $share) {
                $qb = $this->dbConn->getQueryBuilder();
 
                $qb->insert('share');
@@ -179,10 +180,10 @@ class DefaultShareProvider implements IShareProvider {
        /**
         * Update a share
         *
-        * @param IShare $share
-        * @return IShare The share object
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare The share object
         */
-       public function update(IShare $share) {
+       public function update(\OCP\Share\IShare $share) {
                if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
                        /*
                         * We allow updating the recipient on user shares.
@@ -251,10 +252,10 @@ class DefaultShareProvider implements IShareProvider {
        /**
         * Get all children of this share
         *
-        * @param IShare $parent
+        * @param \OCP\Share\IShare $parent
         * @return IShare[]
         */
-       public function getChildren(IShare $parent) {
+       public function getChildren(\OCP\Share\IShare $parent) {
                $children = [];
 
                $qb = $this->dbConn->getQueryBuilder();
@@ -286,10 +287,10 @@ class DefaultShareProvider implements IShareProvider {
        /**
         * Delete a share
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws BackendError
         */
-       public function delete(IShare $share) {
+       public function delete(\OCP\Share\IShare $share) {
                // Fetch share to make sure it exists
                $share = $this->getShareById($share->getId());
 
@@ -308,12 +309,12 @@ class DefaultShareProvider implements IShareProvider {
         * Unshare a share from the recipient. If this is a group share
         * this means we need a special entry in the share db.
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @param IUser $recipient
         * @throws BackendError
         * @throws ProviderException
         */
-       public function deleteFromSelf(IShare $share, IUser $recipient) {
+       public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
                if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
 
                        /** @var IGroup $group */
diff --git a/lib/private/share20/iproviderfactory.php b/lib/private/share20/iproviderfactory.php
deleted file mode 100644 (file)
index b386669..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Share20;
-
-use OC\Share20\Exception\ProviderException;
-use OCP\IServerContainer;
-
-/**
- * Interface IProviderFactory
- *
- * @package OC\Share20
- * @since 9.0.0
- */
-interface IProviderFactory {
-
-       /**
-        * IProviderFactory constructor.
-        * @param IServerContainer $serverContainer
-        */
-       public function __construct(IServerContainer $serverContainer);
-
-       /**
-        * @param string $id
-        * @return IShareProvider
-        * @throws ProviderException
-        */
-       public function getProvider($id);
-
-       /**
-        * @param int $shareType
-        * @return IShareProvider
-        * @throws ProviderException
-        */
-       public function getProviderForType($shareType);
-}
diff --git a/lib/private/share20/ishare.php b/lib/private/share20/ishare.php
deleted file mode 100644 (file)
index d3ffd41..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-<?php
-/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Share20;
-
-use OCP\Files\File;
-use OCP\Files\Folder;
-use OCP\Files\Node;
-use OCP\IUser;
-use OCP\IGroup;
-
-interface IShare {
-
-       /**
-        * Get the id of the share
-        *
-        * @return string
-        */
-       public function getId();
-
-       /**
-        * Set the id of the share
-        *
-        * @param string $id
-        * @return IShare The modified share object
-        */
-       public function setId($id);
-
-       /**
-        * Get the full share id
-        *
-        * @return string
-        */
-       public function getFullId();
-
-       /**
-        * Set the provider id
-        *
-        * @param string $id
-        * @return IShare The modified share object
-        */
-       public function setProviderId($id);
-
-       /**
-        * Set the path of this share
-        *
-        * @param Node $path
-        * @return IShare The modified object
-        */
-       public function setPath(Node $path);
-
-       /**
-        * Get the path of this share for the current user
-        * 
-        * @return File|Folder
-        */
-       public function getPath();
-
-       /**
-        * Set the shareType
-        *
-        * @param int $shareType
-        * @return IShare The modified object
-        */
-       public function setShareType($shareType);
-
-       /**
-        * Get the shareType 
-        *
-        * @return int
-        */
-       public function getShareType();
-
-       /**
-        * Set the receiver of this share
-        *
-        * @param IUser|IGroup|string
-        * @return IShare The modified object
-        */
-       public function setSharedWith($sharedWith);
-
-       /**
-        * Get the receiver of this share
-        *
-        * @return IUser|IGroup|string
-        */
-       public function getSharedWith();
-
-       /**
-        * Set the permissions
-        *
-        * @param int $permissions
-        * @return IShare The modified object
-        */
-       public function setPermissions($permissions);
-
-       /**
-        * Get the share permissions
-        *
-        * @return int
-        */
-       public function getPermissions();
-
-       /**
-        * Set the expiration date
-        *
-        * @param \DateTime $expireDate
-        * @return IShare The modified object
-        */
-       public function setExpirationDate($expireDate);
-
-       /**
-        * Get the share expiration date
-        *
-        * @return \DateTime
-        */
-       public function getExpirationDate();
-
-       /**
-        * Set the sharer of the path
-        *
-        * @param IUser|string $sharedBy
-        * @return IShare The modified object
-        */
-       public function setSharedBy($sharedBy);
-
-       /**
-        * Get share sharer
-        *
-        * @return IUser|string
-        */
-       public function getSharedBy();
-
-       /**
-        * Set the original share owner (who owns the path)
-        *
-        * @param IUser|string
-        *
-        * @return IShare The modified object
-        */
-       public function setShareOwner($shareOwner);
-
-       /**
-        * Get the original share owner (who owns the path)
-        * 
-        * @return IUser|string
-        */
-       public function getShareOwner();
-
-       /**
-        * Set the password
-        *
-        * @param string $password
-        *
-        * @return IShare The modified object
-        */
-       public function setPassword($password);
-
-       /**
-        * Is a password set for this share
-        *
-        * @return string
-        */
-       public function getPassword();
-
-       /**
-        * Set the token
-        *
-        * @param string $token
-        * @return IShare The modified object
-        */
-       public function setToken($token);
-
-       /**
-        * Get the token
-        *
-        * @return string
-        */
-       public function getToken();
-
-       /**
-        * Get the parent it
-        *
-        * @return int
-        */
-       public function getParent();
-
-       /**
-        * Set the target of this share
-        *
-        * @param string $target
-        * @return IShare The modified object
-        */
-       public function setTarget($target);
-
-       /**
-        * Get the target of this share
-        *
-        * @return string
-        */
-       public function getTarget();
-
-       /**
-        * Set the time this share was created
-        *
-        * @param int $shareTime
-        * @return IShare The modified object
-        */
-       public function setShareTime($shareTime);
-
-       /**
-        * Get the timestamp this share was created
-        *
-        * @return int
-        */
-       public function getShareTime();
-
-       /**
-        * Set mailSend
-        *
-        * @param bool $mailSend
-        * @return IShare The modified object
-        */
-       public function setMailSend($mailSend);
-
-       /**
-        * Get mailSend
-        *
-        * @return bool
-        */
-       public function getMailSend();
-}
diff --git a/lib/private/share20/ishareprovider.php b/lib/private/share20/ishareprovider.php
deleted file mode 100644 (file)
index 17ee4ab..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Share20;
-
-use OC\Share20\Exception\ShareNotFound;
-use OC\Share20\Exception\BackendError;
-use OCP\IUser;
-
-interface IShareProvider {
-
-       /**
-        * Return the identifier of this provider.
-        *
-        * @return string Containing only [a-zA-Z0-9]
-        */
-       public function identifier();
-
-       /**
-        * Share a path
-        * 
-        * @param IShare $share
-        * @return IShare The share object
-        */
-       public function create(IShare $share);
-
-       /**
-        * Update a share
-        *
-        * @param IShare $share
-        * @return IShare The share object
-        */
-       public function update(IShare $share);
-
-       /**
-        * Delete a share
-        *
-        * @param IShare $share
-        * @throws BackendError
-        */
-       public function delete(IShare $share);
-
-       /**
-        * Unshare a file from self as recipient.
-        * This may require special handling.
-        *
-        * @param IShare $share
-        * @param IUser $recipient
-        */
-       public function deleteFromSelf(IShare $share, IUser $recipient);
-
-       /**
-        * Get all shares by the given user
-        *
-        * @param IUser $user
-        * @param int $shareType
-        * @param \OCP\Files\File|\OCP\Files\Folder $node
-        * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
-        * @param int $limit The maximum number of shares to be returned, -1 for all shares
-        * @param int $offset
-        * @return Share[]
-        */
-       public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset);
-
-       /**
-        * Get share by id
-        *
-        * @param int $id
-        * @return IShare
-        * @throws ShareNotFound
-        */
-       public function getShareById($id);
-
-       /**
-        * Get children
-        *
-        * @param IShare $parent
-        * @return IShare[]
-        */
-       public function getChildren(IShare $parent);
-
-       /**
-        * Get shares for a given path
-        *
-        * @param \OCP\Files\Node $path
-        * @return IShare[]
-        */
-       public function getSharesByPath(\OCP\Files\Node $path);
-
-       /**
-        * Get shared with the given user
-        *
-        * @param IUser $user get shares where this user is the recipient
-        * @param int $shareType
-        * @param int $limit The max number of entries returned, -1 for all
-        * @param int $offset
-        * @param Share
-        */
-       public function getSharedWith(IUser $user, $shareType, $limit, $offset);
-
-       /**
-        * Get a share by token
-        *
-        * @param string $token
-        * @return IShare
-        * @throws ShareNotFound
-        */
-       public function getShareByToken($token);
-}
index 673cea9b946a2a4db8f7e2bb832939f6959b6ed9..867849102c8f59d200a3b84408d928b4a625fcf7 100644 (file)
@@ -20,9 +20,8 @@
  */
 namespace OC\Share20;
 
-
+use OCP\Share\IProviderFactory;
 use OC\Share20\Exception\BackendError;
-use OC\Share20\Exception\ProviderException;
 use OCP\IConfig;
 use OCP\IL10N;
 use OCP\ILogger;
@@ -45,9 +44,6 @@ class Manager {
        /** @var IProviderFactory */
        private $factory;
 
-       /** @var array */
-       private $type2provider;
-
        /** @var ILogger */
        private $logger;
 
@@ -91,9 +87,6 @@ class Manager {
                        IL10N $l,
                        IProviderFactory $factory
        ) {
-               $this->providers = [];
-               $this->type2provider = [];
-
                $this->logger = $logger;
                $this->config = $config;
                $this->secureRandom = $secureRandom;
@@ -147,10 +140,10 @@ class Manager {
        /**
         * Check for generic requirements before creating a share
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws \Exception
         */
-       protected function generalCreateChecks(IShare $share) {
+       protected function generalCreateChecks(\OCP\Share\IShare $share) {
                if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
                        // We expect a valid user as sharedWith for user shares
                        if (!($share->getSharedWith() instanceof \OCP\IUser)) {
@@ -266,10 +259,10 @@ class Manager {
        /**
         * Check for pre share requirements for user shares
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws \Exception
         */
-       protected function userCreateChecks(IShare $share) {
+       protected function userCreateChecks(\OCP\Share\IShare $share) {
                // Check if we can share with group members only
                if ($this->shareWithGroupMembersOnly()) {
                        // Verify we can share with this user
@@ -312,10 +305,10 @@ class Manager {
        /**
         * Check for pre share requirements for group shares
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws \Exception
         */
-       protected function groupCreateChecks(IShare $share) {
+       protected function groupCreateChecks(\OCP\Share\IShare $share) {
                // Verify if the user can share with this group
                if ($this->shareWithGroupMembersOnly()) {
                        if (!$share->getSharedWith()->inGroup($share->getSharedBy())) {
@@ -344,10 +337,10 @@ class Manager {
        /**
         * Check for pre share requirements for link shares
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws \Exception
         */
-       protected function linkCreateChecks(IShare $share) {
+       protected function linkCreateChecks(\OCP\Share\IShare $share) {
                // Are link shares allowed?
                if (!$this->shareApiAllowLinks()) {
                        throw new \Exception('Link sharing not allowed');
@@ -388,10 +381,10 @@ class Manager {
        /**
         * Check if the user that is sharing can actually share
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @return bool
         */
-       protected function canShare(IShare $share) {
+       protected function canShare(\OCP\Share\IShare $share) {
                if (!$this->shareApiEnabled()) {
                        return false;
                }
@@ -406,13 +399,13 @@ class Manager {
        /**
         * Share a path
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @return Share The share object
         * @throws \Exception
         *
         * TODO: handle link share permissions or check them
         */
-       public function createShare(IShare $share) {
+       public function createShare(\OCP\Share\IShare $share) {
                if (!$this->canShare($share)) {
                        throw new \Exception('The Share API is disabled');
                }
@@ -528,10 +521,10 @@ class Manager {
        /**
         * Update a share
         *
-        * @param IShare $share
-        * @return IShare The share object
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare The share object
         */
-       public function updateShare(IShare $share) {
+       public function updateShare(\OCP\Share\IShare $share) {
                $expirationDateUpdated = false;
 
                if (!$this->canShare($share)) {
@@ -604,10 +597,10 @@ class Manager {
        /**
         * Delete all the children of this share
         *
-        * @param IShare $share
-        * @return IShare[] List of deleted shares
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare[] List of deleted shares
         */
-       protected function deleteChildren(IShare $share) {
+       protected function deleteChildren(\OCP\Share\IShare $share) {
                $deletedShares = [];
 
                $provider = $this->factory->getProviderForType($share->getShareType());
@@ -626,16 +619,16 @@ class Manager {
        /**
         * Delete a share
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @throws ShareNotFound
         * @throws BackendError
         * @throws ShareNotFound
         */
-       public function deleteShare(IShare $share) {
+       public function deleteShare(\OCP\Share\IShare $share) {
                // Just to make sure we have all the info
                $share = $this->getShareById($share->getFullId());
 
-               $formatHookParams = function(IShare $share) {
+               $formatHookParams = function(\OCP\Share\IShare $share) {
                        // Prepare hook
                        $shareType = $share->getShareType();
                        $sharedWith = '';
@@ -694,10 +687,10 @@ class Manager {
         * the users in a groups deletes that share. But the provider should
         * handle this.
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @param IUser $recipient
         */
-       public function deleteFromSelf(IShare $share, IUser $recipient) {
+       public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
                list($providerId, $id) = $this->splitFullId($share->getId());
                $provider = $this->factory->getProvider($providerId);
 
@@ -713,7 +706,7 @@ class Manager {
         * @param bool $reshares
         * @param int $limit The maximum number of returned results, -1 for all results
         * @param int $offset
-        * @return IShare[]
+        * @return \OCP\Share\IShare[]
         */
        public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
                if ($path !== null &&
@@ -734,7 +727,7 @@ class Manager {
         * @param int $shareType
         * @param int $limit The maximum number of shares returned, -1 for all
         * @param int $offset
-        * @return IShare[]
+        * @return \OCP\Share\IShare[]
         */
        public function getSharedWith(IUser $user, $shareType, $limit = 50, $offset = 0) {
                $provider = $this->factory->getProviderForType($shareType);
@@ -797,11 +790,11 @@ class Manager {
        /**
         * Verify the password of a public share
         *
-        * @param IShare $share
+        * @param \OCP\Share\IShare $share
         * @param string $password
         * @return bool
         */
-       public function checkPassword(IShare $share, $password) {
+       public function checkPassword(\OCP\Share\IShare $share, $password) {
                if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) {
                        //TODO maybe exception?
                        return false;
@@ -852,7 +845,7 @@ class Manager {
 
        /**
         * Create a new share
-        * @return IShare;
+        * @return \OCP\Share\IShare;
         */
        public function newShare() {
                return new \OC\Share20\Share();
index 2e5282c1eb4201b0b13862871b32684a4220ad72..641473555962ea17503d919b7f5cc278547a92c0 100644 (file)
@@ -20,6 +20,7 @@
  */
 namespace OC\Share20;
 
+use OCP\Share\IProviderFactory;
 use OC\Share20\Exception\ProviderException;
 use OCP\IServerContainer;
 
index 3e42d5084763371770310fc0e885b93eb2b8886a..6b38d2db490b37fe5c2a6009be0fac2d203ab112 100644 (file)
@@ -24,7 +24,7 @@ use OCP\Files\Node;
 use OCP\IUser;
 use OCP\IGroup;
 
-class Share implements IShare {
+class Share implements \OCP\Share\IShare {
 
        /** @var string */
        private $id;
diff --git a/lib/public/share/iproviderfactory.php b/lib/public/share/iproviderfactory.php
new file mode 100644 (file)
index 0000000..3a8bacc
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share;
+
+use OC\Share20\Exception\ProviderException;
+use OCP\IServerContainer;
+
+/**
+ * Interface IProviderFactory
+ *
+ * @package OC\Share20
+ * @since 9.0.0
+ */
+interface IProviderFactory {
+
+       /**
+        * IProviderFactory constructor.
+        * @param IServerContainer $serverContainer
+        * @since 9.0.0
+        */
+       public function __construct(IServerContainer $serverContainer);
+
+       /**
+        * @param string $id
+        * @return IShareProvider
+        * @throws ProviderException
+        * @since 9.0.0
+        */
+       public function getProvider($id);
+
+       /**
+        * @param int $shareType
+        * @return IShareProvider
+        * @throws ProviderException
+        * @since 9.0.0
+        */
+       public function getProviderForType($shareType);
+}
diff --git a/lib/public/share/ishare.php b/lib/public/share/ishare.php
new file mode 100644 (file)
index 0000000..1038ccf
--- /dev/null
@@ -0,0 +1,283 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share;
+
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\Node;
+use OCP\IUser;
+use OCP\IGroup;
+
+/**
+ * Interface IShare
+ *
+ * @package OCP\Share
+ * @since 9.0.0
+ */
+interface IShare {
+
+       /**
+        * Get the id of the share
+        *
+        * @return string
+        * @since 9.0.0
+        */
+       public function getId();
+
+       /**
+        * Set the id of the share
+        *
+        * @param string $id
+        * @return \OCP\Share\IShare The modified share object
+        * @since 9.0.0
+        */
+       public function setId($id);
+
+       /**
+        * Get the full share id
+        *
+        * @return string
+        * @since 9.0.0
+        */
+       public function getFullId();
+
+       /**
+        * Set the provider id
+        *
+        * @param string $id
+        * @return \OCP\Share\IShare The modified share object\
+        * @since 9.0.0
+        */
+       public function setProviderId($id);
+
+       /**
+        * Set the path of this share
+        *
+        * @param Node $path
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setPath(Node $path);
+
+       /**
+        * Get the path of this share for the current user
+        *
+        * @return File|Folder
+        * @since 9.0.0
+        */
+       public function getPath();
+
+       /**
+        * Set the shareType
+        *
+        * @param int $shareType
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setShareType($shareType);
+
+       /**
+        * Get the shareType
+        *
+        * @return int
+        * @since 9.0.0
+        */
+       public function getShareType();
+
+       /**
+        * Set the receiver of this share
+        *
+        * @param IUser|IGroup|string
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setSharedWith($sharedWith);
+
+       /**
+        * Get the receiver of this share
+        *
+        * @return IUser|IGroup|string
+        * @since 9.0.0
+        */
+       public function getSharedWith();
+
+       /**
+        * Set the permissions
+        *
+        * @param int $permissions
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setPermissions($permissions);
+
+       /**
+        * Get the share permissions
+        *
+        * @return int
+        * @since 9.0.0
+        */
+       public function getPermissions();
+
+       /**
+        * Set the expiration date
+        *
+        * @param \DateTime $expireDate
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setExpirationDate($expireDate);
+
+       /**
+        * Get the share expiration date
+        *
+        * @return \DateTime
+        * @since 9.0.0
+        */
+       public function getExpirationDate();
+
+       /**
+        * Set the sharer of the path
+        *
+        * @param IUser|string $sharedBy
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setSharedBy($sharedBy);
+
+       /**
+        * Get share sharer
+        *
+        * @return IUser|string
+        * @since 9.0.0
+        */
+       public function getSharedBy();
+
+       /**
+        * Set the original share owner (who owns the path)
+        *
+        * @param IUser|string
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setShareOwner($shareOwner);
+
+       /**
+        * Get the original share owner (who owns the path)
+        *
+        * @return IUser|string
+        * @since 9.0.0
+        */
+       public function getShareOwner();
+
+       /**
+        * Set the password
+        *
+        * @param string $password
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setPassword($password);
+
+       /**
+        * Is a password set for this share
+        *
+        * @return string
+        * @since 9.0.0
+        */
+       public function getPassword();
+
+       /**
+        * Set the token
+        *
+        * @param string $token
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setToken($token);
+
+       /**
+        * Get the token
+        *
+        * @return string
+        * @since 9.0.0
+        */
+       public function getToken();
+
+       /**
+        * Get the parent it
+        *
+        * @return int
+        * @since 9.0.0
+        */
+       public function getParent();
+
+       /**
+        * Set the target of this share
+        *
+        * @param string $target
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setTarget($target);
+
+       /**
+        * Get the target of this share
+        *
+        * @return string
+        * @since 9.0.0
+        */
+       public function getTarget();
+
+       /**
+        * Set the time this share was created
+        *
+        * @param int $shareTime
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setShareTime($shareTime);
+
+       /**
+        * Get the timestamp this share was created
+        *
+        * @return int
+        * @since 9.0.0
+        */
+       public function getShareTime();
+
+       /**
+        * Set mailSend
+        *
+        * @param bool $mailSend
+        * @return \OCP\Share\IShare The modified object
+        * @since 9.0.0
+        */
+       public function setMailSend($mailSend);
+
+       /**
+        * Get mailSend
+        *
+        * @return bool
+        * @since 9.0.0
+        */
+       public function getMailSend();
+}
diff --git a/lib/public/share/ishareprovider.php b/lib/public/share/ishareprovider.php
new file mode 100644 (file)
index 0000000..fa1b63d
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share;
+
+use OC\Share20\Exception\ShareNotFound;
+use OC\Share20\Exception\BackendError;
+use OCP\IUser;
+
+/**
+ * Interface IShareProvider
+ *
+ * @package OCP\Share
+ * @since 9.0.0
+ */
+interface IShareProvider {
+
+       /**
+        * Return the identifier of this provider.
+        *
+        * @return string Containing only [a-zA-Z0-9]
+        * @since 9.0.0
+        */
+       public function identifier();
+
+       /**
+        * Share a path
+        * 
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare The share object
+        * @since 9.0.0
+        */
+       public function create(\OCP\Share\IShare $share);
+
+       /**
+        * Update a share
+        *
+        * @param \OCP\Share\IShare $share
+        * @return \OCP\Share\IShare The share object
+        * @since 9.0.0
+        */
+       public function update(\OCP\Share\IShare $share);
+
+       /**
+        * Delete a share
+        *
+        * @param \OCP\Share\IShare $share
+        * @since 9.0.0
+        */
+       public function delete(\OCP\Share\IShare $share);
+
+       /**
+        * Unshare a file from self as recipient.
+        * This may require special handling.
+        *
+        * @param \OCP\Share\IShare $share
+        * @param IUser $recipient
+        * @since 9.0.0
+        */
+       public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient);
+
+       /**
+        * Get all shares by the given user
+        *
+        * @param IUser $user
+        * @param int $shareType
+        * @param \OCP\Files\File|\OCP\Files\Folder $node
+        * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
+        * @param int $limit The maximum number of shares to be returned, -1 for all shares
+        * @param int $offset
+        * @return Share[]
+        * @since 9.0.0
+        */
+       public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset);
+
+       /**
+        * Get share by id
+        *
+        * @param int $id
+        * @return IShare
+        * @throws ShareNotFound
+        * @since 9.0.0
+        */
+       public function getShareById($id);
+
+       /**
+        * Get shares for a given path
+        *
+        * @param \OCP\Files\Node $path
+        * @return IShare[]
+        * @since 9.0.0
+        */
+       public function getSharesByPath(\OCP\Files\Node $path);
+
+       /**
+        * Get shared with the given user
+        *
+        * @param IUser $user get shares where this user is the recipient
+        * @param int $shareType
+        * @param int $limit The max number of entries returned, -1 for all
+        * @param int $offset
+        * @param Share
+        * @since 9.0.0
+        */
+       public function getSharedWith(IUser $user, $shareType, $limit, $offset);
+
+       /**
+        * Get a share by token
+        *
+        * @param string $token
+        * @return IShare
+        * @throws ShareNotFound
+        * @since 9.0.0
+        */
+       public function getShareByToken($token);
+}
index 2bbcdfa04892fbcbfc2703cfe6546e2dbb749a5f..565c5e97aa2f3d9b5a7b5b421df4f6709f87b54b 100644 (file)
@@ -326,7 +326,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
 
                $id = $qb->getLastInsertId();
 
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share->method('getId')->willReturn($id);
 
                $provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
@@ -361,7 +361,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
         * @expectedException \OC\Share20\Exception\BackendError
         */
        public function testDeleteFails() {
-               $share = $this->getMock('OC\Share20\IShare');
+               $share = $this->getMock('OCP\Share\IShare');
                $share
                        ->method('getId')
                        ->willReturn(42);
@@ -510,7 +510,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
                                ['group1', $group1]
                        ]));
 
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn($id);
 
                $children = $this->provider->getChildren($share);
index ef602fc8e4693f5154e9cb156bdee683c41f58ea..6dcfb37e126fff6d968651e9a3214226d51cb220 100644 (file)
@@ -20,8 +20,8 @@
  */
 namespace Test\Share20;
 
-use OC\Share20\IProviderFactory;
-use OC\Share20\IShare;
+use OCP\Share\IProviderFactory;
+use OCP\Share\IShare;
 use OC\Share20\Manager;
 use OC\Share20\Exception;
 
@@ -29,7 +29,7 @@ use OC\Share20\Share;
 use OCP\IL10N;
 use OCP\ILogger;
 use OCP\IConfig;
-use OC\Share20\IShareProvider;
+use OCP\Share\IShareProvider;
 use OCP\Security\ISecureRandom;
 use OCP\Security\IHasher;
 use OCP\Files\Mount\IMountManager;
@@ -102,7 +102,9 @@ class ManagerTest extends \Test\TestCase {
                        $this->factory
                );
 
-               $this->defaultProvider = $this->getMock('\OC\Share20\IShareProvider');
+               $this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
+                       ->disableOriginalConstructor()
+                       ->getMock();
                $this->defaultProvider->method('identifier')->willReturn('default');
                $this->factory->setProvider($this->defaultProvider);
 
@@ -130,7 +132,7 @@ class ManagerTest extends \Test\TestCase {
         * @expectedException \OC\Share20\Exception\ShareNotFound
         */
        public function testDeleteNoShareId() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
 
                $share
                        ->expects($this->once())
@@ -170,7 +172,7 @@ class ManagerTest extends \Test\TestCase {
                $path = $this->getMock('\OCP\Files\File');
                $path->method('getId')->willReturn(1);
 
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getId')->willReturn(42);
                $share->method('getFullId')->willReturn('prov:42');
                $share->method('getShareType')->willReturn($shareType);
@@ -261,7 +263,7 @@ class ManagerTest extends \Test\TestCase {
                $path = $this->getMock('\OCP\Files\File');
                $path->method('getId')->willReturn(1);
 
-               $share1 = $this->getMock('\OC\Share20\IShare');
+               $share1 = $this->getMock('\OCP\Share\IShare');
                $share1->method('getId')->willReturn(42);
                $share1->method('getFullId')->willReturn('prov:42');
                $share1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
@@ -270,7 +272,7 @@ class ManagerTest extends \Test\TestCase {
                $share1->method('getPath')->willReturn($path);
                $share1->method('getTarget')->willReturn('myTarget1');
 
-               $share2 = $this->getMock('\OC\Share20\IShare');
+               $share2 = $this->getMock('\OCP\Share\IShare');
                $share2->method('getId')->willReturn(43);
                $share2->method('getFullId')->willReturn('prov:43');
                $share2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
@@ -280,7 +282,7 @@ class ManagerTest extends \Test\TestCase {
                $share2->method('getTarget')->willReturn('myTarget2');
                $share2->method('getParent')->willReturn(42);
 
-               $share3 = $this->getMock('\OC\Share20\IShare');
+               $share3 = $this->getMock('\OCP\Share\IShare');
                $share3->method('getId')->willReturn(44);
                $share3->method('getFullId')->willReturn('prov:44');
                $share3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
@@ -383,14 +385,14 @@ class ManagerTest extends \Test\TestCase {
                        ->setMethods(['deleteShare'])
                        ->getMock();
 
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
 
-               $child1 = $this->getMock('\OC\Share20\IShare');
+               $child1 = $this->getMock('\OCP\Share\IShare');
                $child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
-               $child2 = $this->getMock('\OC\Share20\IShare');
+               $child2 = $this->getMock('\OCP\Share\IShare');
                $child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
-               $child3 = $this->getMock('\OC\Share20\IShare');
+               $child3 = $this->getMock('\OCP\Share\IShare');
                $child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
 
                $shares = [
@@ -419,7 +421,7 @@ class ManagerTest extends \Test\TestCase {
        }
 
        public function testGetShareById() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
 
                $this->defaultProvider
                        ->expects($this->once())
@@ -487,7 +489,7 @@ class ManagerTest extends \Test\TestCase {
 
        public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
                $permissions, $expireDate = null, $password = null) {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
 
                $share->method('getShareType')->willReturn($type);
                $share->method('getSharedWith')->willReturn($sharedWith);
@@ -1487,7 +1489,7 @@ class ManagerTest extends \Test\TestCase {
        }
 
        public function testGetShareByToken() {
-               $factory = $this->getMock('\OC\Share20\IProviderFactory');
+               $factory = $this->getMock('\OCP\Share\IProviderFactory');
 
                $manager = new Manager(
                        $this->logger,
@@ -1500,7 +1502,7 @@ class ManagerTest extends \Test\TestCase {
                        $factory
                );
 
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
 
                $factory->expects($this->once())
                        ->method('getProviderForType')
@@ -1517,13 +1519,13 @@ class ManagerTest extends \Test\TestCase {
        }
 
        public function testCheckPasswordNoLinkShare() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
                $this->assertFalse($this->manager->checkPassword($share, 'password'));
        }
 
        public function testCheckPasswordNoPassword() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
                $this->assertFalse($this->manager->checkPassword($share, 'password'));
 
@@ -1532,7 +1534,7 @@ class ManagerTest extends \Test\TestCase {
        }
 
        public function testCheckPasswordInvalidPassword() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
                $share->method('getPassword')->willReturn('password');
 
@@ -1542,7 +1544,7 @@ class ManagerTest extends \Test\TestCase {
        }
 
        public function testCheckPasswordValidPassword() {
-               $share = $this->getMock('\OC\Share20\IShare');
+               $share = $this->getMock('\OCP\Share\IShare');
                $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
                $share->method('getPassword')->willReturn('passwordHash');