summaryrefslogtreecommitdiffstats
path: root/lib/private/share20
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-27 12:13:53 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-27 22:04:37 +0100
commit185b9c6edd56157f45c72800fdea104bd360925a (patch)
treed47fc798513a5d1e680451d24f81e43c1a5bc28e /lib/private/share20
parent0832cca54e09c9b1f04f3133cc1780ca6ab1ae3b (diff)
downloadnextcloud-server-185b9c6edd56157f45c72800fdea104bd360925a.tar.gz
nextcloud-server-185b9c6edd56157f45c72800fdea104bd360925a.zip
[Share 2.0] Move IShare to OCP
Diffstat (limited to 'lib/private/share20')
-rw-r--r--lib/private/share20/defaultshareprovider.php25
-rw-r--r--lib/private/share20/iproviderfactory.php53
-rw-r--r--lib/private/share20/ishare.php249
-rw-r--r--lib/private/share20/ishareprovider.php126
-rw-r--r--lib/private/share20/manager.php65
-rw-r--r--lib/private/share20/providerfactory.php1
-rw-r--r--lib/private/share20/share.php2
7 files changed, 44 insertions, 477 deletions
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index 36ba56d63a2..74dd408ad21 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -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
index b38666978db..00000000000
--- a/lib/private/share20/iproviderfactory.php
+++ /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
index d3ffd417fe0..00000000000
--- a/lib/private/share20/ishare.php
+++ /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
index 17ee4abb9a8..00000000000
--- a/lib/private/share20/ishareprovider.php
+++ /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);
-}
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 673cea9b946..867849102c8 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -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();
diff --git a/lib/private/share20/providerfactory.php b/lib/private/share20/providerfactory.php
index 2e5282c1eb4..64147355596 100644
--- a/lib/private/share20/providerfactory.php
+++ b/lib/private/share20/providerfactory.php
@@ -20,6 +20,7 @@
*/
namespace OC\Share20;
+use OCP\Share\IProviderFactory;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php
index 3e42d508476..6b38d2db490 100644
--- a/lib/private/share20/share.php
+++ b/lib/private/share20/share.php
@@ -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;