Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed apps/workflowengine/.noopenapi
Empty file.
17 changes: 0 additions & 17 deletions apps/workflowengine/appinfo/routes.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'OCA\\WorkflowEngine\\Check\\TFileCheck' => $baseDir . '/../lib/Check/TFileCheck.php',
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => $baseDir . '/../lib/Check/UserGroupMembership.php',
'OCA\\WorkflowEngine\\Command\\Index' => $baseDir . '/../lib/Command/Index.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => $baseDir . '/../lib/Controller/AWorkflowController.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowOCSController' => $baseDir . '/../lib/Controller/AWorkflowOCSController.php',
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => $baseDir . '/../lib/Controller/GlobalWorkflowsController.php',
'OCA\\WorkflowEngine\\Controller\\RequestTimeController' => $baseDir . '/../lib/Controller/RequestTimeController.php',
'OCA\\WorkflowEngine\\Controller\\UserWorkflowsController' => $baseDir . '/../lib/Controller/UserWorkflowsController.php',
Expand All @@ -33,6 +33,7 @@
'OCA\\WorkflowEngine\\Migration\\PopulateNewlyIntroducedDatabaseFields' => $baseDir . '/../lib/Migration/PopulateNewlyIntroducedDatabaseFields.php',
'OCA\\WorkflowEngine\\Migration\\Version2000Date20190808074233' => $baseDir . '/../lib/Migration/Version2000Date20190808074233.php',
'OCA\\WorkflowEngine\\Migration\\Version2200Date20210805101925' => $baseDir . '/../lib/Migration/Version2200Date20210805101925.php',
'OCA\\WorkflowEngine\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
'OCA\\WorkflowEngine\\Service\\Logger' => $baseDir . '/../lib/Service/Logger.php',
'OCA\\WorkflowEngine\\Service\\RuleMatcher' => $baseDir . '/../lib/Service/RuleMatcher.php',
'OCA\\WorkflowEngine\\Settings\\ASettings' => $baseDir . '/../lib/Settings/ASettings.php',
Expand Down
3 changes: 2 additions & 1 deletion apps/workflowengine/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ComposerStaticInitWorkflowEngine
'OCA\\WorkflowEngine\\Check\\TFileCheck' => __DIR__ . '/..' . '/../lib/Check/TFileCheck.php',
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => __DIR__ . '/..' . '/../lib/Check/UserGroupMembership.php',
'OCA\\WorkflowEngine\\Command\\Index' => __DIR__ . '/..' . '/../lib/Command/Index.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => __DIR__ . '/..' . '/../lib/Controller/AWorkflowController.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowOCSController' => __DIR__ . '/..' . '/../lib/Controller/AWorkflowOCSController.php',
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/GlobalWorkflowsController.php',
'OCA\\WorkflowEngine\\Controller\\RequestTimeController' => __DIR__ . '/..' . '/../lib/Controller/RequestTimeController.php',
'OCA\\WorkflowEngine\\Controller\\UserWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/UserWorkflowsController.php',
Expand All @@ -48,6 +48,7 @@ class ComposerStaticInitWorkflowEngine
'OCA\\WorkflowEngine\\Migration\\PopulateNewlyIntroducedDatabaseFields' => __DIR__ . '/..' . '/../lib/Migration/PopulateNewlyIntroducedDatabaseFields.php',
'OCA\\WorkflowEngine\\Migration\\Version2000Date20190808074233' => __DIR__ . '/..' . '/../lib/Migration/Version2000Date20190808074233.php',
'OCA\\WorkflowEngine\\Migration\\Version2200Date20210805101925' => __DIR__ . '/..' . '/../lib/Migration/Version2200Date20210805101925.php',
'OCA\\WorkflowEngine\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
'OCA\\WorkflowEngine\\Service\\Logger' => __DIR__ . '/..' . '/../lib/Service/Logger.php',
'OCA\\WorkflowEngine\\Service\\RuleMatcher' => __DIR__ . '/..' . '/../lib/Service/RuleMatcher.php',
'OCA\\WorkflowEngine\\Settings\\ASettings' => __DIR__ . '/..' . '/../lib/Settings/ASettings.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,25 @@
use Doctrine\DBAL\Exception;
use OCA\WorkflowEngine\Helper\ScopeContext;
use OCA\WorkflowEngine\Manager;
use OCA\WorkflowEngine\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\WorkflowEngine\IEntityEvent;
use OCP\WorkflowEngine\IOperation;
use Psr\Log\LoggerInterface;

abstract class AWorkflowController extends OCSController {
/**
* @psalm-import-type WorkflowEngineOperator from ResponseDefinitions
* @psalm-import-type WorkflowEngineCheck from ResponseDefinitions
* @psalm-import-type WorkflowEngineRule from ResponseDefinitions
*/
abstract class AWorkflowOCSController extends OCSController {

public function __construct(
$appName,
Expand All @@ -37,11 +46,14 @@ public function __construct(
abstract protected function getScopeContext(): ScopeContext;

/**
* Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global?format=json"
* Retrieve all configured workflow rules
*
* @throws OCSForbiddenException
* @return DataResponse<Http::STATUS_OK, list<WorkflowEngineRule>, array{}>
*
* 200: List of workflows returned
*/
public function index(): DataResponse {
/** @var list<WorkflowEngineRule> $operationsByClass */
$operationsByClass = $this->manager->getAllOperations($this->getScopeContext());
Comment on lines +56 to 57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set the return type on the method instead

Copy link
Member Author

@nickvergessen nickvergessen Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not work, actually its wrong here as well. It's only true after the format call, but didn't know where else to add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that adding the type to the return annotation of formatOperation should work.


foreach ($operationsByClass as &$operations) {
Expand All @@ -54,9 +66,12 @@ public function index(): DataResponse {
}

/**
* Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global/OCA\\Workflow_DocToPdf\\Operation?format=json"
* Retrieve a specific workflow
*
* @throws OCSForbiddenException
* @param string $id Workflow ID to load
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule|list<empty>, array{}>
*
* 200: Workflow returned or empty array if the ID is unknown in the scope
*/
public function show(string $id): DataResponse {
$context = $this->getScopeContext();
Expand All @@ -72,9 +87,19 @@ public function show(string $id): DataResponse {
}

/**
* @throws OCSBadRequestException
* @throws OCSForbiddenException
* @throws OCSException
* Create a workflow
*
* @param class-string<IOperation> $class Operation class to execute
* @param string $name Name of the workflow rule
* @param list<WorkflowEngineCheck> $checks List of conditions that need to apply for the rule to match
* @param string $operation Operation class to execute on match
* @param string $entity The matched entity
* @param list<class-string<IEntityEvent>> $events The list of events on which the rule should be validated
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule, array{}>
*
* 200: Workflow created
*
* @throws OCSBadRequestException Thrown when a check or check value is invalid
*/
#[PasswordConfirmationRequired]
public function create(
Expand All @@ -101,9 +126,20 @@ public function create(
}

/**
* @throws OCSBadRequestException
* @throws OCSForbiddenException
* @throws OCSException
* Modify a workflow
*
* @param int $id Workflow ID to delete
* @param string $name Name of the workflow rule
* @param list<WorkflowEngineCheck> $checks List of conditions that need to apply for the rule to match
* @param string $operation Operation action to execute on match
* @param string $entity The matched entity
* @param list<class-string<IEntityEvent>> $events The list of events on which the rule should be validated
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule, array{}>
*
* 200: Workflow updated
*
* @throws OCSBadRequestException Thrown when a check or check value is invalid
* @throws OCSForbiddenException Thrown when workflow is from a different scope
*/
#[PasswordConfirmationRequired]
public function update(
Expand All @@ -130,9 +166,14 @@ public function update(
}

/**
* @throws OCSBadRequestException
* @throws OCSForbiddenException
* @throws OCSException
* Delete a workflow
*
* @param int $id Workflow ID to delete
* @return DataResponse<Http::STATUS_OK, bool, array{}>|DataResponse<Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: Workflow deleted
*
* @throws OCSForbiddenException Thrown when workflow is from a different scope
*/
#[PasswordConfirmationRequired]
public function destroy(int $id): DataResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,109 @@
namespace OCA\WorkflowEngine\Controller;

use OCA\WorkflowEngine\Helper\ScopeContext;
use OCA\WorkflowEngine\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\WorkflowEngine\IEntityEvent;
use OCP\WorkflowEngine\IManager;
use OCP\WorkflowEngine\IOperation;

class GlobalWorkflowsController extends AWorkflowController {
/**
* @psalm-import-type WorkflowEngineCheck from ResponseDefinitions
* @psalm-import-type WorkflowEngineRule from ResponseDefinitions
*/
class GlobalWorkflowsController extends AWorkflowOCSController {

private ?ScopeContext $scopeContext = null;

/**
* Retrieve all configured workflow rules
*
* @return DataResponse<Http::STATUS_OK, list<WorkflowEngineRule>, array{}>
*
* 200: List of workflows returned
*/
#[ApiRoute(verb: 'GET', url: '/api/v1/workflows/global')]
public function index(): DataResponse {
return parent::index();
}

/**
* Retrieve a specific workflow
*
* @param string $id Workflow ID to load
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule|list<empty>, array{}>
*
* 200: Workflow returned or empty array if the ID is unknown in the scope
*/
#[ApiRoute(verb: 'GET', url: '/api/v1/workflows/global/{id}')]
public function show(string $id): DataResponse {
return parent::show($id);
}

/**
* Create a workflow
*
* @param class-string<IOperation> $class Operation class to execute
* @param string $name Name of the workflow rule
* @param list<WorkflowEngineCheck> $checks List of conditions that need to apply for the rule to match
* @param string $operation Operation class to execute on match
* @param string $entity The matched entity
* @param list<class-string<IEntityEvent>> $events The list of events on which the rule should be validated
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule, array{}>
*
* 200: Workflow created
*
* @throws OCSBadRequestException Thrown when a check or check value is invalid
*/
#[PasswordConfirmationRequired]
#[ApiRoute(verb: 'POST', url: '/api/v1/workflows/global')]
public function create(string $class, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
return parent::create($class, $name, $checks, $operation, $entity, $events);
}

/**
* Modify a workflow
*
* @param int $id Workflow ID to delete
* @param string $name Name of the workflow rule
* @param list<WorkflowEngineCheck> $checks List of conditions that need to apply for the rule to match
* @param string $operation Operation action to execute on match
* @param string $entity The matched entity
* @param list<class-string<IEntityEvent>> $events The list of events on which the rule should be validated
* @return DataResponse<Http::STATUS_OK, WorkflowEngineRule, array{}>
*
* 200: Workflow updated
*
* @throws OCSBadRequestException Thrown when a check or check value is invalid
* @throws OCSForbiddenException Thrown when workflow is from a different scope
*/
#[PasswordConfirmationRequired]
#[ApiRoute(verb: 'PUT', url: '/api/v1/workflows/global/{id}')]
public function update(int $id, string $name, array $checks, string $operation, string $entity, array $events): DataResponse {
return parent::update($id, $name, $checks, $operation, $entity, $events);
}

/**
* Delete a workflow
*
* @param int $id Workflow ID to delete
* @return DataResponse<Http::STATUS_OK, bool, array{}>|DataResponse<Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: Workflow deleted
*
* @throws OCSForbiddenException Thrown when workflow is from a different scope
*/
#[PasswordConfirmationRequired]
#[ApiRoute(verb: 'DELETE', url: '/api/v1/workflows/global/{id}')]
public function destroy(int $id): DataResponse {
return parent::destroy($id);
}

protected function getScopeContext(): ScopeContext {
if ($this->scopeContext === null) {
$this->scopeContext = new ScopeContext(IManager::SCOPE_ADMIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace OCA\WorkflowEngine\Controller;

use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\JSONResponse;

Expand All @@ -17,6 +18,7 @@ class RequestTimeController extends Controller {
* @return JSONResponse
*/
#[NoAdminRequired]
#[FrontpageRoute(verb: 'GET', url: '/timezones')]
public function getTimezones($search = '') {
$timezones = \DateTimeZone::listIdentifiers();

Expand Down
Loading
Loading