How to execute all the validators defined in the Workflow transition step ?

Jedrzej Wolski September 14, 2018

I'm doing issue transition programmatically. I can easily check for permissions and conditions using IssueService.validateTransition(). I'm also able to get validators for each transition addressed by its ActionDescriptor, by a call to:

ActionDescriptor.getValidators()

Next, I would like to execute each validator through try {} in order to intercept InvalidInputException exception thrown when validator execution result is negative. This will allow me to skip a call to IssueService.transition() if it has no chance of succeeding. This way finally I could avoid annoying exception:

org.ofbiz.core.entity.GenericTransactionException: Commit failed, rollback previously requested by nested transaction

thrown whenever one of the chained, programmatical transitions fails because of unsatisfied validators (reason for this exception is addressed in https://jira.atlassian.com/browse/JRASERVER-40597). I need to implement such approach as JIRA API does not provide a method to validate transition against its validators.

I know that I can call ValidatorDescriptor.validate(...) method, but it requires transientVars to be passed. I know transientVars are automatically populated when workflow transition is executed by the JIRA user, but my question is how can I get/retrieve transientVars and the rest of required parameters for the transition going to be exectuted programmatically?

 

The ValidatorDescriptor.validate(...) method prototype is given here: 

https://docs.atlassian.com/software/jira/docs/api/7.1.8/com/atlassian/jira/workflow/SkippableValidator.html

as:

public void validate(Map transientVars,
                     Map args,
                     com.opensymphony.module.propertyset.PropertySet ps) h 

 

0 answers

Suggest an answer

Log in or Sign up to answer