Package com.atlassian.jira.workflow
Interface WorkflowManager
- All Known Implementing Classes:
OSWorkflowManager
@PublicApi
public interface WorkflowManager
The WorkflowManager is used to interface with the workflow implementation
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyAndDeleteDraftsForInactiveWorkflowsIn
(ApplicationUser user, Iterable<JiraWorkflow> workflows) Provided a set of workflows, this method will check, if the passed in inactive workflows have any drafts linked to them.void
copyAndDeleteDraftWorkflows
(ApplicationUser user, Set<JiraWorkflow> workflows) Deprecated.Since 5.1.copyWorkflow
(ApplicationUser user, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Clones a workflow by creating a deep copy of the workflow provided.copyWorkflow
(String username, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Deprecated.createDraftWorkflow
(ApplicationUser user, String parentWorkflowName) This will create an draft workflow of the named active workflow.createDraftWorkflow
(String username, String parentWorkflowName) Deprecated.org.ofbiz.core.entity.GenericValue
createIssue
(String remoteUserName, Map<String, Object> fields) Create an issue in the database.void
createWorkflow
(ApplicationUser user, JiraWorkflow workflow) void
createWorkflow
(String username, JiraWorkflow workflow) Deprecated.boolean
deleteDraftWorkflow
(String parentWorkflowName) Deletes all draft workflows (there should every be only one) for a given parent workflow.void
deleteWorkflow
(JiraWorkflow workflow) void
com.opensymphony.workflow.loader.ActionDescriptor
getActionDescriptor
(Issue issue, int actionId) Given an issue and the identifier if a workflow action, returns the ActionDescriptor associated.com.opensymphony.workflow.loader.ActionDescriptor
getActionDescriptor
(WorkflowProgressAware workflowProgressAware) Retrieve all currently active workflows.getDraftWorkflow
(String parentWorkflowName) Retrieve a single draft workflow by name.getInitialStatusIdForIssue
(Issue issue) Returns the initial status for the workflow the given issue belongs to.getNextStatusIdForAction
(Issue issue, int actionId) Given an issue and the identifier of a workflow action, returns the next status id for the issue if the action gets executed.Map<com.opensymphony.workflow.loader.ActionDescriptor,
Collection<com.opensymphony.workflow.loader.FunctionDescriptor>> getPostFunctionsForWorkflow
(JiraWorkflow workflow) Retrieve a map: actions -> post functions for a workflow.Gets the first stepId for the given action and workflow name.com.opensymphony.workflow.spi.WorkflowStore
getStore()
getWorkflow
(Issue issue) Retrieve the workflow for a given issue.getWorkflow
(Long projectId, String issueTypeId) Retrieve the workflow for a given project - issue type pair.getWorkflow
(String name) Retrieve a single workflow by name.getWorkflow
(org.ofbiz.core.entity.GenericValue issue) Deprecated.UsegetWorkflow(com.atlassian.jira.issue.Issue)
instead.getWorkflowClone
(String name) This method returns a JiraWorkflow, that contains aWorkflowDescriptor
that is mutable.getWorkflowFromScheme
(WorkflowScheme scheme, String issueTypeId) Return the workflow in a particular scheme for a given issue type.getWorkflowFromScheme
(org.ofbiz.core.entity.GenericValue scheme, String issueTypeId) Return the workflow in a particular scheme for a given issue type.Retrieve all of the workflows in the systemgetWorkflowsFromScheme
(Scheme workflowScheme) Returns all workflows for a given scheme.getWorkflowsFromScheme
(org.ofbiz.core.entity.GenericValue workflowScheme) Deprecated.Since 5.0.Retrieve all of the workflows in the system including drafts.boolean
isActive
(JiraWorkflow workflow) Determine whether or not a given workflow is active in the system.boolean
isEditable
(Issue issue) boolean
isEditable
(Issue issue, String nextStatusId) Checks if the issue will be editable in workflow step with given id.boolean
isSystemWorkflow
(JiraWorkflow workflow) Determine whether or not a given workflow is a system workflow.com.opensymphony.workflow.Workflow
makeWorkflow
(ApplicationUser user) PreparesWorkflow
object with given user as callercom.opensymphony.workflow.Workflow
makeWorkflow
(String userName) Deprecated.com.opensymphony.workflow.Workflow
makeWorkflowWithUserKey
(String userKey) com.opensymphony.workflow.Workflow
makeWorkflowWithUserName
(String userName) void
migrateIssueToWorkflow
(MutableIssue issue, JiraWorkflow newWorkflow, Status status) Migrates given issue to new workflow and sets new status on it.void
migrateIssueToWorkflow
(org.ofbiz.core.entity.GenericValue issue, JiraWorkflow newWorkflow, org.ofbiz.core.entity.GenericValue status) boolean
migrateIssueToWorkflowNoReindex
(org.ofbiz.core.entity.GenericValue issue, JiraWorkflow newWorkflow, org.ofbiz.core.entity.GenericValue status) Migrates given issue to new workflow and sets new status on it.void
overwriteActiveWorkflow
(ApplicationUser user, String workflowName) Saves the draft workflow into the active workflow.void
overwriteActiveWorkflow
(String username, String workflowName) Deprecated.void
removeWorkflowEntries
(org.ofbiz.core.entity.GenericValue issue) void
replaceConditionInTransition
(com.opensymphony.workflow.loader.ActionDescriptor transition, Map<String, String> matchMap, Map<String, String> newMap) Changes the parameter map of all conditions that have the parameter map matching matchMap by adding all properties from newMap.void
saveWorkflowWithoutAudit
(JiraWorkflow workflow) This method will save the workflow and it will not affect the updatedDate and updatedAuthorName meta attributes of the workflow.void
updateWorkflow
(ApplicationUser user, JiraWorkflow workflow) Saves the given JiraWorkflow, which may be either a "live" or "draft" version.void
updateWorkflow
(String username, JiraWorkflow workflow) Deprecated.void
updateWorkflowNameAndDescription
(ApplicationUser user, JiraWorkflow currentWorkflow, String newName, String newDescription) Used to change the name and description of an existing worfklow with the given name.void
updateWorkflowNameAndDescription
(String username, JiraWorkflow currentWorkflow, String newName, String newDescription) boolean
workflowExists
(String name)
-
Method Details
-
getWorkflows
Collection<JiraWorkflow> getWorkflows()Retrieve all of the workflows in the system- Returns:
- A Collection of
JiraWorkflow
objects.
-
getWorkflowsIncludingDrafts
List<JiraWorkflow> getWorkflowsIncludingDrafts()Retrieve all of the workflows in the system including drafts. We return a list as we want to keep workflows and associated drafts are adjacent.- Returns:
- A List of
JiraWorkflow
objects.
-
isActive
Determine whether or not a given workflow is active in the system.Active workflows are those currently assigned to schemes and associated with projects - they cannot be edited but can be used.
- Parameters:
workflow
- the JiraWorkflow to check- Returns:
- true if the given workflow is active
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
isSystemWorkflow
Determine whether or not a given workflow is a system workflow.Check for a system or XML based workflow - can not be edited.
- Parameters:
workflow
- the JiraWorkflow to check- Returns:
- true if the given workflow is a system workflow
- Throws:
WorkflowException
- maybe - but it doesn't look like it?
-
getActiveWorkflows
Retrieve all currently active workflows.- Returns:
- Collection of JiraWorkflow objects.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflow
Retrieve a single workflow by name. The returnedJiraWorkflow
contains a descriptor that by default isn't mutable.If you need to edit a workflow, please see
getWorkflowClone(String)
.- Parameters:
name
- The workflow name- Returns:
- A
JiraWorkflow
that wraps an Immutable WorkflowDescriptor or null - See Also:
-
getWorkflowClone
This method returns a JiraWorkflow, that contains aWorkflowDescriptor
that is mutable. This method should be called, if you require to edit the workflow.If you only need to view a workflow, please use
getWorkflow(String)
as it will provide better performance. Cloning a workflow is expensive, as it requires de-constructing and re-constructing the underlyingWorkflowDescriptor
from XML.- Parameters:
name
- The workflow name- Returns:
- A
JiraWorkflow
or null if it doesn't exist. - See Also:
-
getDraftWorkflow
Retrieve a single draft workflow by name. If there is not an draft workflow associated with the name this will return null.- Parameters:
parentWorkflowName
- is the name of the Saved workflow which identifies then paritally edited draft workflow to retrieve.- Returns:
- a JiraWorkflow that represents an draft edited workflow.
- Throws:
IllegalArgumentException
- if no parentWorkflow with the name provided can be found.- Since:
- v3.13
-
createDraftWorkflow
JiraWorkflow createDraftWorkflow(String username, String parentWorkflowName) throws IllegalStateException, IllegalArgumentException Deprecated.UsecreateDraftWorkflow(com.atlassian.jira.user.ApplicationUser, String)
instead. Since v6.0.This will create an draft workflow of the named active workflow. This draft workflow can be used to edit active workflows without overwriting the active workflow immediately.
This method will not allow you to create an draft workflow if the parent workflow is not active, the method will throw anIllegalStateException
in this case.- Parameters:
parentWorkflowName
- identifies the parent workflow that should be used as the template for creating the draft workflow.username
- identifies the user performing the action so that we can keep an audit trail of who has last saved the workflow. Empty string for anonymous user. If null anIllegalArgumentException
will be thrown- Returns:
- An instance of
JiraWorkflow
that represents a copy of the parent that can be edited without overwriting the active workflow immediately. - Throws:
IllegalStateException
- thrown if the parentWorkflow is not Active or the draft already existsIllegalArgumentException
- If the username is null- Since:
- v3.13
-
createDraftWorkflow
JiraWorkflow createDraftWorkflow(ApplicationUser user, String parentWorkflowName) throws IllegalStateException, IllegalArgumentException This will create an draft workflow of the named active workflow. This draft workflow can be used to edit active workflows without overwriting the active workflow immediately.
This method will not allow you to create an draft workflow if the parent workflow is not active, the method will throw anIllegalStateException
in this case.- Parameters:
parentWorkflowName
- identifies the parent workflow that should be used as the template for creating the draft workflow.user
- identifies the user performing the action so that we can keep an audit trail of who has last saved the workflow. Empty string for anonymous user. If null anIllegalArgumentException
will be thrown- Returns:
- An instance of
JiraWorkflow
that represents a copy of the parent that can be edited without overwriting the active workflow immediately. - Throws:
IllegalStateException
- thrown if the parentWorkflow is not Active or the draft already existsIllegalArgumentException
- If the username is null- Since:
- v3.13
-
deleteDraftWorkflow
Deletes all draft workflows (there should every be only one) for a given parent workflow.- Parameters:
parentWorkflowName
- The parentworkflow for which the draft workflow needs to be deleted.- Returns:
- true if a draft workflow as deleted, false otherwise.
- Throws:
IllegalArgumentException
- if the parentWorkflowName is null- Since:
- v3.13
-
getWorkflow
Deprecated.UsegetWorkflow(com.atlassian.jira.issue.Issue)
instead. Since v6.2.Retrieve the workflow for a given issue.- Parameters:
issue
- the Issue- Returns:
- the workflow for the given issue.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflow
Retrieve the workflow for a given issue.- Parameters:
issue
- the Issue- Returns:
- the workflow for the given issue.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflow
Retrieve the workflow for a given project - issue type pair.- Parameters:
projectId
- the ProjectissueTypeId
- the IssueType ID- Returns:
- the workflow for the given project - issue type pair.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflowFromScheme
JiraWorkflow getWorkflowFromScheme(org.ofbiz.core.entity.GenericValue scheme, String issueTypeId) throws WorkflowException Return the workflow in a particular scheme for a given issue type.- Parameters:
scheme
- the SchemeissueTypeId
- the IssueType ID- Returns:
- the workflow for the issue type in the scheme.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflowFromScheme
JiraWorkflow getWorkflowFromScheme(WorkflowScheme scheme, String issueTypeId) throws WorkflowException Return the workflow in a particular scheme for a given issue type.- Parameters:
scheme
- the SchemeissueTypeId
- the IssueType ID- Returns:
- the workflow for the issue type in the scheme.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflowsFromScheme
Collection<JiraWorkflow> getWorkflowsFromScheme(org.ofbiz.core.entity.GenericValue workflowScheme) throws WorkflowException Deprecated.Since 5.0. UsegetWorkflowsFromScheme(com.atlassian.jira.scheme.Scheme)
instead.Returns all workflows for a given scheme.- Parameters:
workflowScheme
- the Workflow Scheme.- Returns:
- Collection of workflow schemes, empty collection if none exists.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getWorkflowsFromScheme
Returns all workflows for a given scheme.- Parameters:
workflowScheme
- the Workflow Scheme.- Returns:
- Collection of workflow schemes, empty collection if none exists.
- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
getDefaultWorkflow
- Throws:
WorkflowException
-
createIssue
org.ofbiz.core.entity.GenericValue createIssue(String remoteUserName, Map<String, Object> fields) throws WorkflowExceptionCreate an issue in the database.- Parameters:
remoteUserName
- Issue creatorfields
- Map of fields. The key is the name of the field, and the type of the value depends on the key. Must include a key "issue", which containsMutableIssue
object (holding values, not yet persisted to disk). May include other fields (eg "pkey"->String key of project, "originalissueobject"->Issue object) passed onto the workflow engine.- Returns:
- The created issue GenericValue
- Throws:
WorkflowException
- If any errors occur while trying to create the issue.
-
removeWorkflowEntries
void removeWorkflowEntries(org.ofbiz.core.entity.GenericValue issue) -
doWorkflowAction
-
getStore
com.opensymphony.workflow.spi.WorkflowStore getStore() throws com.opensymphony.workflow.StoreException- Throws:
com.opensymphony.workflow.StoreException
-
createWorkflow
Deprecated.UsecreateWorkflow(com.atlassian.jira.user.ApplicationUser, JiraWorkflow)
instead. Since v6.0.- Parameters:
username
-workflow
-- Throws:
WorkflowException
-
createWorkflow
- Parameters:
user
-workflow
-- Throws:
WorkflowException
-
saveWorkflowWithoutAudit
This method will save the workflow and it will not affect the updatedDate and updatedAuthorName meta attributes of the workflow. This should only ever be invoked by system operations such as upgrade tasks. All other saves should use the methodupdateWorkflow(String, JiraWorkflow)
- Parameters:
workflow
- the workflow to save.- Throws:
WorkflowException
- RuntimeException wrapper for any errors.
-
deleteWorkflow
- Throws:
WorkflowException
-
getActionDescriptor
com.opensymphony.workflow.loader.ActionDescriptor getActionDescriptor(WorkflowProgressAware workflowProgressAware) throws Exception - Throws:
Exception
-
migrateIssueToWorkflow
void migrateIssueToWorkflow(MutableIssue issue, JiraWorkflow newWorkflow, Status status) throws WorkflowException Migrates given issue to new workflow and sets new status on it.- Parameters:
issue
- issue to migratenewWorkflow
- new workflowstatus
- new status- Throws:
WorkflowException
- if migration fails
-
migrateIssueToWorkflow
void migrateIssueToWorkflow(org.ofbiz.core.entity.GenericValue issue, JiraWorkflow newWorkflow, org.ofbiz.core.entity.GenericValue status) throws WorkflowException Deprecated.Migrates given issue to new workflow and sets new status on it.- Parameters:
issue
- issue to migratenewWorkflow
- new workflowstatus
- new status- Throws:
WorkflowException
- if migration fails
-
migrateIssueToWorkflowNoReindex
boolean migrateIssueToWorkflowNoReindex(org.ofbiz.core.entity.GenericValue issue, JiraWorkflow newWorkflow, org.ofbiz.core.entity.GenericValue status) throws WorkflowException Migrates given issue to new workflow and sets new status on it. It returns true iff the issue that was migrated needs a reindex. The passed issue is not reindexed even if necessary.- Parameters:
issue
- issue to migratenewWorkflow
- new workflowstatus
- new status- Returns:
- true if the issue
- Throws:
WorkflowException
- if migration fails
-
makeWorkflow
Deprecated.UsemakeWorkflow(com.atlassian.jira.user.ApplicationUser)
instead. Since v6.0.PreparesWorkflow
object with given username as caller- Parameters:
userName
- caller username- Returns:
- created
Workflow
-
makeWorkflow
PreparesWorkflow
object with given user as caller- Parameters:
user
- caller- Returns:
- created
Workflow
-
makeWorkflowWithUserName
-
makeWorkflowWithUserKey
-
workflowExists
- Throws:
WorkflowException
-
isEditable
-
isEditable
Checks if the issue will be editable in workflow step with given id.- Parameters:
issue
- the issue which is affected by the workflow actionnextStatusId
- the workflow status that the issue will be in after transition- Returns:
- a boolean value which indicates if the issue will be editable in step with given id
- Since:
- 8.3
-
getPostFunctionsForWorkflow
Map<com.opensymphony.workflow.loader.ActionDescriptor,Collection<com.opensymphony.workflow.loader.FunctionDescriptor>> getPostFunctionsForWorkflow(JiraWorkflow workflow) Retrieve a map: actions -> post functions for a workflow.- Parameters:
workflow
- The Workflow- Returns:
- Map of actions-> post functions
-
getStepId
Gets the first stepId for the given action and workflow name.- Parameters:
actionDescriptorId
- id of the ActionDescriptorworkflowName
- name of the JiraWorkflow- Returns:
- the first stepId for the given action and workflow name.
-
overwriteActiveWorkflow
Deprecated.UseoverwriteActiveWorkflow(com.atlassian.jira.user.ApplicationUser, String)
instead. Since v6.0.Saves the draft workflow into the active workflow.- Parameters:
username
- User will be added to the workflows Audit trailworkflowName
- The workflow to be overwritten
-
overwriteActiveWorkflow
Saves the draft workflow into the active workflow.- Parameters:
user
- User will be added to the workflows Audit trailworkflowName
- The workflow to be overwritten- Since:
- v6.0
-
updateWorkflow
Deprecated.UseupdateWorkflow(com.atlassian.jira.user.ApplicationUser, JiraWorkflow)
instead. Since v6.0.Saves the given JiraWorkflow, which may be either a "live" or "draft" version. This method does not save the changes to the active workflow. Instead, this is meant to be used to make persistent changes to your working edit. Once all changes have been made you can over write the active workflow by callingoverwriteActiveWorkflow(String, String)
- Parameters:
username
- User making the request.workflow
- The JiraWorkflow to save.- Throws:
IllegalArgumentException
- if the workflow or its descriptor is null.- Since:
- v3.13
-
updateWorkflow
Saves the given JiraWorkflow, which may be either a "live" or "draft" version. This method does not save the changes to the active workflow. Instead, this is meant to be used to make persistent changes to your working edit. Once all changes have been made you can over write the active workflow by callingoverwriteActiveWorkflow(ApplicationUser, String)
- Parameters:
user
- User making the request.workflow
- The JiraWorkflow to save.- Throws:
IllegalArgumentException
- if the workflow or its descriptor is null.- Since:
- v6.0
-
copyWorkflow
JiraWorkflow copyWorkflow(String username, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Deprecated.UsecopyWorkflow(com.atlassian.jira.user.ApplicationUser, String, String, JiraWorkflow)
instead. Since v6.0.Clones a workflow by creating a deep copy of the workflow provided.- Parameters:
username
- The user performing the operationclonedWorkflowName
- The name to store the new workflow with.clonedWorkflowDescription
- The description to store with the cloned workflow. Can be null.workflowToClone
- The workflow to copy.- Returns:
- A cloned copy of the original workflow.
-
copyWorkflow
JiraWorkflow copyWorkflow(ApplicationUser user, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Clones a workflow by creating a deep copy of the workflow provided.- Parameters:
user
- The user performing the operationclonedWorkflowName
- The name to store the new workflow with.clonedWorkflowDescription
- The description to store with the cloned workflow. Can be null.workflowToClone
- The workflow to copy.- Returns:
- A cloned copy of the original workflow.
-
updateWorkflowNameAndDescription
void updateWorkflowNameAndDescription(String username, JiraWorkflow currentWorkflow, String newName, String newDescription) Deprecated.Used to change the name and description of an existing worfklow with the given name.- Parameters:
username
- The user performing the operationcurrentWorkflow
- The workflow to update.newName
- The new name to save with the workflownewDescription
- The new description to save with the workflow
-
updateWorkflowNameAndDescription
void updateWorkflowNameAndDescription(ApplicationUser user, JiraWorkflow currentWorkflow, String newName, String newDescription) Used to change the name and description of an existing worfklow with the given name.- Parameters:
user
- The user performing the operationcurrentWorkflow
- The workflow to update.newName
- The new name to save with the workflownewDescription
- The new description to save with the workflow
-
copyAndDeleteDraftWorkflows
Deprecated.Since 5.1. This method should not be used directly by external developers as it is an operation that only makes sense in the context of a higher level operation in JIRA (i.e. project removal / changing the workflow scheme of a given project).Please use the API calls for these higher level operations instead.
Provided a set of workflows, this method will check, if the passed in inactive workflows have any drafts linked to them. If they do, it will copy the draft into a new inactive workflow, and then delete the draft.- Parameters:
user
- The user performing the operationworkflows
- A set of parentJiraWorkflow
s
-
copyAndDeleteDraftsForInactiveWorkflowsIn
@Internal void copyAndDeleteDraftsForInactiveWorkflowsIn(ApplicationUser user, Iterable<JiraWorkflow> workflows) Provided a set of workflows, this method will check, if the passed in inactive workflows have any drafts linked to them. If they do, it will copy the draft into a new inactive workflow, and then delete the draft.This method is only meant to be used internally in JIRA. External developers should not call this method directly.
- Parameters:
user
- The user performing the operationworkflows
- A set of parentJiraWorkflow
s
-
getNextStatusIdForAction
Given an issue and the identifier of a workflow action, returns the next status id for the issue if the action gets executed.- Parameters:
issue
- The issueactionId
- The identifier of a workflow action- Returns:
- The status id corresponding to the next status of the issue if the action got executed
-
getInitialStatusIdForIssue
@ExperimentalApi @Internal @Nonnull Optional<String> getInitialStatusIdForIssue(@Nonnull Issue issue) Returns the initial status for the workflow the given issue belongs to.- Parameters:
issue
- the issue in workflow for which the initial status should be returned- Returns:
- initial status id in the workflow
-
getActionDescriptor
@Nonnull com.opensymphony.workflow.loader.ActionDescriptor getActionDescriptor(@Nonnull Issue issue, int actionId) Given an issue and the identifier if a workflow action, returns the ActionDescriptor associated.- Parameters:
issue
- The issue.actionId
- The identifier of a workflow action.- Returns:
- The ActionDescriptor corresponding to the workflow action id for the given issue.
- Since:
- v7.0.3
-
replaceConditionInTransition
void replaceConditionInTransition(@Nonnull com.opensymphony.workflow.loader.ActionDescriptor transition, @Nonnull Map<String, String> matchMap, @Nonnull Map<String, String> newMap) Changes the parameter map of all conditions that have the parameter map matching matchMap by adding all properties from newMap.- Parameters:
transition
- transition to change the conditions inmatchMap
- the map used to determine if the condition should be modifiednewMap
- a map of properties to be added to the parameter map
-