summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-07-27 08:54:34 +0200
committerJoas Schilling <coding@schilljs.com>2016-07-27 10:21:26 +0200
commit681eebcfe613157e05919a3223fcd0bbbe324638 (patch)
tree654be10c0d4313b49520254e79d65602de466b38 /apps/workflowengine
parent7588f648a14bd6ec3c2573ede5327b0277ecccf0 (diff)
downloadnextcloud-server-681eebcfe613157e05919a3223fcd0bbbe324638.tar.gz
nextcloud-server-681eebcfe613157e05919a3223fcd0bbbe324638.zip
Remove php side of check registration
Diffstat (limited to 'apps/workflowengine')
-rw-r--r--apps/workflowengine/appinfo/routes.php1
-rw-r--r--apps/workflowengine/lib/AppInfo/Application.php12
-rw-r--r--apps/workflowengine/lib/Controller/FlowOperations.php21
-rw-r--r--apps/workflowengine/lib/Manager.php14
4 files changed, 9 insertions, 39 deletions
diff --git a/apps/workflowengine/appinfo/routes.php b/apps/workflowengine/appinfo/routes.php
index 69478b1715c..b8c9ae1c236 100644
--- a/apps/workflowengine/appinfo/routes.php
+++ b/apps/workflowengine/appinfo/routes.php
@@ -21,7 +21,6 @@
return [
'routes' => [
- ['name' => 'flowOperations#getChecks', 'url' => '/checks', 'verb' => 'GET'], // TODO rm and do via js?
['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'],
['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php
index c196ecd955c..84339503047 100644
--- a/apps/workflowengine/lib/AppInfo/Application.php
+++ b/apps/workflowengine/lib/AppInfo/Application.php
@@ -38,18 +38,6 @@ class Application extends \OCP\AppFramework\App {
public function registerHooksAndListeners() {
$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
$dispatcher->addListener(
- 'OCP\WorkflowEngine\RegisterCheckEvent',
- function(RegisterCheckEvent $event) {
- $event->addCheck(
- 'OCA\WorkflowEngine\Check\UserGroupMembership',
- 'User group membership',
- ['is', '!is']
- );
- },
- -100
- );
-
- $dispatcher->addListener(
'OCP\WorkflowEngine::loadAdditionalSettingScripts',
function() {
Util::addStyle('workflowengine', 'admin');
diff --git a/apps/workflowengine/lib/Controller/FlowOperations.php b/apps/workflowengine/lib/Controller/FlowOperations.php
index e0836c727a2..94b8b9ddc79 100644
--- a/apps/workflowengine/lib/Controller/FlowOperations.php
+++ b/apps/workflowengine/lib/Controller/FlowOperations.php
@@ -26,38 +26,19 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
-use OCP\WorkflowEngine\RegisterCheckEvent;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class FlowOperations extends Controller {
/** @var Manager */
protected $manager;
- /** @var EventDispatcherInterface */
- protected $dispatcher;
-
/**
* @param IRequest $request
* @param Manager $manager
- * @param EventDispatcherInterface $dispatcher
*/
- public function __construct(IRequest $request, Manager $manager, EventDispatcherInterface $dispatcher) {
+ public function __construct(IRequest $request, Manager $manager) {
parent::__construct('workflowengine', $request);
$this->manager = $manager;
- $this->dispatcher = $dispatcher;
- }
-
- /**
- * @NoCSRFRequired
- *
- * @return JSONResponse
- */
- public function getChecks() {
- $event = new RegisterCheckEvent();
- $this->dispatcher->dispatch('OCP\WorkflowEngine\RegisterCheckEvent', $event);
-
- return new JSONResponse($event->getChecks());
}
/**
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php
index 98c34e894cc..f2a04dfb0fa 100644
--- a/apps/workflowengine/lib/Manager.php
+++ b/apps/workflowengine/lib/Manager.php
@@ -110,8 +110,8 @@ class Manager implements IManager {
$checkInstance->setFileInfo($this->storage, $this->path);
return $checkInstance->executeCheck($check['operator'], $check['value']);
} else {
- // Check is invalid, assume it matches.
- return true;
+ // Check is invalid
+ throw new \RuntimeException('Check ' . htmlspecialchars($check['class']) . ' is invalid or does not exist');
}
}
@@ -258,10 +258,12 @@ class Manager implements IManager {
}
$result->closeCursor();
- // TODO What if a check is missing? Should we throw?
- // As long as we only allow AND-concatenation of checks, a missing check
- // is like a matching check, so it evaluates to true and therefor blocks
- // access. So better save than sorry.
+ $checkIds = array_diff($checkIds, array_keys($checks));
+
+ if (!empty($checkIds)) {
+ $missingCheck = array_pop($checkIds);
+ throw new \RuntimeException('Check #' . htmlspecialchars($missingCheck) . ' is invalid or does not exist');
+ }
return $checks;
}