Package com.atlassian.jira.workflow
Class WorkflowUtil
java.lang.Object
com.atlassian.jira.workflow.WorkflowUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckInvalidCharacters(String fieldValue, String fieldName, ErrorCollection errorCollection) JRA-4429 (prevent invalid characters)static StringconvertDescriptorToXML(com.opensymphony.workflow.loader.WorkflowDescriptor descriptor) Converts aWorkflowDescriptorto XML.static com.opensymphony.workflow.loader.WorkflowDescriptorconvertXMLtoWorkflowDescriptor(String workflowDescriptorXML) Converts a string representation of a workflow XML into theWorkflowDescriptorobject representation.static StringgetCallerKey(Map transientVars) Given a map of transientVars from a Workflow Function, returns the user's key of the caller.static ApplicationUsergetCallerUser(Map transientVars) Given a map of transientVars from a Workflow Function, returns theApplicationUserobject of the caller.static intGet the next usable ID value for a given list of descriptors.static intGet the next usable ID value for a given list of descriptors and a start point.static StringgetWorkflowDisplayName(JiraWorkflow workflow) Appends "(Draft)" to the end of the workflow name for an draft workflow.static WorkflowManagerstatic StringgetWorkflowTransitionDescription(com.opensymphony.workflow.loader.ActionDescriptor descriptor) Get the translated description of the workflow transition.static StringgetWorkflowTransitionDisplayName(com.opensymphony.workflow.loader.ActionDescriptor descriptor) Get the translated display name of a workflow transition.static IntegergetWorkflowTransitionOpsbarSequence(com.opensymphony.workflow.loader.ActionDescriptor action) Get the opsbar sequence number (order) or the workflow transition.static booleanisAcceptableName(String workflowName) static booleanisAcceptableName(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 toerrorCollectionIf workflow name is valid then no error will be added toerrorCollectionstatic booleanisReservedKey(String key) Return true if the passed string is a reserved workflow property key.static voidsetActionScreen(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor, FieldScreen screen) Sets the view and screen for the given action.
-
Constructor Details
-
WorkflowUtil
public WorkflowUtil()
-
-
Method Details
-
getNextId
Get the next usable ID value for a given list of descriptors. -
getNextId
Get the next usable ID value for a given list of descriptors and a start point. -
convertDescriptorToXML
public static String convertDescriptorToXML(com.opensymphony.workflow.loader.WorkflowDescriptor descriptor) Converts aWorkflowDescriptorto XML.- Parameters:
descriptor- TheWorkflowDescriptorto 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 toerrorCollectionIf workflow name is valid then no error will be added toerrorCollection- Parameters:
workflowName- name of the workflow to checkfieldName- field name that the error should be associated with inerrorCollectionerrorCollection- 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
SeeisAcceptableName(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) -
isReservedKey
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:
trueif the passed key is reserved orfalseotherwise.
-
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 theWorkflowDescriptorobject representation.- Parameters:
workflowDescriptorXML- the XML representation of an OSWorkflow- Returns:
- the
WorkflowDescriptorthat represents the workflow. - Throws:
com.opensymphony.workflow.FactoryException- thrown if the XML is malformed or can not be converted to the object representation.
-
getWorkflowDisplayName
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).
-
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.
-
getWorkflowTransitionOpsbarSequence
@ExperimentalApi @Nonnull public static Integer getWorkflowTransitionOpsbarSequence(@Nullable com.opensymphony.workflow.loader.ActionDescriptor action) Get the opsbar sequence number (order) or the workflow transition.- Parameters:
action- The action descriptor to get the sequence/order of- Returns:
- the opsbar sequence/order of the workflow transition
- Since:
- 9.0
-
getCallerKey
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 usegetCallerUser(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
Given a map of transientVars from a Workflow Function, returns theApplicationUserobject 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
-
setActionScreen
public static void setActionScreen(@Nonnull com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor, @Nullable 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.
-