public class

WorkflowUtil

extends Object
java.lang.Object
   ↳ com.atlassian.jira.workflow.WorkflowUtil

Summary

Public Constructors
WorkflowUtil()
Public Methods
static void checkInvalidCharacters(String fieldValue, String fieldName, ErrorCollection errorCollection)
JRA-4429 (prevent invalid characters)
static String convertDescriptorToXML(WorkflowDescriptor descriptor)
Converts a com.opensymphony.workflow.loader.WorkflowDescriptor to XML.
static WorkflowDescriptor convertXMLtoWorkflowDescriptor(String workflowDescriptorXML)
Converts a string representation of a workflow XML into the com.opensymphony.workflow.loader.WorkflowDescriptor object representation.
static String getCallerKey(Map transientVars)
Given a map of transientVars from a Workflow Function, returns the user's key of the caller.
static ApplicationUser getCallerUser(Map transientVars)
Given a map of transientVars from a Workflow Function, returns the ApplicationUser object of the caller.
static int getNextId(List descriptors)
Get the next usable ID value for a given list of descriptors.
static int getNextId(List descriptors, int start)
Get the next usable ID value for a given list of descriptors and a start point.
static String getWorkflowDisplayName(JiraWorkflow workflow)
Appends "(Draft)" to the end of the workflow name for an draft workflow.
static WorkflowManager getWorkflowManager()
static String getWorkflowTransitionDescription(ActionDescriptor descriptor)
Get the translated description of the workflow transition.
static String getWorkflowTransitionDisplayName(ActionDescriptor descriptor)
Get the translated display name of a workflow transition.
static boolean isAcceptableName(String workflowName, String fieldName, ErrorCollection errorCollection)
Check if given workflow name is valid that means it: Is not blank, contains only ASCII characters, does not contain leading or trailing whitespaces If any of the above is not meet the first error is added to errorCollection If workflow name is valid then no error will be added to errorCollection
static boolean isAcceptableName(String workflowName)
See isAcceptableName(String, String, com.atlassian.jira.util.ErrorCollection)

This method does not provide information about error type.

static boolean isReservedKey(String key)
Return true if the passed string is a reserved workflow property key.
static void setActionScreen(ActionDescriptor actionDescriptor, FieldScreen screen)
Sets the view and screen for the given action.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public WorkflowUtil ()

Public Methods

public static void checkInvalidCharacters (String fieldValue, String fieldName, ErrorCollection errorCollection)

JRA-4429 (prevent invalid characters)

public static String convertDescriptorToXML (WorkflowDescriptor descriptor)

Converts a com.opensymphony.workflow.loader.WorkflowDescriptor to XML.

Parameters
descriptor The com.opensymphony.workflow.loader.WorkflowDescriptor to convert
Returns
  • An XML representation of the workflowdescritpor passed in.

public static WorkflowDescriptor convertXMLtoWorkflowDescriptor (String workflowDescriptorXML)

Converts a string representation of a workflow XML into the com.opensymphony.workflow.loader.WorkflowDescriptor object representation.

Parameters
workflowDescriptorXML the XML representation of an OSWorkflow
Returns
  • the com.opensymphony.workflow.loader.WorkflowDescriptor that represents the workflow.
Throws
FactoryException thrown if the XML is malformed or can not be converted to the object representation.

public static String getCallerKey (Map transientVars)

Given a map of transientVars from a Workflow Function, returns the user's key of the caller. It is highly discouraged to use this method directly when fetching user object. Please use getCallerUser(java.util.Map) instead.

Parameters
transientVars the "transientVars" from the workflow FunctionProvider
Returns
  • the userKey of the caller (can be null for anonymous).

public static ApplicationUser getCallerUser (Map transientVars)

Given a map of transientVars from a Workflow Function, returns the ApplicationUser object of the caller.

Parameters
transientVars the "transientVars" from the workflow FunctionProvider
Returns
  • the username of the caller (can be null for anonymous).

public static int getNextId (List descriptors)

Get the next usable ID value for a given list of descriptors.

public static int getNextId (List descriptors, int start)

Get the next usable ID value for a given list of descriptors and a start point.

public static String getWorkflowDisplayName (JiraWorkflow workflow)

Appends "(Draft)" to the end of the workflow name for an draft workflow.

Parameters
workflow The workflow to create the display name for.
Returns
  • A String with the workflow name plus an optional (Draft).

public static WorkflowManager getWorkflowManager ()

public static String getWorkflowTransitionDescription (ActionDescriptor descriptor)

Get the translated description of the workflow transition.

Parameters
descriptor The action descriptor to get the description of
Returns
  • the translated description of the workflow transition.

public static String getWorkflowTransitionDisplayName (ActionDescriptor descriptor)

Get the translated display name of a workflow transition.

Parameters
descriptor The action descriptor to get the name of
Returns
  • The name of the transition.

public static boolean isAcceptableName (String workflowName, String fieldName, ErrorCollection errorCollection)

Check if given workflow name is valid that means it: Is not blank, contains only ASCII characters, does not contain leading or trailing whitespaces If any of the above is not meet the first error is added to errorCollection If workflow name is valid then no error will be added to errorCollection

Parameters
workflowName name of the workflow to check
fieldName field name that the error should be associated with in errorCollection
errorCollection error collection that collects errors
Returns
  • true if workflow name is valid false otherwise
Throws
NullPointerException if fieldName or errorCollection is null

public static boolean isAcceptableName (String workflowName)

See isAcceptableName(String, String, com.atlassian.jira.util.ErrorCollection)

This method does not provide information about error type.

public static boolean isReservedKey (String key)

Return true if the passed string is a reserved workflow property key. Reserved keys are those that can't be changed by the user and can only be used internally by JIRA. The UI tries to hide these keys from the user.

Parameters
key the key to check.
Returns
  • true if the passed key is reserved or false otherwise.

public static void setActionScreen (ActionDescriptor actionDescriptor, FieldScreen screen)

Sets the view and screen for the given action.

Parameters
actionDescriptor Action who's screen to set.
screen Screen to be set for the action. Null indicates no screen.