summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-08-21 20:45:40 +0200
committerGitHub <noreply@github.com>2016-08-21 20:45:40 +0200
commitede32a558a1ee6e8a2baa91e98a4d09a471a6234 (patch)
tree739ac429d397750cd853a6fe3f667c2a3b4c15ec /apps
parent2e857c6d90cba91ab864e09b293d37b1c4105926 (diff)
parent75e058e3f2bc080e873da41a7dd249ea76395c04 (diff)
downloadnextcloud-server-ede32a558a1ee6e8a2baa91e98a4d09a471a6234.tar.gz
nextcloud-server-ede32a558a1ee6e8a2baa91e98a4d09a471a6234.zip
Merge pull request #969 from nextcloud/allow-to-validate-operations
Allow to validate operations
Diffstat (limited to 'apps')
-rw-r--r--apps/systemtags/appinfo/info.xml2
-rw-r--r--apps/systemtags/lib/Settings/Admin.php2
-rw-r--r--apps/systemtags/tests/Settings/AdminTest.php2
-rw-r--r--apps/workflowengine/lib/Manager.php48
4 files changed, 46 insertions, 8 deletions
diff --git a/apps/systemtags/appinfo/info.xml b/apps/systemtags/appinfo/info.xml
index 46bb9278838..15b9abed0d4 100644
--- a/apps/systemtags/appinfo/info.xml
+++ b/apps/systemtags/appinfo/info.xml
@@ -7,7 +7,7 @@
<licence>AGPL</licence>
<author>Vincent Petry, Joas Schilling</author>
<default_enable/>
- <version>1.1.1</version>
+ <version>1.1.2</version>
<dependencies>
<owncloud min-version="9.2" max-version="9.2" />
</dependencies>
diff --git a/apps/systemtags/lib/Settings/Admin.php b/apps/systemtags/lib/Settings/Admin.php
index fbdec8741f7..c8d986414e6 100644
--- a/apps/systemtags/lib/Settings/Admin.php
+++ b/apps/systemtags/lib/Settings/Admin.php
@@ -39,7 +39,7 @@ class Admin implements ISettings {
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
- return 'sharing';
+ return 'additional';
}
/**
diff --git a/apps/systemtags/tests/Settings/AdminTest.php b/apps/systemtags/tests/Settings/AdminTest.php
index b1faf82cf25..174fd382159 100644
--- a/apps/systemtags/tests/Settings/AdminTest.php
+++ b/apps/systemtags/tests/Settings/AdminTest.php
@@ -43,7 +43,7 @@ class AdminTest extends TestCase {
}
public function testGetSection() {
- $this->assertSame('sharing', $this->admin->getSection());
+ $this->assertSame('additional', $this->admin->getSection());
}
public function testGetPriority() {
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php
index b72836a919c..9140ef73ea7 100644
--- a/apps/workflowengine/lib/Manager.php
+++ b/apps/workflowengine/lib/Manager.php
@@ -30,6 +30,7 @@ use OCP\IL10N;
use OCP\IServerContainer;
use OCP\WorkflowEngine\ICheck;
use OCP\WorkflowEngine\IManager;
+use OCP\WorkflowEngine\IOperation;
class Manager implements IManager {
@@ -176,6 +177,8 @@ class Manager implements IManager {
* @throws \UnexpectedValueException
*/
public function addOperation($class, $name, array $checks, $operation) {
+ $this->validateOperation($class, $name, $checks, $operation);
+
$checkIds = [];
foreach ($checks as $check) {
$checkIds[] = $this->addCheck($check['class'], $check['operator'], $check['value']);
@@ -204,6 +207,9 @@ class Manager implements IManager {
* @throws \UnexpectedValueException
*/
public function updateOperation($id, $name, array $checks, $operation) {
+ $row = $this->getOperation($id);
+ $this->validateOperation($row['class'], $name, $checks, $operation);
+
$checkIds = [];
foreach ($checks as $check) {
$checkIds[] = $this->addCheck($check['class'], $check['operator'], $check['value']);
@@ -233,6 +239,43 @@ class Manager implements IManager {
}
/**
+ * @param string $class
+ * @param string $name
+ * @param array[] $checks
+ * @param string $operation
+ * @throws \UnexpectedValueException
+ */
+ protected function validateOperation($class, $name, array $checks, $operation) {
+ try {
+ /** @var IOperation $instance */
+ $instance = $this->container->query($class);
+ } catch (QueryException $e) {
+ throw new \UnexpectedValueException($this->l->t('Operation %s does not exist', $class));
+ }
+
+ if (!($instance instanceof IOperation)) {
+ throw new \UnexpectedValueException($this->l->t('Operation %s is invalid', $class));
+ }
+
+ $instance->validateOperation($name, $checks, $operation);
+
+ foreach ($checks as $check) {
+ try {
+ /** @var ICheck $instance */
+ $instance = $this->container->query($check['class']);
+ } catch (QueryException $e) {
+ throw new \UnexpectedValueException($this->l->t('Check %s does not exist', $class));
+ }
+
+ if (!($instance instanceof ICheck)) {
+ throw new \UnexpectedValueException($this->l->t('Check %s is invalid', $class));
+ }
+
+ $instance->validateCheck($check['operator'], $check['value']);
+ }
+ }
+
+ /**
* @param int[] $checkIds
* @return array[]
*/
@@ -279,13 +322,8 @@ class Manager implements IManager {
* @param string $operator
* @param string $value
* @return int Check unique ID
- * @throws \UnexpectedValueException
*/
protected function addCheck($class, $operator, $value) {
- /** @var ICheck $check */
- $check = $this->container->query($class);
- $check->validateCheck($operator, $value);
-
$hash = md5($class . '::' . $operator . '::' . $value);
$query = $this->connection->getQueryBuilder();