summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-04 10:00:55 +0100
committerBjörn Schießle <bjoern@schiessle.org>2016-02-08 11:30:48 +0100
commitba0bab294e198f84ae038e6b50ca6a03b1ca5bdf (patch)
tree43b619c30fa46379a7fc53dd8ed33fda6be1f721 /lib
parent9079388e02cefd006c74b435dfd70dcb5852d48b (diff)
downloadnextcloud-server-ba0bab294e198f84ae038e6b50ca6a03b1ca5bdf.tar.gz
nextcloud-server-ba0bab294e198f84ae038e6b50ca6a03b1ca5bdf.zip
Add federated share provider to core
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share20/manager.php4
-rw-r--r--lib/private/share20/providerfactory.php49
2 files changed, 53 insertions, 0 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 33085410e1d..c3c739e4874 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -166,6 +166,10 @@ class Manager implements IManager {
if ($share->getSharedWith() !== null) {
throw new \InvalidArgumentException('SharedWith should be empty');
}
+ } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
+ if ($share->getSharedWith() === null) {
+ throw new \InvalidArgumentException('SharedWith should not be empty');
+ }
} else {
// We can't handle other types yet
throw new \InvalidArgumentException('unkown share type');
diff --git a/lib/private/share20/providerfactory.php b/lib/private/share20/providerfactory.php
index 64147355596..dba96aebdcf 100644
--- a/lib/private/share20/providerfactory.php
+++ b/lib/private/share20/providerfactory.php
@@ -20,6 +20,10 @@
*/
namespace OC\Share20;
+use OCA\FederatedFileSharing\AddressHandler;
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\FederatedFileSharing\Notifications;
+use OCA\FederatedFileSharing\TokenHandler;
use OCP\Share\IProviderFactory;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
@@ -35,6 +39,8 @@ class ProviderFactory implements IProviderFactory {
private $serverContainer;
/** @var DefaultShareProvider */
private $defaultProvider = null;
+ /** @var FederatedShareProvider */
+ private $federatedProvider = null;
/**
* IProviderFactory constructor.
@@ -63,6 +69,43 @@ class ProviderFactory implements IProviderFactory {
}
/**
+ * Create the federated share provider
+ *
+ * @return FederatedShareProvider
+ */
+ protected function federatedShareProvider() {
+ if ($this->federatedProvider === null) {
+ /*
+ * TODO: add factory to federated sharing app
+ */
+ $l = $this->serverContainer->getL10N('federatedfilessharing');
+ $addressHandler = new AddressHandler(
+ $this->serverContainer->getURLGenerator(),
+ $l
+ );
+ $notifications = new Notifications(
+ $addressHandler,
+ $this->serverContainer->getHTTPClientService()
+ );
+ $tokenHandler = new TokenHandler(
+ $this->serverContainer->getSecureRandom()
+ );
+
+ $this->federatedProvider = new FederatedShareProvider(
+ $this->serverContainer->getDatabaseConnection(),
+ $addressHandler,
+ $notifications,
+ $tokenHandler,
+ $l,
+ $this->serverContainer->getLogger(),
+ $this->serverContainer->getRootFolder()
+ );
+ }
+
+ return $this->federatedProvider;
+ }
+
+ /**
* @inheritdoc
*/
public function getProvider($id) {
@@ -70,6 +113,10 @@ class ProviderFactory implements IProviderFactory {
return $this->defaultShareProvider();
}
+ if ($id === 'ocFederatedSharing') {
+ return $this->federatedShareProvider();
+ }
+
throw new ProviderException('No provider with id .' . $id . ' found.');
}
@@ -83,6 +130,8 @@ class ProviderFactory implements IProviderFactory {
$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
$shareType === \OCP\Share::SHARE_TYPE_LINK) {
return $this->defaultShareProvider();
+ } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
+ return $this->federatedShareProvider();
}
throw new ProviderException('No share provider for share type ' . $shareType);