Studio Developer Manual / Version 2110
Table Of ContentsThis section describes the server-side customizations required for workflow validation. The client-side counterpart is very simple and was already covered in section Section 9.26.3, “Workflow Fields”.
For the Studio server you can define or change validators that create issues for your workflow.
Each validator is linked to a workflow task and optionally its state, so that you can define different validators
for every stage of your process. For each set of validators you can additionally define a so called WorkflowValidationPreparation
.
This is a step that will be executed before the Workflow validators. (For example, the dependent content is calculated
in the WorkflowValidationPreparation
)
Adding custom workflow validators
In order to add validators or a preparation step for your workflow, you need to provide a Bean of type
WorkflowValidatorsModel
within your studio-lib extension.
In that model you need to set the processName
accordingly to the process, that you want to add
validators for.
Now you need to define validators that have to implement the Interface
com.coremedia.rest.cap.workflow.validation.WorkflowValidator
, and optionally a
WorkflowValidationPreparation
interface.
Depending on if you want to use the validator for the start of a workflow or for a certain task you need
to either place you validator in the workflowStartValidators
or the workflowTaskValidators
.
Note
If you want to add a validator for already existing Workflows you need to adapt the existing WorkflowValidatorsModel
bean
for that process.
Already existing validators
There is a set of already defined validators available, which you can use for your own validator lists.
You can get these validators via the Spring configuration class
com.coremedia.rest.cap.workflow.validation.WorkflowValidationConfiguration
.
Writing your own validator
If you want to define your own validator you need to implement the interface WorkflowValidator
and create issues within the method addIssuesIfInvalid
. The method will receive a
parameter
object that you can use to compute your issues from.
Within the parameter object, the isAbortRequestedRunnable
object is stored, that you need to
check if the validation was aborted.
You need to call the isAbortRequestedRunnable
method within your validator
regularly to make sure that an aborted validation does not go on longer than necessary.