Package com.atlassian.jira.bc.workflow
Interface WorkflowService
- All Known Implementing Classes:
DefaultWorkflowService
@PublicApi
public interface WorkflowService
This class is responsible for validation before passing the actual call to the underlying
WorkflowManager
.- Since:
- v3.13
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Enum specifying whether workflow is editable or not. -
Method Summary
Modifier and TypeMethodDescriptioncopyWorkflow
(JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Clones and persists a new workflow with the name given.createDraftWorkflow
(JiraServiceContext jiraServiceContext, String parentWorkflowName) Creates a copy of an active workflow for editing.boolean
deleteDraftWorkflow
(JiraServiceContext jiraServiceContext, String parentWorkflowName) Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.deleteWorkflow
(ApplicationUser deletingUser, String workflowName) Deletes the workflow which has the passed name.getDraftWorkflow
(JiraServiceContext jiraServiceContext, String parentWorkflowName) Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.getWorkflow
(JiraServiceContext jiraServiceContext, String name) Returns the workflow with the given name.getWorkflowPermission
(ApplicationUser applicationUser, JiraWorkflow workflow) Checks whether workflow is editable for given user.boolean
isStepOnDraftWithNoTransitionsOnParentWorkflow
(JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId) Deprecated.Depreciated as of 7.3.boolean
isWorkflowEditable
(ApplicationUser applicationUser, JiraWorkflow workflow) Checks if user can edit workflow.void
overwriteActiveWorkflow
(JiraServiceContext jiraServiceContext, String parentWorkflowName) This method will overwrite the parentWorkflow with a draft Workflow if it exists.void
updateWorkflow
(JiraServiceContext jiraServiceContext, JiraWorkflow workflow) Updates the workflow descriptor provided in the persistance mechanism implemented.void
updateWorkflowNameAndDescription
(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription) Used to change the name and description of an existing worfklow with the given name.void
validateAddWorkflowTransitionToDraft
(JiraServiceContext jiraServiceContext, JiraWorkflow newJiraworkflow, int stepId) Validates if a workflow transition can be added to a draft.void
validateCopyWorkflow
(JiraServiceContext jiraServiceContext, String newWorkflowName) Validates if a workflow can be cloned and saved with the provided name.void
validateOverwriteWorkflow
(JiraServiceContext jiraServiceContext, String workflowName) Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow.void
validateUpdateWorkflowNameAndDescription
(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName) Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.
-
Method Details
-
getDraftWorkflow
Given a parentWorkflowName, this methods will retrieved the relevant draft workflow linked to that parent.
If the parentWorkflow doesn't exist, this method returns null and will log an error in the servicecontext errorcollection. If no DraftWorkflow exists, then this method will simply return null.- Parameters:
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name to create an draft copy of.- Returns:
- A draft workflow or null if no draft workflow is found
-
createDraftWorkflow
Creates a copy of an active workflow for editing. This will not overwrite the current active workflow- Parameters:
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name to create an draft copy of.- Returns:
- A copy of the active workflow
-
deleteDraftWorkflow
Deletes draft workflows (there should only be one) that are associated with the given parent workflow name.- Parameters:
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name that the draft workflow to be deleted is associated with- Returns:
- true if an draft workflow was deleted, false otherwise
-
deleteWorkflow
Deletes the workflow which has the passed name.- Parameters:
deletingUser
- user who performs the deletionworkflowName
- name of the workflow to be deleted- Returns:
- the result of the operation.
-
overwriteActiveWorkflow
This method will overwrite the parentWorkflow with a draft Workflow if it exists. If it doesn't exist, this method will add an error to the errorcollection in the service context. The method will also check for the existance of the parent, and callvalidateOverwriteWorkflow(com.atlassian.jira.bc.JiraServiceContext, String)
to ensure the active workflow isn't being overwritten with an invalid draft workflow.- Parameters:
jiraServiceContext
- service context with user and error collectionparentWorkflowName
- The parent workflow name that will be overwritten with its draft workflow
-
validateOverwriteWorkflow
Validates that the draft workflow with the given name is allowed to be saved into the corresponding active workflow. Basically you are allowed to add new Steps and change the transitions. You are allowed to delete status from workflow only if there are no issues in deleted status that are using this workflow. You are not allowed to change an existing association between a step ID and an Issue status.- Parameters:
jiraServiceContext
- JiraServiceContextworkflowName
- Name of the workflow to be validated.
-
updateWorkflow
Updates the workflow descriptor provided in the persistance mechanism implemented. This method can be used for draft workflows, as well as for copies of active workflows. 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(com.atlassian.jira.bc.JiraServiceContext, String)
}- Parameters:
jiraServiceContext
- service context with user and error collectionworkflow
- contains the descriptor that the workflow will be updated to.- Throws:
IllegalArgumentException
- if theworkflow or its descriptor is null. Also thrown if there is no draft workflow associated with the provided parentWorkflowName.
-
validateUpdateWorkflowNameAndDescription
void validateUpdateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newWorkflowName) Validates that the workflow with currentName can have its name and description changed to newWorkflowName and newDescription.- Parameters:
jiraServiceContext
- service context with user and error collectioncurrentWorkflow
- The current workflow to be updated.newWorkflowName
- The new name to save with the workflow
-
updateWorkflowNameAndDescription
void updateWorkflowNameAndDescription(JiraServiceContext jiraServiceContext, JiraWorkflow currentWorkflow, String newName, String newDescription) Used to change the name and description of an existing worfklow with the given name.- Parameters:
jiraServiceContext
- service context with user and error collectioncurrentWorkflow
- The current workflow to be updated.newName
- The new name to save with the workflownewDescription
- The new descriptio to save with the workflow
-
getWorkflow
Returns the workflow with the given name.- Parameters:
jiraServiceContext
- service context with user and error collectionname
- the name of the workflow- Returns:
- the workflow with the given name.
-
validateCopyWorkflow
Validates if a workflow can be cloned and saved with the provided name. This means checking if the name is set, if it contains invalid characters, and if the workflow already exists.- Parameters:
jiraServiceContext
- service context with user and error collectionnewWorkflowName
- The name of the cloned workflow.
-
copyWorkflow
JiraWorkflow copyWorkflow(JiraServiceContext jiraServiceContext, String clonedWorkflowName, String clonedWorkflowDescription, JiraWorkflow workflowToClone) Clones and persists a new workflow with the name given. This will create a complete deep copy of the worfklow provided.- Parameters:
jiraServiceContext
- service context with user and error collectionclonedWorkflowName
- The name to store the cloned workflow with.clonedWorkflowDescription
- The description of the new copy. May be null.workflowToClone
- The workflow to clone.- Returns:
- A clone of the workflow provided.
-
isStepOnDraftWithNoTransitionsOnParentWorkflow
@Deprecated boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(JiraServiceContext jiraServiceContext, JiraWorkflow workflow, int stepId) Deprecated.Depreciated as of 7.3. Method was used to check if transition can be added to a status (status had to have at least one outgoing transition). After fixing https://jira.atlassian.com/browse/JRA-19091 this is no longer needed.Given a draft workflow and a step Id, this method returns true, if the step does not have any transitions on the original workflow.- Parameters:
jiraServiceContext
- service context with user and error collectionworkflow
- The draft workflow with the new stepstepId
- The stepId of the step to check- Returns:
- true if the step does not have any transitions on the original workflow.
-
validateAddWorkflowTransitionToDraft
void validateAddWorkflowTransitionToDraft(JiraServiceContext jiraServiceContext, JiraWorkflow newJiraworkflow, int stepId) Validates if a workflow transition can be added to a draft. If the original workflow for the draft does not have any outgoing transitions, then this method will add an error to the error collection.- Parameters:
jiraServiceContext
- service context with user and error collectionnewJiraworkflow
- The draft workflow to which the transition is being addedstepId
- The step to which the transition is being added.
-
getWorkflowPermission
@ExperimentalApi WorkflowService.WorkflowPermission getWorkflowPermission(ApplicationUser applicationUser, JiraWorkflow workflow) Checks whether workflow is editable for given user.- Parameters:
applicationUser
- The user to check permission forworkflow
- The workflow to which permission is checked- Returns:
- WorkflowPermission enum.
- Since:
- 7.4
-
isWorkflowEditable
Checks if user can edit workflow.- Parameters:
applicationUser
- The user to check permission forworkflow
- The workflow to which permission is checked- Returns:
- true if user can edit workflow, false otherwise.
- Since:
- 7.4
-