Class WorkflowUtil

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

public class WorkflowUtil extends Object
  • Constructor Details

    • WorkflowUtil

      public WorkflowUtil()
  • Method Details

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

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

      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

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