com.atlassian.jira.workflow
Class WorkflowUtil

java.lang.Object
  extended by com.atlassian.jira.workflow.WorkflowUtil

public class WorkflowUtil
extends Object


Constructor Summary
WorkflowUtil()
           
 
Method Summary
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)
static String cloneWorkflowName(String currentName)
          Deprecated. Since 5.1. Use WorkflowCopyNameFactory instead.
static String convertDescriptorToXML(com.opensymphony.workflow.loader.WorkflowDescriptor descriptor)
          Converts a WorkflowDescriptor to XML.
static com.opensymphony.workflow.loader.WorkflowDescriptor convertXMLtoWorkflowDescriptor(String workflowDescriptorXML)
          Converts a string representation of a workflow XML into the WorkflowDescriptor object representation.
static com.atlassian.crowd.embedded.api.User getCaller(Map transientVars)
          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)
          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(org.ofbiz.core.entity.GenericValue issue, String metaKey)
          Return a meta attribute applying to a whole workflow (ie.
static String getMetaAttributeForIssue(org.ofbiz.core.entity.GenericValue issue, String metaKey)
          Return a workflow meta attribute for the current state of an issue.
static Map getMetaAttributesForIssue(org.ofbiz.core.entity.GenericValue issue)
          Get all meta attributes for an issue's current state.
static List getMetaAttributesForIssue(org.ofbiz.core.entity.GenericValue issue, String metaKeyPrefix)
          Return all meta attribute values whose key starts with a certain prefix.
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(com.opensymphony.workflow.loader.ActionDescriptor descriptor)
          Get the translated description of the workflow transition.
static String getWorkflowTransitionDisplayName(com.opensymphony.workflow.loader.ActionDescriptor descriptor)
          Get the translated display name of a workflow transition.
static String interpolateProjectKey(org.ofbiz.core.entity.GenericValue project, String groupName)
          Deprecated. Use replaceProjectKey(com.atlassian.jira.project.Project, String) instead. Since v5.0.
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 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 String replaceProjectKey(Project project, String groupName)
          Deprecated. Use Project Roles instead. Since v5.2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkflowUtil

public WorkflowUtil()
Method Detail

addToExistingTransientArgs

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.


getNextId

public static int getNextId(List descriptors)
Get the next usable ID value for a given list of descriptors.


getNextId

public static int getNextId(List descriptors,
                            int start)
Get the next usable ID value for a given list of descriptors and a start point.


interpolateProjectKey

public static String interpolateProjectKey(org.ofbiz.core.entity.GenericValue project,
                                           String groupName)
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


replaceProjectKey

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


getGlobalMetaAttributeForIssue

public static String getGlobalMetaAttributeForIssue(org.ofbiz.core.entity.GenericValue issue,
                                                    String metaKey)
Return a meta attribute applying to a whole workflow (ie. right under the start tag).


getMetaAttributeForIssue

public static String getMetaAttributeForIssue(org.ofbiz.core.entity.GenericValue issue,
                                              String metaKey)
Return a workflow meta attribute for the current state of an issue.


getMetaAttributesForIssue

public static List getMetaAttributesForIssue(org.ofbiz.core.entity.GenericValue issue,
                                             String metaKeyPrefix)
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.


getMetaAttributesForIssue

public static Map getMetaAttributesForIssue(org.ofbiz.core.entity.GenericValue issue)
Get all meta attributes for an issue's current state.


convertDescriptorToXML

public static String convertDescriptorToXML(com.opensymphony.workflow.loader.WorkflowDescriptor descriptor)
Converts a WorkflowDescriptor to XML.

Parameters:
descriptor - The WorkflowDescriptor to convert
Returns:
An XML representation of the workflowdescritpor passed in.

isAcceptableName

public static boolean isAcceptableName(String workflowName,
                                       @Nonnull
                                       String fieldName,
                                       @Nonnull
                                       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
Since:
5.1.7

isAcceptableName

public static boolean isAcceptableName(String workflowName)
See isAcceptableName(String, String, com.atlassian.jira.util.ErrorCollection)

This method does not provide information about error type.


checkInvalidCharacters

public static void checkInvalidCharacters(String fieldValue,
                                          String fieldName,
                                          ErrorCollection errorCollection)
JRA-4429 (prevent invalid characters)


convertXMLtoWorkflowDescriptor

public static com.opensymphony.workflow.loader.WorkflowDescriptor convertXMLtoWorkflowDescriptor(String workflowDescriptorXML)
                                                                                          throws com.opensymphony.workflow.FactoryException
Converts a string representation of a workflow XML into the WorkflowDescriptor object representation.

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

getWorkflowDisplayName

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).

cloneWorkflowName

@Deprecated
public static String cloneWorkflowName(String currentName)
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.

getWorkflowManager

public static WorkflowManager getWorkflowManager()

getWorkflowTransitionDisplayName

public static String getWorkflowTransitionDisplayName(com.opensymphony.workflow.loader.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.

getWorkflowTransitionDescription

public static String getWorkflowTransitionDescription(com.opensymphony.workflow.loader.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.

getCallerName

public static String getCallerName(Map transientVars)
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).
Since:
4.4
See Also:
FunctionProvider.execute(java.util.Map, java.util.Map, com.opensymphony.module.propertyset.PropertySet), WorkflowContext.getCaller(), getCaller(java.util.Map)

getCallerKey

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).
Since:
6.0
See Also:
getCallerUser(java.util.Map)

getCallerUser

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).
Since:
6.0

getCaller

public static com.atlassian.crowd.embedded.api.User getCaller(Map transientVars)
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).
Since:
4.4
See Also:
FunctionProvider.execute(java.util.Map, java.util.Map, com.opensymphony.module.propertyset.PropertySet), WorkflowContext.getCaller(), getCallerUser(java.util.Map)


Copyright © 2002-2014 Atlassian. All Rights Reserved.