Add federated share provider to core
This commit is contained in:
parent
9079388e02
commit
ba0bab294e
|
@ -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');
|
||||
|
|
|
@ -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.
|
||||
|
@ -62,6 +68,43 @@ class ProviderFactory implements IProviderFactory {
|
|||
return $this->defaultProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue