public class

WorkflowUtil

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

Summary

Public Constructors
WorkflowUtil()
Public Methods
static void addToExistingTransientArgs(Map transientArgs, String key, List list)
This method adds to an existing list stored in the transient args map.
static void checkInvalidCharacters(String fieldValue, String fieldName, ErrorCollection errorCollection)
JRA-4429 (prevent invalid characters)
@Deprecated static String cloneWorkflowName(String currentName)
This method is deprecated. Since 5.1. Use WorkflowCopyNameFactory instead.
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 User getCaller(Map transientVars)
This method is deprecated. Use getCallerUser(java.util.Map) instead. Since v6.0.
static String getCallerKey(Map transientVars)
Given a map of transientVars from a Workflow Function, returns the user's key of the caller.
static String getCallerName(Map transientVars)
This method is deprecated. Use getCallerUser(java.util.Map) instead. Since v6.0.
static ApplicationUser getCallerUser(Map transientVars)
Given a map of transientVars from a Workflow Function, returns the ApplicationUser object of the caller.
static String getGlobalMetaAttributeForIssue(GenericValue issue, String metaKey)
This method is deprecated. Use WorkflowManager instead as described above. Since v6.3.
static String getMetaAttributeForIssue(GenericValue issue, String metaKey)
This method is deprecated. Use Issue and WorkflowManager instead as described above. Since v6.3.
static List getMetaAttributesForIssue(GenericValue issue, String metaKeyPrefix)
This method is deprecated. Use Issue and WorkflowManager instead as described above. Since v6.3.
static Map getMetaAttributesForIssue(GenericValue issue)
This method is deprecated. Use Issue and WorkflowManager instead as described above. Since v6.3.
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 String interpolateProjectKey(GenericValue project, String groupName)
This method is deprecated. Use replaceProjectKey(com.atlassian.jira.project.Project, String) instead. Since v5.0.
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 String replaceProjectKey(Project project, String groupName)
This method is deprecated. Use Project Roles instead. Since v5.2.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public WorkflowUtil ()

Public Methods

public static void addToExistingTransientArgs (Map transientArgs, String key, List list)

This method adds to an existing list stored in the transient args map.

If the existing list does not exist, the new list is just added - otherwise the new list is added to the old list, and the result readded to the transientArgs map.

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

JRA-4429 (prevent invalid characters)

@Deprecated public static String cloneWorkflowName (String currentName)

This method is deprecated.
Since 5.1. Use WorkflowCopyNameFactory instead.

Creates a name to be used for a copy of a given workflow.

Parameters
currentName The name of the current workflow.
Returns
  • A name for the copy of the current workflow.

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 User getCaller (Map transientVars)

This method is deprecated.
Use getCallerUser(java.util.Map) instead. Since v6.0.

Given a map of transientVars from a Workflow Function, returns the User 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 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 String getCallerName (Map transientVars)

This method is deprecated.
Use getCallerUser(java.util.Map) instead. Since v6.0.

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

Parameters
transientVars the "transientVars" from the workflow FunctionProvider
Returns
  • the username 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 String getGlobalMetaAttributeForIssue (GenericValue issue, String metaKey)

This method is deprecated.
Use WorkflowManager instead as described above. Since v6.3.

Return a meta attribute applying to a whole workflow (ie. right under the start tag).

This method is deprecated because it is uses GenericValues and not considered a good candidate for a static utility method. If you really want to get hold of a Workflow's global meta attributes, use the WorkflowManager component directly. eg:

     workflowManager.getWorkflow(issue).getDescriptor().getMetaAttributes().get(metaKey);
 

public static String getMetaAttributeForIssue (GenericValue issue, String metaKey)

This method is deprecated.
Use Issue and WorkflowManager instead as described above. Since v6.3.

Return a workflow meta attribute for the current state of an issue.

This method is deprecated because it is uses GenericValues and not considered a good candidate for a static utility method. If you really want to get hold of a Workflow meta attributes, use the Issue object and WorkflowManager component. eg:

     workflowManager.getWorkflow(issue).getLinkedStep(issue.getStatusObject()).getMetaAttributes();
 

public static List getMetaAttributesForIssue (GenericValue issue, String metaKeyPrefix)

This method is deprecated.
Use Issue and WorkflowManager instead as described above. Since v6.3.

Return all meta attribute values whose key starts with a certain prefix. For example, given: 3 jira-qa jira-administrators

Prefix 'jira.permission.subtasks.comment.group' would return {'jira-qa', 'jira-administrators'}. Unfortunately OSWorkflow does not allow multiple meta attributes with the same name.

This method is deprecated because it is uses GenericValues and not considered a good candidate for a static utility method. If you really want to get hold of a Workflow meta attributes, use the Issue object and WorkflowManager component. eg:

     workflowManager.getWorkflow(issue).getLinkedStep(issue.getStatusObject()).getMetaAttributes();
 

public static Map getMetaAttributesForIssue (GenericValue issue)

This method is deprecated.
Use Issue and WorkflowManager instead as described above. Since v6.3.

Get all meta attributes for an issue's current state.

This method is deprecated because it is uses GenericValues and not considered a good candidate for a static utility method. If you really want to get hold of a Workflow meta attributes, use the Issue object and WorkflowManager component. eg:

     workflowManager.getWorkflow(issue).getLinkedStep(issue.getStatusObject()).getMetaAttributes();
 

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 String interpolateProjectKey (GenericValue project, String groupName)

This method is deprecated.
Use replaceProjectKey(com.atlassian.jira.project.Project, String) instead. Since v5.0.

Variable interpolation. Eg. given a project TestProject and groupName '${pkey}-users', will return 'TP-users', or null if groupName is null

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 String replaceProjectKey (Project project, String groupName)

This method is deprecated.
Use Project Roles instead. Since v5.2.

Replaces ${pkey} in the given groupName with the given Project's key. Eg. given a project TestProject(key="TP") and groupName '${pkey}-users', will return 'TP-users', or null if groupName is null